diff options
author | Per Bothner <per@bothner.com> | 2004-03-19 15:10:55 -0800 |
---|---|---|
committer | Per Bothner <bothner@gcc.gnu.org> | 2004-03-19 15:10:55 -0800 |
commit | 24d82bce7ab29c1616b961d79f676bb08d339719 (patch) | |
tree | 33b8d368112dad1721fb1c8b1717ab2dd33584f3 /gcc/java/parse.y | |
parent | 73c4ab99de2a48eb748c61ddcce1adef752eb702 (diff) | |
download | gcc-24d82bce7ab29c1616b961d79f676bb08d339719.zip gcc-24d82bce7ab29c1616b961d79f676bb08d339719.tar.gz gcc-24d82bce7ab29c1616b961d79f676bb08d339719.tar.bz2 |
class.c (assume_compiled_node_struct): Rename type to class_flag_node_struct, as it is now also used for enable_assertions.
* class.c (assume_compiled_node_struct): Rename type to
class_flag_node_struct, as it is now also used for enable_assertions.
Rename assume_compiled_node typedef. Rename excludep field to value.
(find_assume_compiled_node): Rename function to find_class_flag_node.
Minor optimization - avoid needless strlen.
(add_assume_compiled): Some tweaking and optimization.
Rename and generalize to add_class_flag takem an extra parameter.
(add_assume_compled): New just calls add_class_flag.
(add_enable_assert, enable_assertions): New functions.
(enable_assert_tree): New static.
* java-tree.h (add_enable_assert, enable_assertions): New declarations.
* lang.opt (fenable-assertions, fenable-assertions=,
fdisable-assertions, fdisable-assertions=): New options.
* lang.c (java_handle_option): Handle new options.
* parse.y (build_incomplete_class_ref): Handle class$ in an inner
class in an interface - create helper class nested in outer interface.
(build_assertion): Short-circuit if enable_assertions is false.
From-SVN: r79710
Diffstat (limited to 'gcc/java/parse.y')
-rw-r--r-- | gcc/java/parse.y | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 049e50b..a21fc2a 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -13992,25 +13992,32 @@ build_incomplete_class_ref (int location, tree class_name) && !JPRIMITIVE_TYPE_P (class_name) && !(TREE_CODE (class_name) == VOID_TYPE)) { + tree cpc_list = GET_CPC_LIST(); + tree cpc = cpc_list; tree target_class; - if (CLASS_INTERFACE (TYPE_NAME (this_class))) + /* For inner classes, add a 'class$' method to their outermost + context, creating it if necessary. */ + + while (GET_NEXT_ENCLOSING_CPC(cpc)) + cpc = GET_NEXT_ENCLOSING_CPC(cpc); + class_decl = TREE_VALUE (cpc); + + target_class = TREE_TYPE (class_decl); + + if (CLASS_INTERFACE (TYPE_NAME (target_class))) { /* For interfaces, adding a static 'class$' method directly is illegal. So create an inner class to contain the new method. Empirically this matches the behavior of javac. */ - tree t = build_wfl_node (DECL_NAME (TYPE_NAME (object_type_node))); - tree inner = create_anonymous_class (0, t); + tree t, inner; + /* We want the generated inner class inside the outermost class. */ + GET_CPC_LIST() = cpc; + t = build_wfl_node (DECL_NAME (TYPE_NAME (object_type_node))); + inner = create_anonymous_class (0, t); target_class = TREE_TYPE (inner); end_class_declaration (1); - } - else - { - /* For inner classes, add a 'class$' method to their outermost - context, creating it if necessary. */ - while (INNER_CLASS_DECL_P (class_decl)) - class_decl = DECL_CONTEXT (class_decl); - target_class = TREE_TYPE (class_decl); + GET_CPC_LIST() = cpc_list; } if (TYPE_DOT_CLASS (target_class) == NULL_TREE) @@ -15299,6 +15306,16 @@ build_assertion (int location, tree condition, tree value) tree node; tree klass = GET_CPC (); + if (! enable_assertions (klass)) + { + condition = build (TRUTH_ANDIF_EXPR, NULL_TREE, + boolean_false_node, condition); + if (value == NULL_TREE) + value = empty_stmt_node; + return build_if_else_statement (location, condition, + value, NULL_TREE); + } + if (! CLASS_USES_ASSERTIONS (klass)) { tree field, classdollar, id, call; |