aboutsummaryrefslogtreecommitdiff
path: root/gdb/jv-exp.y
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>1997-10-03 23:05:12 +0000
committerPer Bothner <per@bothner.com>1997-10-03 23:05:12 +0000
commit8d2755a953cfc95a09b19010aa47d9c998079acf (patch)
treef5fa6eb95035e87b5ba5b7e8f1375065371c707b /gdb/jv-exp.y
parenta3e8c5b712d92489860090317327dd80d00893a6 (diff)
downloadgdb-8d2755a953cfc95a09b19010aa47d9c998079acf.zip
gdb-8d2755a953cfc95a09b19010aa47d9c998079acf.tar.gz
gdb-8d2755a953cfc95a09b19010aa47d9c998079acf.tar.bz2
* c-lang.h, cp-valprint.c (static_field_print): Make non-static.
* parse.c, parser-defs.h (length_of_subexp): Make non-static. * jv-exp.y (FieldAccess): Handle dollar-VARIABLE as primary. (ArrayAccess): Likewise. Also remove warnings. (CastExpression): Implement (typename) UnaryExpression. (push_qualified_expression_name): Fix small bug. * jv-lang.c: Use TYPE_TAG_NAME, not TYPE_NAME for class names. (_initialize_jave_language): Fix typo (jave -> java). (java_language): Java does *not* have C-style arrays. (java_class_from_object): Make more general (and complicated). (java_link_class_type): Fix typo "super" -> "class". Handle arrays. (java_emit_char, java_printchar): New function. (evaluate_subexp_java case BINOP_SUBSCRIPT): Handle Java arrays. * jv-valprint.c (java_value_print): Implement printing of Java arrays. (java_print_value_fields): New function. (java_val_print): Better printing of TYPE_CODE_CHAR, TYPE_CODE_STRUCT.
Diffstat (limited to 'gdb/jv-exp.y')
-rw-r--r--gdb/jv-exp.y33
1 files changed, 28 insertions, 5 deletions
diff --git a/gdb/jv-exp.y b/gdb/jv-exp.y
index 22067a6..9e4c261 100644
--- a/gdb/jv-exp.y
+++ b/gdb/jv-exp.y
@@ -210,7 +210,7 @@ StringLiteral:
}
;
-Literal :
+Literal:
INTEGER_LITERAL
{ write_exp_elt_opcode (OP_LONG);
write_exp_elt_type ($1.type);
@@ -426,6 +426,8 @@ Dims_opt:
FieldAccess:
Primary '.' SimpleName
{ push_fieldnames ($3); }
+| VARIABLE '.' SimpleName
+ { push_fieldnames ($3); }
/*| SUPER '.' SimpleName { FIXME } */
;
@@ -442,10 +444,10 @@ ArrayAccess:
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:
@@ -503,7 +505,27 @@ CastExpression:
{ 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));
@@ -1277,6 +1299,7 @@ push_qualified_expression_name (name, dot_index)
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;