summaryrefslogtreecommitdiff
path: root/gcc/java/jcf-parse.c
diff options
context:
space:
mode:
authorAlexandre Petit-Bianco <apbianco@gcc.gnu.org>1998-11-24 09:57:41 -0800
committerAlexandre Petit-Bianco <apbianco@gcc.gnu.org>1998-11-24 09:57:41 -0800
commit23a79c61921246f3d84df2503555208f2683203e (patch)
treeddfaaed8a863a8721201f3dd3d76d282cc58791c /gcc/java/jcf-parse.c
parent333a9f0aafc0d0e426d948e545daae6f6d277f19 (diff)
downloadgcc-23a79c61921246f3d84df2503555208f2683203e.tar.gz
[multiple changes]
Tue Nov 24 17:06:38 1998 Per Bothner <bothner@cygnus.com> * (generate_classfile): Always write class access flag with ACC_SUPER set. Tue Nov 24 16:34:33 1998 Alexandre Petit-Bianco <apbianco@cygnus.com> * class.c (maybe_layout_super_class): New function. (layout_class): Reorganized. Loop on class methods dispatched into a new function. Call maybe_layout_super_class. (layout_class_methods, layout_class_method): New functions. * expr.c (expand_java_NEW): Call layout_class_methods on loaded class. (expand_invoke): Likewise. * java-tree.h (all_class_list): New global variable declared. (layout_class_methods, layout_class_method): New function prototypes. (LAYOUT_SEEN_CLASS_METHODS): New macro. * jcf-parse.c (all_class_list): New global variable. (load_class): Extended what class_or_name can be. Use parser context mechanism to save globals before calling jcf_parse. (jcf_parse_source): Don't parse twice if HAS_BEEN_ALREADY_PARSED_P is set on the file name. (jcf_parse): Layout class methods when Object is loaded, otherwise record class in all_class_list for delayed method layout. (parse_class_file): Use LAYOUT_SEEN_CLASS_METHODS. * lang.c (put_decl_node): Decode <init> into the decl context class name. * lex.c (java_allocate_new_line): Use xmalloc. * parse.h (INCOMPLETE_TYPE_P): Redefined to work with incomplete pointers, not TREE_LIST elements. (struct parser_ctxt): Fixed comment indentations, added comments and reordered some fields. (java_check_methods): Function prototype removed. * parse.y (java_push_parser_context): Use xmalloc. (java_parser_context_restore_global): Pop extra pushed ctxp only when there's nothing next. (maybe_create_class_interface_decl): Fixed comment, add new created class decl to all_class_list. (method_header): Use GET_REAL_TYPE on argument's types. (method_declarator): Use GET_REAL_TYPE, change type to the real type in TREE_LIST dependency node. Build argument list with the real type. (create_jdep_list): Use xmalloc. Removed allocation error message. (obtain_incomplete_type): Fixed leading comment. Broadened incoming argument meaning. (register_incomplete_type): Use xmalloc. Removed allocation error message. (safe_layout_class): Fixed leading comment. (jdep_resolve_class): Reversed if statement condition and switch if and else bodies. (resolve_and_layout): Fixed leading comment. Broadened incoming argument meaning. (complete_class_report_errors): New local variable name, for clarity. purify_type_name used for all error cases. (java_get_real_method_name): Stricter check on constructors. (java_check_regular_methods): Reverse methods list only if not already laid out. Layout artificial constructor. (java_check_methods): Deleted. (source_start_java_method): Obtain incomplete type for patchable method arguments. (java_layout_classes): Fixed leading comment. Use LAYOUT_SEEN_CLASS_METHODS, use a loop to check methods. Added else statement to layout operation, reuse LAYOUT_SEEN_CLASS_METHODS before returning. Fixed comments. (java_expand_classes): Check for errors up front. (patch_method_invocation): Class to search is resolved and laid out. A step forward truly mixing .class and .java during package compilation. Includes a Per's patch. From-SVN: r23834
Diffstat (limited to 'gcc/java/jcf-parse.c')
-rw-r--r--gcc/java/jcf-parse.c49
1 files changed, 37 insertions, 12 deletions
diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c
index 8a01b2cb925..c9f2ed7f5aa 100644
--- a/gcc/java/jcf-parse.c
+++ b/gcc/java/jcf-parse.c
@@ -61,7 +61,10 @@ tree current_class = NULL_TREE;
/* The class we started with. */
tree main_class = NULL_TREE;
-/* The FIELD_DECL for the current field. */
+/* List of all class DECL seen so far. */
+tree all_class_list = NULL_TREE;
+
+/* The FIELD_DECL for the current field. */
static tree current_field = NULL_TREE;
/* The METHOD_DECL for the current method. */
@@ -450,8 +453,7 @@ load_class (class_or_name, verbose)
int verbose;
{
JCF this_jcf, *jcf;
- tree name = (TREE_CODE (class_or_name) == IDENTIFIER_NODE ?
- class_or_name : DECL_NAME (TYPE_NAME (class_or_name)));
+ tree name;
tree save_current_class = current_class;
char *save_input_filename = input_filename;
JCF *save_current_jcf = current_jcf;
@@ -459,6 +461,17 @@ load_class (class_or_name, verbose)
if (current_jcf->read_state)
saved_pos = ftell (current_jcf->read_state);
+ /* class_or_name can be the name of the class we want to load */
+ if (TREE_CODE (class_or_name) == IDENTIFIER_NODE)
+ name = class_or_name;
+ /* In some cases, it's a dependency that we process earlier that
+ we though */
+ else if (TREE_CODE (class_or_name) == TREE_LIST)
+ name = TYPE_NAME (TREE_PURPOSE (class_or_name));
+ /* Or it's a type in the making */
+ else
+ name = DECL_NAME (TYPE_NAME (class_or_name));
+
push_obstacks (&permanent_obstack, &permanent_obstack);
/* Search in current zip first. */
@@ -494,10 +507,12 @@ load_class (class_or_name, verbose)
if (current_jcf->java_source)
jcf_parse_source (current_jcf);
else {
- int saved_lineno = lineno;
+ java_parser_context_save_global ();
+ java_push_parser_context ();
input_filename = current_jcf->filename;
jcf_parse (current_jcf);
- lineno = saved_lineno;
+ java_pop_parser_context (0);
+ java_parser_context_restore_global ();
}
if (!current_jcf->seen_in_zip)
@@ -524,13 +539,16 @@ jcf_parse_source (jcf)
java_push_parser_context ();
input_filename = current_jcf->filename;
file = get_identifier (input_filename);
- if (!(finput = fopen (input_filename, "r")))
- fatal ("input file `%s' just disappeared - jcf_parse_source",
- input_filename);
- parse_source_file (file);
- if (fclose (finput))
- fatal ("can't close input file `%s' stream - jcf_parse_source",
- input_filename);
+ if (!HAS_BEEN_ALREADY_PARSED_P (file))
+ {
+ if (!(finput = fopen (input_filename, "r")))
+ fatal ("input file `%s' just disappeared - jcf_parse_source",
+ input_filename);
+ parse_source_file (file);
+ if (fclose (finput))
+ fatal ("can't close input file `%s' stream - jcf_parse_source",
+ input_filename);
+ }
java_pop_parser_context (IS_A_COMMAND_LINE_FILENAME_P (file));
java_parser_context_restore_global ();
}
@@ -586,6 +604,11 @@ jcf_parse (jcf)
push_obstacks (&permanent_obstack, &permanent_obstack);
layout_class (current_class);
+ if (current_class == object_type_node)
+ layout_class_methods (object_type_node);
+ else
+ all_class_list = tree_cons (NULL_TREE,
+ TYPE_NAME (current_class), all_class_list );
pop_obstacks ();
}
@@ -612,6 +635,8 @@ parse_class_file ()
char *save_input_filename = input_filename;
int save_lineno = lineno;
+ LAYOUT_SEEN_CLASS_METHODS ();
+
input_filename = DECL_SOURCE_FILE (TYPE_NAME (current_class));
lineno = 0;
debug_start_source_file (input_filename);