aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/except.c
diff options
context:
space:
mode:
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;
- }
-}