Index: src/scopes.cc |
=================================================================== |
--- src/scopes.cc (revision 854) |
+++ src/scopes.cc (working copy) |
@@ -184,11 +184,22 @@ |
-Variable* Scope::Lookup(Handle<String> name) { |
+Variable* Scope::LookupLocal(Handle<String> name) { |
return locals_.Lookup(name); |
} |
+Variable* Scope::Lookup(Handle<String> name) { |
+ for (Scope* scope = this; |
+ scope != NULL; |
+ scope = scope->outer_scope()) { |
+ Variable* var = scope->LookupLocal(name); |
+ if (var != NULL) return var; |
+ } |
+ return NULL; |
+} |
+ |
+ |
Variable* Scope::DeclareFunctionVar(Handle<String> name) { |
ASSERT(is_function_scope() && function_ == NULL); |
function_ = new Variable(this, name, Variable::CONST, true, false); |
@@ -207,7 +218,7 @@ |
void Scope::AddParameter(Variable* var) { |
ASSERT(is_function_scope()); |
- ASSERT(Lookup(var->name()) == var); |
+ ASSERT(LookupLocal(var->name()) == var); |
params_.Add(var); |
} |
@@ -258,7 +269,7 @@ |
} |
-void Scope::VisitIllegalRedeclaration(Visitor* visitor) { |
+void Scope::VisitIllegalRedeclaration(AstVisitor* visitor) { |
ASSERT(HasIllegalRedeclaration()); |
illegal_redecl_->Accept(visitor); |
} |
@@ -513,7 +524,7 @@ |
bool guess = scope_calls_eval_; |
// Try to find the variable in this scope. |
- Variable* var = Lookup(name); |
+ Variable* var = LookupLocal(name); |
if (var != NULL) { |
// We found a variable. If this is not an inner lookup, we are done. |
@@ -707,7 +718,7 @@ |
void Scope::AllocateParameterLocals() { |
ASSERT(is_function_scope()); |
- Variable* arguments = Lookup(Factory::arguments_symbol()); |
+ Variable* arguments = LookupLocal(Factory::arguments_symbol()); |
ASSERT(arguments != NULL); // functions have 'arguments' declared implicitly |
if (MustAllocate(arguments) && !HasArgumentsParameter()) { |
// 'arguments' is used. Unless there is also a parameter called |