}
;
-Literal :
+Literal:
INTEGER_LITERAL
{ write_exp_elt_opcode (OP_LONG);
write_exp_elt_type ($1.type);
FieldAccess:
Primary '.' SimpleName
{ push_fieldnames ($3); }
+| VARIABLE '.' SimpleName
+ { push_fieldnames ($3); }
/*| SUPER '.' SimpleName { FIXME } */
;
Name '[' Expression ']'
/* FIXME - This is nasty - need to shuffle expr stack. */
{ error ("`Name[Expr]' not implemented yet - try `(Name)[Expr]'"); }
+| VARIABLE '[' Expression ']'
+ { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
| PrimaryNoNewArray '[' Expression ']'
- {
- warning("array subscripts not implemented for Java");
- write_exp_elt_opcode (BINOP_SUBSCRIPT); }
+ { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
;
PostfixExpression:
{ write_exp_elt_opcode (UNOP_CAST);
write_exp_elt_type (java_array_type ($2, $3));
write_exp_elt_opcode (UNOP_CAST); }
-| '(' Expression ')' UnaryExpressionNotPlusMinus /* FIXME */
+| '(' Expression ')' UnaryExpressionNotPlusMinus
+ {
+ int exp_size = expout_ptr;
+ int last_exp_size = length_of_subexp(expout, expout_ptr);
+ struct type *type;
+ int i;
+ int base = expout_ptr - last_exp_size - 3;
+ if (base < 0 || expout->elts[base+2].opcode != OP_TYPE)
+ error ("invalid cast expression");
+ type = expout->elts[base+1].type;
+ /* Remove the 'Expression' and slide the
+ UnaryExpressionNotPlusMinus down to replace it. */
+ for (i = 0; i < last_exp_size; i++)
+ expout->elts[base + i] = expout->elts[base + i + 3];
+ expout_ptr -= 3;
+ if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
+ type = lookup_pointer_type (type);
+ write_exp_elt_opcode (UNOP_CAST);
+ write_exp_elt_type (type);
+ write_exp_elt_opcode (UNOP_CAST);
+ }
| '(' Name Dims ')' UnaryExpressionNotPlusMinus
{ write_exp_elt_opcode (UNOP_CAST);
write_exp_elt_type (java_array_type (java_type_from_name ($2), $3));
dot_index++; /* Skip '.' */
name.ptr += dot_index;
name.length -= dot_index;
+ dot_index = 0;
while (dot_index < name.length && name.ptr[dot_index] != '.')
dot_index++;
token.ptr = name.ptr;