From 53bfc53e4de5204dc9877e96062e252b9848c03c Mon Sep 17 00:00:00 2001 From: bothner Date: Wed, 25 Nov 1998 17:10:57 +0000 Subject: [PATCH] * java-tree.h (end_params_node): Declare global. * decl.c (end_params_node): New global. (init_decl_processing, start_java_method): Use end_params_node for end of list of parameter types. Follows correct gcc conventions. * expr.c (pop_argument_types, pop_arguments): Likewise. * lang.c (put_decl_node): Likewise. * typeck.c (various places): Likewise. * class.y (various places): Likewise. * parse.y (various places): Likewise. * parse.y (java_complete_tree): Move CAN_COMPLETE_NORMALLY. (build_jump_to_finally): Add missing CAN_COMPLETE_NORMALLY. * class.c: Add #include flags.h, remove no-longer needed declaration. * class.c (layout_class_method): Remove commented-out code, re-format. Don't add vtable entry (or index) for private methods. * expr.c (expand_invoke): A private method is implicitly final. * class.c (make_class_data): If inlining or optimizing, skip private methods. * class.c (finish_class): New function. Calls existing methods, but alls emits deferred inline functions. * jcf-parse.c (parse_class_file): Call finish_class. * parse.y (java_complete_expand_methods): Likewise. * expr.c (build_java_binop): Explicit default, to silence -Wall. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@23871 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/java/java-tree.h | 2 ++ gcc/java/jcf-parse.c | 5 ++--- gcc/java/lang.c | 2 +- gcc/java/parse.y | 32 ++++++++++++++------------------ gcc/java/typeck.c | 6 +++--- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index 66aae18..6d6c254 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -249,6 +249,8 @@ extern tree method_type_node; extern tree method_ptr_type_node; #define nativecode_ptr_type_node ptr_type_node +extern tree end_params_node; + /* References to internal libjava functions we use. */ extern tree alloc_object_node; extern tree soft_instanceof_node; diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index c9f2ed7..75d5775 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -692,9 +692,8 @@ parse_class_file () if (flag_emit_class_files) write_classfile (current_class); - make_class_data (current_class); - register_class (); - rest_of_decl_compilation (TYPE_NAME (current_class), (char*) 0, 1, 0); + + finish_class (current_class); debug_end_source_file (save_lineno); input_filename = save_input_filename; diff --git a/gcc/java/lang.c b/gcc/java/lang.c index 4e646d2..50a1b67 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -371,7 +371,7 @@ put_decl_node (node) if (TREE_CODE (TREE_TYPE (node)) == METHOD_TYPE) args = TREE_CHAIN (args); put_decl_string ("(", 1); - for ( ; args != NULL_TREE; args = TREE_CHAIN (args), i++) + for ( ; args != end_params_node; args = TREE_CHAIN (args), i++) { if (i > 0) put_decl_string (",", 1); diff --git a/gcc/java/parse.y b/gcc/java/parse.y index be09d72..d99bc93 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -2925,7 +2925,7 @@ maybe_generate_finit () mdecl = create_artificial_method (TREE_TYPE (ctxp->current_parsed_class), ACC_PRIVATE|ACC_FINAL, void_type_node, - finit_identifier_node, NULL_TREE); + finit_identifier_node, end_params_node); start_artificial_method_body (mdecl); ctxp->non_static_initialized = nreverse (ctxp->non_static_initialized); @@ -2953,7 +2953,7 @@ maybe_generate_clinit () mdecl = create_artificial_method (TREE_TYPE (ctxp->current_parsed_class), ACC_STATIC, void_type_node, - clinit_identifier_node, NULL_TREE); + clinit_identifier_node, end_params_node); start_artificial_method_body (mdecl); /* Keep initialization in order to enforce 8.5 */ @@ -3179,7 +3179,7 @@ fix_method_argument_names (orig_arg, meth) TREE_PURPOSE (arg) = this_identifier_node; arg = TREE_CHAIN (arg); } - while (orig_arg) + while (orig_arg != end_params_node) { TREE_PURPOSE (arg) = TREE_PURPOSE (orig_arg); orig_arg = TREE_CHAIN (orig_arg); @@ -3370,7 +3370,7 @@ method_declarator (id, list) TREE_CHAIN (arg_node) = arg_types; arg_types = arg_node; } - TYPE_ARG_TYPES (meth) = nreverse (arg_types); + TYPE_ARG_TYPES (meth) = chainon (nreverse (arg_types), end_params_node); node = build_tree_list (id, meth); return node; } @@ -4340,7 +4340,7 @@ java_check_regular_methods (class_decl) flags = (get_access_flags_from_decl (class_decl) & ACC_PUBLIC ? ACC_PUBLIC : 0); decl = create_artificial_method (class, flags, void_type_node, - init_identifier_node, NULL_TREE); + init_identifier_node, end_params_node); DECL_CONSTRUCTOR_P (decl) = 1; layout_class_method (TREE_TYPE (class_decl), NULL_TREE, decl, NULL_TREE); } @@ -5031,7 +5031,7 @@ source_start_java_method (fndecl) /* New scope for the function */ enter_block (); for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0; - tem != NULL_TREE; tem = TREE_CHAIN (tem), i++) + tem != end_params_node; tem = TREE_CHAIN (tem), i++) { tree type = TREE_VALUE (tem); tree name = TREE_PURPOSE (tem); @@ -5341,12 +5341,7 @@ java_complete_expand_methods () /* Make the class data, register it and run the rest of decl compilation on it */ if (!java_error_count && ! flag_emit_class_files) - { - make_class_data (current_class); - register_class (); - rest_of_decl_compilation (TYPE_NAME (current_class), - (char*) 0, 1, 0); - } + finish_class (current_class); } } @@ -5514,7 +5509,7 @@ verify_constructor_super () for (mdecl = TYPE_METHODS (class); mdecl; mdecl = TREE_CHAIN (mdecl)) { if (DECL_CONSTRUCTOR_P (mdecl) - && !TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (mdecl)))) + && TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (mdecl))) == end_params_node) return 0; } } @@ -6588,7 +6583,7 @@ patch_invoke (patch, method, args, from_super) t = TYPE_ARG_TYPES (TREE_TYPE (method)); if (TREE_CODE (patch) == NEW_CLASS_EXPR) t = TREE_CHAIN (t); - for (ta = args; t && ta; t = TREE_CHAIN (t), ta = TREE_CHAIN (ta)) + for (ta = args; t != end_params_node && ta; t = TREE_CHAIN (t), ta = TREE_CHAIN (ta)) if (JPRIMITIVE_TYPE_P (TREE_TYPE (TREE_VALUE (ta))) && TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t)) TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta)); @@ -6698,7 +6693,7 @@ lookup_method_invoke (lc, cl, class, name, arg_list) tree cl; tree class, name, arg_list; { - tree atl = NULL_TREE; /* Arg Type List */ + tree atl = end_params_node; /* Arg Type List */ tree method, signature, list, node; char *candidates; /* Used for error report */ @@ -6899,7 +6894,7 @@ argument_types_convertible (m1, m2_or_arglist) m2_arg_cache = m2_arg; } - while (m1_arg && m2_arg) + while (m1_arg != end_params_node && m2_arg != end_params_node) { resolve_and_layout (TREE_VALUE (m1_arg), NULL_TREE); if (!valid_method_invocation_conversion_p (TREE_VALUE (m1_arg), @@ -6908,7 +6903,7 @@ argument_types_convertible (m1, m2_or_arglist) m1_arg = TREE_CHAIN (m1_arg); m2_arg = TREE_CHAIN (m2_arg); } - return (!m1_arg && !m2_arg ? 1 : 0); + return m1_arg == end_params_node && m2_arg == end_params_node; } /* Qualification routines */ @@ -7421,7 +7416,6 @@ java_complete_tree (node) case NEW_CLASS_EXPR: case CALL_EXPR: - CAN_COMPLETE_NORMALLY (node) = 1; /* Complete function's argument(s) first */ if (complete_function_arguments (node)) return error_mark_node; @@ -7441,6 +7435,7 @@ java_complete_tree (node) DECL_CONSTRUCTOR_CALLS (current_function_decl) = tree_cons (wfl, decl, DECL_CONSTRUCTOR_CALLS (current_function_decl)); + CAN_COMPLETE_NORMALLY (node) = 1; return node; } @@ -10015,6 +10010,7 @@ build_jump_to_finally (block, decl, finally_label, type) stmt = build (MODIFY_EXPR, void_type_node, decl, build_address_of (LABELED_BLOCK_LABEL (new_block))); TREE_SIDE_EFFECTS (stmt) = 1; + CAN_COMPLETE_NORMALLY (stmt) = 1; add_stmt_to_block (block, type, stmt); stmt = build (GOTO_EXPR, void_type_node, finally_label); TREE_SIDE_EFFECTS (stmt) = 1; diff --git a/gcc/java/typeck.c b/gcc/java/typeck.c index 154ba57..8af3a4f 100644 --- a/gcc/java/typeck.c +++ b/gcc/java/typeck.c @@ -467,8 +467,8 @@ parse_signature_string (sig_string, sig_length) if (str++, str >= limit) fatal ("bad signature string"); result_type = parse_signature_type (&str, limit); - result_type = build_function_type (result_type, - nreverse (argtype_list)); + argtype_list = chainon (nreverse (argtype_list), end_params_node); + result_type = build_function_type (result_type, argtype_list); } else result_type = parse_signature_type (&str, limit); @@ -513,7 +513,7 @@ build_java_argument_signature (type) tree args = TYPE_ARG_TYPES (type); if (TREE_CODE (type) == METHOD_TYPE) args = TREE_CHAIN (args); /* Skip "this" argument. */ - for (; args != NULL_TREE; args = TREE_CHAIN (args)) + for (; args != end_params_node; args = TREE_CHAIN (args)) { tree t = build_java_signature (TREE_VALUE (args)); obstack_grow (&temporary_obstack, -- 2.7.4