+2005-05-10 Paolo Bonzini <bonzini@gnu.org>
+
+ PR java/21436
+ * class.c (maybe_layout_super_class): Look for imports in this_class.
+ * parse.h (ctxp_for_generation_last): New.
+ (do_resolve_class): Add a parameter.
+ * parse.y (ctxp_for_generation_last): New.
+ (java_pop_parser_context): Add at end of list.
+ (find_in_imports, find_in_imports_on_demand): Look in ctxp
+ if the TYPE_IMPORT_LIST or respectively the TYPE_IMPORT_DEMAND_LIST of
+ the given type are NULL.
+ (do_resolve_class): Look into the imports of the new second parameter.
+ Adjust recursive calls.
+ (resolve_class, resolve_inner_class, find_as_inner_class): Adjust
+ calls to do_resolve_class.
+ (create_class): Set the TYPE_IMPORT_LIST and TYPE_IMPORT_DEMAND_LIST.
+ (java_complete_class): Do not do that here.
+
2005-05-03 Thomas Fitzsimmons <fitzsim@redhat.com>
PR java/20309
(CLASS_P): Moved around.
(java_parse_abort_on_error): Macro moved from jcf-parse.c
* jcf-parse.c (java_parse_abort_on_error): Macro moved to
- java-parse.h
+ java-tree.h
(jcf_parse_source): Changed leading comment. Removed unnecessary
fclose and CLASS_FROM_SOURCE_P marking.
(parse_source_file): New local variables remember_for_generation
/* List of things that were analyzed for which code will be generated */
struct parser_ctxt *ctxp_for_generation = NULL;
+struct parser_ctxt *ctxp_for_generation_last = NULL;
/* binop_lookup maps token to tree_code. It is used where binary
operations are involved and required by the parser. RDIV_EXPR
do is to just update a list of class names. */
if (generate)
{
- ctxp->next = ctxp_for_generation;
- ctxp_for_generation = ctxp;
+ if (ctxp_for_generation_last == NULL)
+ ctxp_for_generation = ctxp;
+ else
+ ctxp_for_generation_last->next = ctxp;
+ ctxp->next = NULL;
+ ctxp_for_generation_last = ctxp;
}
/* And restore those of the previous context */
break;
if (TREE_CODE (local_super) == POINTER_TYPE)
- local_super = do_resolve_class (NULL, local_super, NULL, NULL);
+ local_super = do_resolve_class (NULL, NULL, local_super, NULL, NULL);
else
local_super = TYPE_NAME (local_super);
acc = merge_qualified_name (acc,
EXPR_WFL_NODE (TREE_PURPOSE (qual)));
BUILD_PTR_FROM_NAME (ptr, acc);
- decl = do_resolve_class (NULL_TREE, ptr, NULL_TREE, cl);
+ decl = do_resolve_class (NULL_TREE, NULL_TREE, ptr, NULL_TREE, cl);
}
/* A NULL qual and a decl means that the search ended
virtual function table in java.lang.object. */
TYPE_VFIELD (TREE_TYPE (decl)) = TYPE_VFIELD (object_type_node);
+ /* We keep the compilation unit imports in the class so that
+ they can be used later to resolve type dependencies that
+ aren't necessary to solve now. */
+ TYPE_IMPORT_LIST (TREE_TYPE (decl)) = ctxp->import_list;
+ TYPE_IMPORT_DEMAND_LIST (TREE_TYPE (decl)) = ctxp->import_demand_list;
+
/* Add the private this$<n> field, Replicate final locals still in
scope as private final fields mangled like val$<local_name>.
This does not occur for top level (static) inner classes. */
{
jdep *dep;
- /* We keep the compilation unit imports in the class so that
- they can be used later to resolve type dependencies that
- aren't necessary to solve now. */
- TYPE_IMPORT_LIST (TREE_TYPE (cclass)) = ctxp->import_list;
- TYPE_IMPORT_DEMAND_LIST (TREE_TYPE (cclass)) = ctxp->import_demand_list;
-
for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep))
{
tree decl;
WFL_STRIP_BRACKET (cl, cl);
/* 2- Resolve the bare type */
- if (!(resolved_type_decl = do_resolve_class (enclosing, class_type,
+ if (!(resolved_type_decl = do_resolve_class (enclosing, NULL_TREE, class_type,
decl, cl)))
return NULL_TREE;
resolved_type = TREE_TYPE (resolved_type_decl);
and (but it doesn't really matter) qualify_and_find. */
tree
-do_resolve_class (tree enclosing, tree class_type, tree decl, tree cl)
+do_resolve_class (tree enclosing, tree import_type, tree class_type, tree decl,
+ tree cl)
{
tree new_class_decl = NULL_TREE, super = NULL_TREE;
tree saved_enclosing_type = enclosing ? TREE_TYPE (enclosing) : NULL_TREE;
if (split_qualified_name (&left, &right, TYPE_NAME (class_type)) == 0)
{
BUILD_PTR_FROM_NAME (left_type, left);
- q = do_resolve_class (enclosing, left_type, decl, cl);
+ q = do_resolve_class (enclosing, import_type, left_type, decl, cl);
if (q)
{
enclosing = q;
return new_class_decl;
}
- /* 1- Check for the type in single imports. This will change
- TYPE_NAME() if something relevant is found */
+ /* 1- Check for the type in single imports. Look at enclosing classes and,
+ if we're laying out a superclass, at the import list for the subclass.
+ This will change TYPE_NAME() if something relevant is found. */
+ if (import_type && TYPE_IMPORT_LIST (import_type))
+ find_in_imports (import_type, class_type);
find_in_imports (saved_enclosing_type, class_type);
/* 2- And check for the type in the current compilation unit */
/* 4- Check the import on demands. Don't allow bar.baz to be
imported from foo.* */
if (!QUALIFIED_P (TYPE_NAME (class_type)))
- if (find_in_imports_on_demand (saved_enclosing_type, class_type))
- return NULL_TREE;
+ {
+ if (import_type
+ && TYPE_IMPORT_DEMAND_LIST (import_type)
+ && find_in_imports_on_demand (import_type, class_type))
+ return NULL_TREE;
+ if (find_in_imports_on_demand (saved_enclosing_type, class_type))
+ return NULL_TREE;
+ }
/* If found in find_in_imports_on_demand, the type has already been
loaded. */
static void
find_in_imports (tree enclosing_type, tree class_type)
{
- tree import = (enclosing_type ? TYPE_IMPORT_LIST (enclosing_type) :
- ctxp->import_list);
+ tree import;
+ if (enclosing_type && TYPE_IMPORT_LIST (enclosing_type))
+ import = TYPE_IMPORT_LIST (enclosing_type);
+ else
+ import = ctxp->import_list;
+
while (import)
{
if (TREE_VALUE (import) == TYPE_NAME (class_type))
find_in_imports_on_demand (tree enclosing_type, tree class_type)
{
tree class_type_name = TYPE_NAME (class_type);
- tree import = (enclosing_type ? TYPE_IMPORT_DEMAND_LIST (enclosing_type) :
- ctxp->import_demand_list);
tree cl = NULL_TREE;
int seen_once = -1; /* -1 when not set, 1 if seen once, >1 otherwise. */
int to_return = -1; /* -1 when not set, 0 or 1 otherwise */
tree node;
+ tree import;
+
+ if (enclosing_type && TYPE_IMPORT_DEMAND_LIST (enclosing_type))
+ import = TYPE_IMPORT_DEMAND_LIST (enclosing_type);
+ else
+ import = ctxp->import_demand_list;
for (; import; import = TREE_CHAIN (import))
{