diff options
| author | Alexandre Petit-Bianco <apbianco@cygnus.com> | 1999-01-13 04:01:43 +0000 |
|---|---|---|
| committer | Alexandre Petit-Bianco <apbianco@gcc.gnu.org> | 1999-01-12 20:01:43 -0800 |
| commit | ba179f9f6f3c593721837c6c24cc39296a6eb92d (patch) | |
| tree | d25a9959214ac681892dce2608d8b8067d1a80bf /gcc/java/parse.y | |
| parent | 3c9a0f78d628f92d77ebb6455192174db7ab4907 (diff) | |
| download | gcc-ba179f9f6f3c593721837c6c24cc39296a6eb92d.zip gcc-ba179f9f6f3c593721837c6c24cc39296a6eb92d.tar.gz gcc-ba179f9f6f3c593721837c6c24cc39296a6eb92d.tar.bz2 | |
class.c (maybe_layout_super_class): Fixed returned value.
Wed Jan 13 01:24:54 1999 Alexandre Petit-Bianco <apbianco@cygnus.com>
* class.c (maybe_layout_super_class): Fixed returned value.
* lex.c: Added 1999 to the copyright.
(java_init_lex): Initialize java_lang_imported.
* lex.h: Added 1999 to the copyright.
* parse.h: Added 1999 to the copyright.
(REGISTER_IMPORT): Fixed typo in trailing macro.
(CURRENT_OSB): New macro.
(struct parser_ctxt): New fields osb_depth, osb_limit.
* parse.y (java_lang_id): New global variable.
(type_import_on_demand_declaration): Don't import java.lang.* twice.
(array_creation_expression:): Use CURRENT_OSB.
(dims:): Uses a stack to keep track of array dimensions.
(cast_expression:): Use CURRENT_OSB.
(find_expr_with_wfl): Return NULL if node found doesn't meet the
conditions.
(register_fields): Fixed typos in comment.
(check_method_redefinition): Fixed comment indentation.
(java_check_regular_methods): Set saved found wfl to NULL after
having reinstalled it in the previously found DECL_NAME.
Fix an array dimension counting bug and some random other ones.
From-SVN: r24648
Diffstat (limited to 'gcc/java/parse.y')
| -rw-r--r-- | gcc/java/parse.y | 69 |
1 files changed, 53 insertions, 16 deletions
diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 25722e0..03d04ee 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -281,6 +281,9 @@ static tree wfl_append = NULL_TREE; /* The "toString" identifier used for String `+' operator. */ static tree wfl_to_string = NULL_TREE; + +/* The "java.lang" import qualified name. */ +static tree java_lang_id = NULL_TREE; %} %union { @@ -591,10 +594,14 @@ type_import_on_demand_declaration: IMPORT_TK name DOT_TK MULT_TK SC_TK { tree name = EXPR_WFL_NODE ($2); - tree node = build_tree_list ($2, NULL_TREE); - read_import_dir ($2); - TREE_CHAIN (node) = ctxp->import_demand_list; - ctxp->import_demand_list = node; + /* Don't import java.lang.* twice. */ + if (name != java_lang_id) + { + tree node = build_tree_list ($2, NULL_TREE); + read_import_dir ($2); + TREE_CHAIN (node) = ctxp->import_demand_list; + ctxp->import_demand_list = node; + } } | IMPORT_TK name DOT_TK error {yyerror ("'*' expected"); RECOVER;} @@ -1760,9 +1767,9 @@ array_creation_expression: | NEW_TK class_or_interface_type dim_exprs { $$ = build_newarray_node ($2, $3, 0); } | NEW_TK primitive_type dim_exprs dims - { $$ = build_newarray_node ($2, $3, ctxp->osb_number); } + { $$ = build_newarray_node ($2, $3, CURRENT_OSB (ctxp));} | NEW_TK class_or_interface_type dim_exprs dims - { $$ = build_newarray_node ($2, $3, ctxp->osb_number); } + { $$ = build_newarray_node ($2, $3, CURRENT_OSB (ctxp));} /* Added, JDK1.1 anonymous array. Initial documentation rule modified */ | NEW_TK class_or_interface_type dims array_initializer @@ -1800,9 +1807,33 @@ dim_expr: dims: OSB_TK CSB_TK - { ctxp->osb_number = 1; } + { + int allocate = 0; + /* If not initialized, allocate memory for the osb + numbers stack */ + if (!ctxp->osb_limit) + { + allocate = ctxp->osb_limit = 32; + ctxp->osb_depth = -1; + } + /* If capacity overflown, reallocate a bigger chuck */ + else if (ctxp->osb_depth+1 == ctxp->osb_limit) + allocate = ctxp->osb_limit << 1; + + if (allocate) + { + allocate *= sizeof (int); + if (ctxp->osb_number) + ctxp->osb_number = (int *)xrealloc (ctxp->osb_number, + allocate); + else + ctxp->osb_number = (int *)xmalloc (allocate); + } + ctxp->osb_depth++; + CURRENT_OSB (ctxp) = 1; + } | dims OSB_TK CSB_TK - { ctxp->osb_number++; } + { CURRENT_OSB (ctxp)++; } | dims OSB_TK error { yyerror ("']' expected"); RECOVER;} ; @@ -1960,8 +1991,9 @@ cast_expression: /* Error handling here is potentially weak */ OP_TK primitive_type dims CP_TK unary_expression { tree type = $2; - while (ctxp->osb_number--) + while (CURRENT_OSB (ctxp)--) type = build_java_array_type (type, -1); + ctxp->osb_depth--; $$ = build_cast ($1.location, type, $5); } | OP_TK primitive_type CP_TK unary_expression @@ -1971,8 +2003,9 @@ cast_expression: /* Error handling here is potentially weak */ | OP_TK name dims CP_TK unary_expression_not_plus_minus { char *ptr; - while (ctxp->osb_number--) + while (CURRENT_OSB (ctxp)--) obstack_1grow (&temporary_obstack, '['); + ctxp->osb_depth--; obstack_grow0 (&temporary_obstack, IDENTIFIER_POINTER (EXPR_WFL_NODE ($2)), IDENTIFIER_LENGTH (EXPR_WFL_NODE ($2))); @@ -2513,6 +2546,7 @@ find_expr_with_wfl (node) if (((code == '1') || (code == '2') || (code == 'e')) && EXPR_WFL_LINECOL (node)) return node; + return NULL_TREE; } } return NULL_TREE; @@ -3130,9 +3164,9 @@ register_fields (flags, type, variable_list) { /* We include the field and its initialization part into a list used to generate <clinit>. After <clinit> is - walked, fields initialization will be processed and - fields initialized with know constants will be taken - out of <clinit> and have ther DECL_INITIAL set + walked, field initializations will be processed and + fields initialized with known constants will be taken + out of <clinit> and have their DECL_INITIAL set appropriately. */ TREE_CHAIN (init) = ctxp->static_initialized; ctxp->static_initialized = init; @@ -4395,8 +4429,8 @@ check_method_redefinition (class, method) tree redef, name; tree cl = DECL_NAME (method); tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method)); - /* decl name of artificial <clinit> and $finit$ doesn't need to be fixed and - checked */ + /* decl name of artificial <clinit> and $finit$ doesn't need to be + fixed and checked */ /* Reset the method name before running the check. If it returns 1, the method doesn't need to be verified with respect to method @@ -4454,7 +4488,10 @@ java_check_regular_methods (class_decl) /* If we previously found something and its name was saved, reinstall it now */ if (found && saved_found_wfl) - DECL_NAME (found) = saved_found_wfl; + { + DECL_NAME (found) = saved_found_wfl; + saved_found_wfl = NULL_TREE; + } /* Check for redefinitions */ if (check_method_redefinition (class, method)) |
