aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/except.c
diff options
context:
space:
mode:
authorAndrew Haley <aph@redhat.com>2004-06-29 16:18:46 +0000
committerAndrew Haley <aph@gcc.gnu.org>2004-06-29 16:18:46 +0000
commitba60e4754adc4181784207396de5abbd349d894f (patch)
tree406cc493b14a7dbe0721aae139686fc7c954a0cc /gcc/java/except.c
parent9f6eb0f4dbc2b394976b52d72f57ea33e1ef6ddf (diff)
downloadgcc-ba60e4754adc4181784207396de5abbd349d894f.zip
gcc-ba60e4754adc4181784207396de5abbd349d894f.tar.gz
gcc-ba60e4754adc4181784207396de5abbd349d894f.tar.bz2
except.c (expand_start_java_handler): Push a new binding level.
2004-06-29 Andrew Haley <aph@redhat.com> * except.c (expand_start_java_handler): Push a new binding level. Don't build a TRY_CATCH_EXPR now, we'll do it later. Call register_exception_range() to register where we'll do it. (expand_end_java_handler): Remove old bogus code. Replace with new logic that simply builds TRY_CATCH_EXPRs and inserts them at the top of the expression we're curently building. (maybe_end_try): Delete. * decl.c (binding_level.exception_range): New field. (clear_binding_level): Add field exception_range. Reformat. (poplevel): Call expand_end_java_handler(). (poplevel): Call java_add_stmt only if functionbody is false. (maybe_poplevels): Don't call maybe_end_try() from here. (end_java_method): Clear no longer used trees in function decl. (register_exception_range): New function. * java-tree.h (register_exception_range, struct eh_range): Declare. From-SVN: r83857
Diffstat (limited to 'gcc/java/except.c')
-rw-r--r--gcc/java/except.c83
1 files changed, 11 insertions, 72 deletions
diff --git a/gcc/java/except.c b/gcc/java/except.c
index b77842e..91f741f 100644
--- a/gcc/java/except.c
+++ b/gcc/java/except.c
@@ -40,7 +40,6 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
#include "toplev.h"
static void expand_start_java_handler (struct eh_range *);
-static void expand_end_java_handler (struct eh_range *);
static struct eh_range *find_handler_in_range (int, struct eh_range *,
struct eh_range *);
static void link_handler (struct eh_range *, struct eh_range *);
@@ -305,13 +304,8 @@ expand_start_java_handler (struct eh_range *range)
fprintf (stderr, "expand start handler pc %d --> %d\n",
current_pc, range->end_pc);
#endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */
- {
- tree new = build (TRY_CATCH_EXPR, void_type_node, NULL, NULL);
- TREE_SIDE_EFFECTS (new) = 1;
- java_add_stmt (build_java_empty_stmt ());
- range->stmt = java_add_stmt (new);
- }
-
+ pushlevel (0);
+ register_exception_range (range, range->start_pc, range->end_pc);
range->expanded = 1;
}
@@ -428,13 +422,11 @@ build_exception_object_ref (tree type)
/* If there are any handlers for this range, isssue end of range,
and then all handler blocks */
-static void
+void
expand_end_java_handler (struct eh_range *range)
{
tree handler = range->handlers;
- tree compound = NULL;
- force_poplevels (range->start_pc);
for ( ; handler != NULL_TREE; handler = TREE_CHAIN (handler))
{
/* For bytecode we treat exceptions a little unusually. A
@@ -444,55 +436,18 @@ expand_end_java_handler (struct eh_range *range)
extra (and difficult) work to get this to look like a
gcc-style finally clause. */
tree type = TREE_PURPOSE (handler);
-
if (type == NULL)
type = throwable_type_node;
-
type = prepare_eh_table_type (type);
- if (compound)
- {
- /* If we already have a COMPOUND there is more than one
- catch handler for this try block. Wrap the
- TRY_CATCH_EXPR in operand 1 of COMPOUND with another
- TRY_CATCH_EXPR. */
- tree inner_try_expr = TREE_OPERAND (compound, 1);
- tree catch_expr
- = build (CATCH_EXPR, void_type_node, type,
- build (GOTO_EXPR, void_type_node, TREE_VALUE (handler)));
- tree try_expr
- = build (TRY_CATCH_EXPR, void_type_node,
- inner_try_expr, catch_expr);
- TREE_OPERAND (compound, 1) = try_expr;
- }
- else
- {
- tree *stmts = get_stmts ();
- tree outer;
- tree try_expr;
- compound = range->stmt;
- outer = TREE_OPERAND (compound, 0);
- try_expr = TREE_OPERAND (compound, 1);
- /* On the left of COMPOUND is the expresion to be evaluated
- before the try handler is entered; on the right is a
- TRY_FINALLY_EXPR with no operands as yet. In the current
- statement list is an expression that we're going to move
- inside the try handler. We'll create a new COMPOUND_EXPR
- with the outer context on the left and the TRY_FINALLY_EXPR
- on the right, then nullify both operands of COMPOUND, which
- becomes the final expression in OUTER. This new compound
- expression replaces the current statement list. */
- TREE_OPERAND (try_expr, 0) = *stmts;
- TREE_OPERAND (try_expr, 1)
- = build (CATCH_EXPR, void_type_node, type,
- build (GOTO_EXPR, void_type_node, TREE_VALUE (handler)));
- TREE_SIDE_EFFECTS (try_expr) = 1;
- TREE_OPERAND (compound, 0) = build_java_empty_stmt ();
- TREE_OPERAND (compound, 1) = build_java_empty_stmt ();
- compound
- = build (COMPOUND_EXPR, TREE_TYPE (try_expr), outer, try_expr);
- *stmts = compound;
- }
+ {
+ tree catch_expr
+ = build (CATCH_EXPR, void_type_node, type,
+ build (GOTO_EXPR, void_type_node, TREE_VALUE (handler)));
+ tree try_catch_expr = build (TRY_CATCH_EXPR, void_type_node,
+ *get_stmts (), catch_expr);
+ *get_stmts () = try_catch_expr;
+ }
}
#if defined(DEBUG_JAVA_BINDING_LEVELS)
indent ();
@@ -536,19 +491,3 @@ maybe_start_try (int start_pc, int end_pc)
check_start_handlers (range, start_pc);
}
-/* Emit any end-of-try-range ending at end_pc and starting before
- start_pc. */
-
-void
-maybe_end_try (int start_pc, int end_pc)
-{
- if (! doing_eh (1))
- return;
-
- while (current_range != NULL_EH_RANGE && current_range->end_pc <= end_pc
- && current_range->start_pc >= start_pc)
- {
- expand_end_java_handler (current_range);
- current_range = current_range->outer;
- }
-}