Commit f2760b27 by Alexandre Petit-Bianco Committed by Alexandre Petit-Bianco

parse.y (lookup_field_wrapper): Search for final local aliases.

 2000-04-19  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* parse.y (lookup_field_wrapper): Search for final local aliases.
	(resolve_expression_name): Let lookup_field_wrapper search for
	final local aliases. Force the value of `name' if one is found.
	(qualify_ambiguous_name): CONVERT_EXPR is enough to now we have
	an expression name. Fixed comments.

From-SVN: r33400
parent c1b177ec
...@@ -47,6 +47,14 @@ Thu Apr 20 18:20:58 2000 Jason Schroeder <shrode@subnature.com> ...@@ -47,6 +47,14 @@ Thu Apr 20 18:20:58 2000 Jason Schroeder <shrode@subnature.com>
2000-04-19 Alexandre Petit-Bianco <apbianco@cygnus.com> 2000-04-19 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (lookup_field_wrapper): Search for final local aliases.
(resolve_expression_name): Let lookup_field_wrapper search for
final local aliases. Force the value of `name' if one is found.
(qualify_ambiguous_name): CONVERT_EXPR is enough to now we have
an expression name. Fixed comments.
2000-04-19 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (yyerror): `msg' can be null, don't use it in that case. * parse.y (yyerror): `msg' can be null, don't use it in that case.
2000-04-19 Tom Tromey <tromey@cygnus.com> 2000-04-19 Tom Tromey <tromey@cygnus.com>
......
...@@ -3986,6 +3986,21 @@ lookup_field_wrapper (class, name) ...@@ -3986,6 +3986,21 @@ lookup_field_wrapper (class, name)
tree decl; tree decl;
java_parser_context_save_global (); java_parser_context_save_global ();
decl = lookup_field (&type, name); decl = lookup_field (&type, name);
/* Last chance: if we're within the context of an inner class, we
might be trying to access a local variable defined in an outer
context. We try to look for it now. */
if (INNER_CLASS_TYPE_P (class) && (!decl || decl == error_mark_node))
{
char *alias_buffer;
MANGLE_OUTER_LOCAL_VARIABLE_NAME (alias_buffer, name);
name = get_identifier (alias_buffer);
type = class;
decl = lookup_field (&type, name);
if (decl && decl != error_mark_node)
FIELD_LOCAL_ALIAS_USED (decl) = 1;
}
java_parser_context_restore_global (); java_parser_context_restore_global ();
return decl == error_mark_node ? NULL : decl; return decl == error_mark_node ? NULL : decl;
} }
...@@ -8450,25 +8465,17 @@ resolve_expression_name (id, orig) ...@@ -8450,25 +8465,17 @@ resolve_expression_name (id, orig)
else else
{ {
decl = lookup_field_wrapper (current_class, name); decl = lookup_field_wrapper (current_class, name);
/* Last chance: if we're within the context of an inner
class, we might be trying to access a local variable
defined in an outer context. We try to look for it
now. */
if (!decl && INNER_CLASS_TYPE_P (current_class))
{
char *alias_buffer;
MANGLE_OUTER_LOCAL_VARIABLE_NAME (alias_buffer, name);
name = get_identifier (alias_buffer);
decl = lookup_field_wrapper (current_class, name);
if (decl)
FIELD_LOCAL_ALIAS_USED (decl) = 1;
}
if (decl) if (decl)
{ {
tree access = NULL_TREE; tree access = NULL_TREE;
int fs = FIELD_STATIC (decl); int fs = FIELD_STATIC (decl);
/* If we're accessing an outer scope local alias, make
sure we change the name of the field we're going to
build access to. */
if (FIELD_LOCAL_ALIAS_USED (decl))
name = DECL_NAME (decl);
/* Instance variable (8.3.1.1) can't appear within /* Instance variable (8.3.1.1) can't appear within
static method, static initializer or initializer for static method, static initializer or initializer for
a static variable. */ a static variable. */
...@@ -10154,8 +10161,9 @@ qualify_ambiguous_name (id) ...@@ -10154,8 +10161,9 @@ qualify_ambiguous_name (id)
qual = TREE_CHAIN (qual); qual = TREE_CHAIN (qual);
again = new_array_found = 1; again = new_array_found = 1;
continue; continue;
case NEW_CLASS_EXPR:
case CONVERT_EXPR: case CONVERT_EXPR:
break;
case NEW_CLASS_EXPR:
qual_wfl = TREE_OPERAND (qual_wfl, 0); qual_wfl = TREE_OPERAND (qual_wfl, 0);
break; break;
case ARRAY_REF: case ARRAY_REF:
...@@ -10240,10 +10248,10 @@ qualify_ambiguous_name (id) ...@@ -10240,10 +10248,10 @@ qualify_ambiguous_name (id)
} }
} while (again); } while (again);
/* If name appears within the scope of a location variable /* If name appears within the scope of a local variable declaration
declaration or parameter declaration, then it is an expression or parameter declaration, then it is an expression name. We don't
name. We don't carry this test out if we're in the context of the carry this test out if we're in the context of the use of SUPER
use of SUPER or THIS */ or THIS */
if (!this_found && !super_found if (!this_found && !super_found
&& TREE_CODE (name) != STRING_CST && TREE_CODE (name) != INTEGER_CST && TREE_CODE (name) != STRING_CST && TREE_CODE (name) != INTEGER_CST
&& (decl = IDENTIFIER_LOCAL_VALUE (name))) && (decl = IDENTIFIER_LOCAL_VALUE (name)))
...@@ -10279,7 +10287,7 @@ qualify_ambiguous_name (id) ...@@ -10279,7 +10287,7 @@ qualify_ambiguous_name (id)
QUAL_RESOLUTION (qual) = decl; QUAL_RESOLUTION (qual) = decl;
} }
/* Method call are expression name */ /* Method call, array references and cast are expression name */
else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR
|| TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF
|| TREE_CODE (QUAL_WFL (qual)) == CONVERT_EXPR) || TREE_CODE (QUAL_WFL (qual)) == CONVERT_EXPR)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment