+2010-05-26 Nathan Froyd <froydnj@codesourcery.com>
+
+ * class.c (utf8_decl_list): Delete.
+ (build_utf8_ref): Remove references to it.
+ * java-tree.h (all_class_list): Delete.
+ (predef_filenames): Delete.
+ (enum java_tree_index) [JTI ALL_CLASS_LIST,JTI_PREDEF_FILENAMES]:
+ Delete.
+ * jcf-parse.c (parse_roots): Decrease size to 2.
+ (current_file_list): Convert to a VEC.
+ (all_class_list): Declare.
+ (jcf_parse): Adjust for new type of all_class_list.
+ (java_layout_seen_class_methods): Likewise.
+ (predefined_filenames): Declare.
+ (add_predefined_file): Use it.
+ (predefined_filename_p): Likewise.
+ (java_parse_file): Adjust for new type of current_file_list. *
+
2010-05-25 Jakub Jelinek <jakub@redhat.com>
* lang.c (java_classify_record): Return RECORD_IS_INTERFACE
extern struct obstack temporary_obstack;
-static GTY(()) tree parse_roots[3];
+static GTY(()) tree parse_roots[2];
/* The FIELD_DECL for the current field. */
#define current_field parse_roots[0]
#define current_method parse_roots[1]
/* A list of TRANSLATION_UNIT_DECLs for the files to be compiled. */
-#define current_file_list parse_roots[2]
+static GTY(()) VEC(tree,gc) *current_file_list;
/* Line 0 in current file, if compiling from bytecode. */
static location_t file_start_location;
/* The Java archive that provides main_class; the main input file. */
static GTY(()) struct JCF * main_jcf;
+/* A list of all the class DECLs seen so far. */
+static GTY(()) VEC(tree,gc) *all_class_list;
+
/* The number of source files passed to us by -fsource-filename and an
array of pointers to each name. Used by find_sourcefile(). */
static int num_files = 0;
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 );
+ VEC_safe_push (tree, gc, all_class_list, TYPE_NAME (current_class));
}
/* If we came across inner classes, load them now. */
static void
java_layout_seen_class_methods (void)
{
- tree previous_list = all_class_list;
- tree end = NULL_TREE;
- tree current;
+ unsigned start = 0;
+ unsigned end = VEC_length (tree, all_class_list);
while (1)
{
- for (current = previous_list;
- current != end; current = TREE_CHAIN (current))
+ unsigned ix;
+ unsigned new_length;
+
+ for (ix = start; ix != end; ix++)
{
- tree decl = TREE_VALUE (current);
+ tree decl = VEC_index (tree, all_class_list, ix);
tree cls = TREE_TYPE (decl);
input_location = DECL_SOURCE_LOCATION (decl);
/* Note that new classes might have been added while laying out
methods, changing the value of all_class_list. */
-
- if (previous_list != all_class_list)
+ new_length = VEC_length (tree, all_class_list);
+ if (end != new_length)
{
- end = previous_list;
- previous_list = all_class_list;
+ start = end;
+ end = new_length;
}
else
break;
input_location = save_location;
}
+static VEC(tree,gc) *predefined_filenames;
+
void
add_predefined_file (tree name)
{
- predef_filenames = tree_cons (NULL_TREE, name, predef_filenames);
+ VEC_safe_push (tree, gc, predefined_filenames, name);
}
int
predefined_filename_p (tree node)
{
- tree iter;
+ unsigned ix;
+ tree f;
+
+ for (ix = 0; VEC_iterate (tree, predefined_filenames, ix, f); ix++)
+ if (f == node)
+ return 1;
- for (iter = predef_filenames; iter != NULL_TREE; iter = TREE_CHAIN (iter))
- {
- if (TREE_VALUE (iter) == node)
- return 1;
- }
return 0;
}
tree node;
FILE *finput = NULL;
int in_quotes = 0;
+ unsigned ix;
bitmap_obstack_initialize (&bit_obstack);
field_offsets = BITMAP_ALLOC (&bit_obstack);
{
tree file_decl = build_decl (input_location,
TRANSLATION_UNIT_DECL, node, NULL);
- TREE_CHAIN (file_decl) = current_file_list;
- current_file_list = file_decl;
+ VEC_safe_push (tree, gc, current_file_list, file_decl);
IS_A_COMMAND_LINE_FILENAME_P (node) = 1;
}
}
const char *resource_filename;
/* Only one resource file may be compiled at a time. */
- assert (TREE_CHAIN (current_file_list) == NULL);
+ assert (VEC_length (tree, current_file_list) == 1);
- resource_filename = IDENTIFIER_POINTER (DECL_NAME (current_file_list));
+ resource_filename = IDENTIFIER_POINTER (DECL_NAME (VEC_index (tree, current_file_list, 0)));
compile_resource_file (resource_name, resource_filename);
goto finish;
}
current_jcf = main_jcf;
- current_file_list = nreverse (current_file_list);
- for (node = current_file_list; node; node = TREE_CHAIN (node))
+ for (ix = 0; VEC_iterate (tree, current_file_list, ix, node); ix++)
{
unsigned char magic_string[4];
char *real_path;
}
}
- for (node = current_file_list; node; node = TREE_CHAIN (node))
+ for (ix = 0; VEC_iterate (tree, current_file_list, ix, node); ix++)
{
input_location = DECL_SOURCE_LOCATION (node);
if (CLASS_FILE_P (node))
#endif
/* A list of all the resources files. */
-static GTY(()) tree resources = NULL;
+static GTY(()) VEC(tree,gc) *resources;
void
compile_resource_data (const char *name, const char *buffer, int length)
rest_of_decl_compilation (decl, global_bindings_p (), 0);
varpool_finalize_decl (decl);
- resources = tree_cons (NULL_TREE, decl, resources);
+ VEC_safe_push (tree, gc, resources, decl);
}
void
write_resource_constructor (tree *list_p)
{
- tree iter, t, register_resource_fn;
+ tree decl, t, register_resource_fn;
+ unsigned ix;
if (resources == NULL)
return;
register_resource_fn = t;
/* Write out entries in the same order in which they were defined. */
- for (iter = nreverse (resources); iter ; iter = TREE_CHAIN (iter))
+ for (ix = 0; VEC_iterate (tree, resources, ix, decl); ix++)
{
- t = build_fold_addr_expr (TREE_VALUE (iter));
+ t = build_fold_addr_expr (decl);
t = build_call_expr (register_resource_fn, 1, t);
append_to_statement_list (t, list_p);
}