This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: 'assert' lowering cleanup
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 26 Mar 2005 19:54:49 -0700
- Subject: [gcjx] Patch: FYI: 'assert' lowering cleanup
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
This fixes a number of bugs in the code to lower 'assert' to trees.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* tree.cc (visit_assert): Yield empty statement if assertions not
desired. Create new AssertionError. Correctly handle case where
no second argument exists.
Index: tree.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/tree.cc,v
retrieving revision 1.1.2.31
diff -u -r1.1.2.31 tree.cc
--- tree.cc 27 Mar 2005 02:56:19 -0000 1.1.2.31
+++ tree.cc 27 Mar 2005 02:57:43 -0000
@@ -330,24 +330,45 @@
const ref_expression &second)
{
if (! global->get_compiler ()->target_assert ())
- return;
+ {
+ current = build_empty_stmt ();
+ return;
+ }
// Add assertion-related members.
ref_field disabled = method->get_declaring_class ()->add_assert_members ();
gcc_builtins->lay_out_class (disabled->get_declaring_class ());
- tree disabled_tree = gcc_builtins->map_field (disabled.get ());
+ tree disabled_tree = gcc_builtins->map_field_ref (class_wrapper,
+ NULL_TREE,
+ disabled.get ());
first->visit (this);
tree first_tree = current;
- second->visit (this);
- tree second_tree = current;
+
+ tree args = NULL_TREE;
+ model_type *arg_type = NULL;
+ if (second)
+ {
+ arg_type = second->type ();
+ second->visit (this);
+ args = build_tree_list (NULL_TREE, current);
+ }
+
+ model_class *errclass = global->get_compiler ()->java_lang_AssertionError ();
+ gcc_builtins->lay_out_class (errclass);
+
+ model_method *init = find_method ("<init>", errclass, arg_type,
+ primitive_void_type, element);
+ tree init_tree = gcc_builtins->map_method (init);
+
+ tree new_tree = gcc_builtins->map_new (class_wrapper, errclass,
+ init_tree, args);
// Generate:
// if (! $assertionsDisabled && ! FIRST) throw new AssertionError (SECOND)
tree throw_node = build3 (CALL_EXPR, void_type_node,
builtin_Jv_Throw,
- // fixme new ...
- tree_cons (NULL_TREE, second_tree, NULL_TREE),
+ build_tree_list (NULL_TREE, new_tree),
NULL_TREE);
current = build3 (COND_EXPR, void_type_node,
build2 (TRUTH_ANDIF_EXPR,