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.c72
1 files changed, 50 insertions, 22 deletions
diff --git a/gcc/java/except.c b/gcc/java/except.c
index cbfeb0a8cc2..8fbf0b60e06 100644
--- a/gcc/java/except.c
+++ b/gcc/java/except.c
@@ -1,5 +1,5 @@
/* Handle exceptions for GNU compiler for the Java(TM) language.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -36,6 +36,9 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
#include "eh-common.h"
#include "toplev.h"
+static void expand_start_java_handler PROTO ((struct eh_range *));
+static void expand_end_java_handler PROTO ((struct eh_range *));
+
extern struct obstack permanent_obstack;
struct eh_range *current_method_handlers;
@@ -161,6 +164,12 @@ method_init_exceptions ()
whole_range.first_child = NULL;
whole_range.next_sibling = NULL;
cache_range_start = 0xFFFFFF;
+ java_set_exception_lang_code ();
+}
+
+void
+java_set_exception_lang_code ()
+{
set_exception_lang_code (EH_LANG_Java);
set_exception_version_code (1);
}
@@ -176,16 +185,42 @@ add_handler (start_pc, end_pc, handler, type)
/* if there are any handlers for this range, issue start of region */
-void
+static void
expand_start_java_handler (range)
- struct eh_range *range;
+ struct eh_range *range ATTRIBUTE_UNUSED;
{
expand_eh_region_start ();
}
+tree
+prepare_eh_table_type (type)
+ tree type;
+{
+ tree exp;
+
+ /* The "type" (metch_info) in a (Java) exception table is one:
+ * a) NULL - meaning match any type in a try-finally.
+ * b) a pointer to a (ccmpiled) class (low-order bit 0).
+ * c) a pointer to the Utf8Const name of the class, plus one
+ * (which yields a value with low-order bit 1). */
+
+ push_obstacks (&permanent_obstack, &permanent_obstack);
+ if (type == NULL_TREE)
+ exp = null_pointer_node;
+ else if (is_compiled_class (type))
+ exp = build_class_ref (type);
+ else
+ exp = fold (build
+ (PLUS_EXPR, ptr_type_node,
+ build_utf8_ref (build_internal_class_name (type)),
+ size_one_node));
+ pop_obstacks ();
+ return exp;
+}
+
/* if there are any handlers for this range, isssue end of range,
and then all handler blocks */
-void
+static void
expand_end_java_handler (range)
struct eh_range *range;
{
@@ -193,24 +228,8 @@ expand_end_java_handler (range)
expand_start_all_catch ();
for ( ; handler != NULL_TREE; handler = TREE_CHAIN (handler))
{
- tree type = TREE_PURPOSE (handler);
- tree exp;
- /* The "type" (metch_info) in a (Java) exception table is one:
- * a) NULL - meaning match any type in a try-finally.
- * b) a pointer to a (ccmpiled) class (low-order bit 0).
- * c) a pointer to the Utf8Const name of the class, plus one
- * (which yields a value with low-order bit 1). */
- push_obstacks (&permanent_obstack, &permanent_obstack);
- if (type == NULL_TREE)
- exp = null_pointer_node;
- else if (is_compiled_class (type))
- exp = build_class_ref (type);
- else
- exp = fold (build (PLUS_EXPR, ptr_type_node,
- build_utf8_ref (build_internal_class_name (type)),
- size_one_node));
- pop_obstacks ();
- start_catch_handler (exp);
+ start_catch_handler (prepare_eh_table_type (TREE_PURPOSE (handler)));
+ /* Push the thrown object on the top of the stack */
expand_goto (TREE_VALUE (handler));
}
expand_end_all_catch ();
@@ -277,3 +296,12 @@ emit_handlers ()
emit_label (funcend);
}
}
+
+/* Resume executing at the statement immediately after the end of an
+ exception region. */
+
+void
+expand_resume_after_catch ()
+{
+ expand_goto (top_label_entry (&caught_return_label_stack));
+}