diff options
author | Alexandre Petit-Bianco <apbianco@gcc.gnu.org> | 2000-03-13 21:01:05 -0800 |
---|---|---|
committer | Alexandre Petit-Bianco <apbianco@gcc.gnu.org> | 2000-03-13 21:01:05 -0800 |
commit | c2952b018a1baf25b12c339f2b96518425164295 (patch) | |
tree | bf1619873e76c17441a1423f1eaba6a4a64f054a /gcc/java/jcf-parse.c | |
parent | e4476d1cbd567593c068dba421b5e089f7ccbcd5 (diff) | |
download | gcc-c2952b018a1baf25b12c339f2b96518425164295.zip gcc-c2952b018a1baf25b12c339f2b96518425164295.tar.gz gcc-c2952b018a1baf25b12c339f2b96518425164295.tar.bz2 |
Added Java 1.1 language features.
From-SVN: r32517
Diffstat (limited to 'gcc/java/jcf-parse.c')
-rw-r--r-- | gcc/java/jcf-parse.c | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index 770cec6..09991eb 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -185,6 +185,32 @@ set_source_filename (jcf, index) DECL_FUNCTION_THROWS (current_method) = nreverse (list); \ } +/* Link seen inner classes to their outer context and register the + inner class to its outer context. They will be later loaded. */ +#define HANDLE_INNERCLASSES_ATTRIBUTE(COUNT) \ +{ \ + int c = (count); \ + while (c--) \ + { \ + tree class = get_class_constant (jcf, JCF_readu2 (jcf)); \ + if (!CLASS_COMPLETE_P (class)) \ + { \ + tree outer = TYPE_NAME (get_class_constant (jcf, \ + JCF_readu2 (jcf))); \ + tree alias = get_name_constant (jcf, JCF_readu2 (jcf)); \ + tree decl = TYPE_NAME (class); \ + JCF_SKIP (jcf, 2); \ + IDENTIFIER_GLOBAL_VALUE (alias) = decl; \ + DECL_CONTEXT (decl) = outer; \ + DECL_INNER_CLASS_LIST (outer) = \ + tree_cons (decl, alias, DECL_INNER_CLASS_LIST (outer)); \ + CLASS_COMPLETE_P (class) = 1; \ + } \ + else \ + JCF_SKIP (jcf, 6); \ + } \ +} + #include "jcf-reader.c" static int yydebug; @@ -565,6 +591,7 @@ jcf_parse (jcf) JCF* jcf; { int i, code; + tree current; if (jcf_parse_preamble (jcf) != 0) fatal ("Not a valid Java .class file.\n"); @@ -617,23 +644,21 @@ jcf_parse (jcf) else all_class_list = tree_cons (NULL_TREE, TYPE_NAME (current_class), all_class_list ); + + /* And if we came accross inner classes, load them now. */ + for (current = DECL_INNER_CLASS_LIST (TYPE_NAME (current_class)); current; + current = TREE_CHAIN (current)) + load_class (DECL_NAME (TREE_PURPOSE (current)), 1); + pop_obstacks (); } void init_outgoing_cpool () { - current_constant_pool_data_ref = NULL_TREE; - if (outgoing_cpool == NULL) - { - static CPool outgoing_cpool_buffer; - outgoing_cpool = &outgoing_cpool_buffer; - CPOOL_INIT(outgoing_cpool); - } - else - { - CPOOL_REINIT(outgoing_cpool); - } + current_constant_pool_data_ref = NULL_TREE; + outgoing_cpool = (struct CPool *)xmalloc (sizeof (struct CPool)); + bzero (outgoing_cpool, sizeof (struct CPool)); } static void @@ -737,6 +762,7 @@ parse_source_file (file) java_parse_abort_on_error (); java_fix_constructors (); /* Fix the constructors */ java_parse_abort_on_error (); + java_reorder_fields (); /* Reorder the fields */ } static int @@ -893,7 +919,7 @@ parse_zip_file_entries (void) continue; class = lookup_class (get_identifier (ZIPDIR_FILENAME (zdir))); - current_jcf = TYPE_LANG_SPECIFIC (class)->jcf; + current_jcf = TYPE_JCF (class); current_class = class; if ( !CLASS_LOADED_P (class)) @@ -970,9 +996,7 @@ static void process_zip_dir() jcf->classname = class_name; jcf->filename = file_name; - TYPE_LANG_SPECIFIC (class) = - (struct lang_type *) perm_calloc (1, sizeof (struct lang_type)); - TYPE_LANG_SPECIFIC (class)->jcf = jcf; + TYPE_JCF (class) = jcf; } } @@ -994,10 +1018,10 @@ DEFUN(find_in_current_zip, (name, length, jcf), class = TREE_TYPE (icv); /* Doesn't have jcf specific info ? It's not ours */ - if (!TYPE_LANG_SPECIFIC (class) || !TYPE_LANG_SPECIFIC (class)->jcf) + if (!TYPE_JCF (class)) return 0; - *jcf = local_jcf = TYPE_LANG_SPECIFIC (class)->jcf; + *jcf = local_jcf = TYPE_JCF (class); fseek (local_jcf->read_state, local_jcf->zip_offset, SEEK_SET); return 1; } |