This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: wrap LABEL_DECLs
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 12 Feb 2005 20:51:51 -0700
- Subject: [gcjx] Patch: FYI: wrap LABEL_DECLs
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
You have to wrap a LABEL_DECL in a LABEL_EXPR in order to use it as a
statement. I don't really get the rationale for this, but I comply.
I forgot to address the bytecode-lowering part of this problem. The
bytecode lowering code hasn't really gotten much attention yet. In
case it isn't obvious all of the tree-lowering code is alpha quality,
I basically wrote it all out and now I'm fixing bugs piecemeal.
Tom
#
# patch "gcc/gcc/java/ChangeLog"
# from [58e071fa98227b7f3d0ab3d00f4164858575f025]
# to [35289bee2f06c4edb8cf706f38989eda28165595]
#
# patch "gcc/gcc/java/tree.cc"
# from [b845207e88959825c85c52cff2bba67992049336]
# to [37e70463907e099df2c599ac8228aa5ba5ef1fae]
#
--- gcc/gcc/java/ChangeLog
+++ gcc/gcc/java/ChangeLog
@@ -1,5 +1,14 @@
2005-02-08 Tom Tromey <tromey@redhat.com>
+ * tree.cc (visit_for): Use LABEL_EXPRs as statements. Set
+ DECL_CONTEXT on labels.
+ (visit_do): Set DECL_CONTEXT on labels.
+ (visit_for_enhanced): Likewise.
+ (visit_for): Likewise.
+ (visit_label): Likewise.
+ (visit_switch_block): Likewise.
+ (visit_while): Likewise.
+
* tree.cc (build_array_reference): Correctly handle array's type.
* builtins.cc (map_type): Don't set TYPE_NAME for array types.
(lay_out_class): Correctly set type of "data" field of array
--- gcc/gcc/java/tree.cc
+++ gcc/gcc/java/tree.cc
@@ -461,7 +461,9 @@
{
// Some labels which we'll use later.
tree test = build0 (LABEL_DECL, NULL_TREE);
+ DECL_CONTEXT (test) = current_block;
tree done = build0 (LABEL_DECL, NULL_TREE);
+ DECL_CONTEXT (done) = current_block;
target_map[dstmt] = std::make_pair (test, done);
// Generate code for the expression and the body.
@@ -518,7 +520,9 @@
const ref_variable_decl &var)
{
tree update_tree = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+ DECL_CONTEXT (update_tree) = current_block;
tree done_tree = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+ DECL_CONTEXT (done_tree) = current_block;
target_map[fstmt] = std::make_pair (update_tree, done_tree);
tree body_tree = alloc_stmt_list ();
@@ -544,7 +548,9 @@
const ref_stmt &update)
{
tree update_tree = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+ DECL_CONTEXT (update_tree) = current_block;
tree done_tree = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+ DECL_CONTEXT (done_tree) = current_block;
target_map[fstmt] = std::make_pair (update_tree, done_tree);
save_tree saver (current_block, make_node (BLOCK));
@@ -570,14 +576,16 @@
body->visit (this);
tsi_link_after (&out, current, TSI_CONTINUE_LINKING);
- tsi_link_after (&out, update_tree, TSI_CONTINUE_LINKING);
+ tsi_link_after (&out, build1 (LABEL_EXPR, void_type_node, update_tree),
+ TSI_CONTINUE_LINKING);
if (update)
{
update->visit (this);
tsi_link_after (&out, current, TSI_CONTINUE_LINKING);
}
- tsi_link_after (&out, done_tree, TSI_CONTINUE_LINKING);
+ tsi_link_after (&out, build1 (LABEL_EXPR, void_type_node, done_tree),
+ TSI_CONTINUE_LINKING);
current = build3 (BIND_EXPR, void_type_node,
BLOCK_VARS (current_block),
@@ -613,6 +621,7 @@
if (label->get_break_target () == NULL)
{
tree brk = build0 (LABEL_DECL, NULL_TREE);
+ DECL_CONTEXT (brk) = current_block;
target_map[label] = std::make_pair (NULL_TREE, brk);
tree body_tree = alloc_stmt_list ();
@@ -689,6 +698,7 @@
tree_stmt_iterator out = tsi_start (body_tree);
tree label = build0 (LABEL_DECL, NULL_TREE);
+ DECL_CONTEXT (label) = current_block;
std::list<ref_expression> labels = swblock->get_labels ();
for (std::list<ref_expression>::const_iterator i = labels.begin ();
@@ -836,7 +846,9 @@
const ref_stmt &body)
{
tree again = build0 (LABEL_DECL, NULL_TREE);
+ DECL_CONTEXT (again) = current_block;
tree done = build0 (LABEL_DECL, NULL_TREE);
+ DECL_CONTEXT (done) = current_block;
target_map[wstmt] = std::make_pair (again, done);
// Create the body of the loop: first the 'again' label, then the