Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: src/scopes.cc

Issue 12673: Change implementation of eval to make an exact distinction between direct eva... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« src/codegen-ia32.cc ('K') | « src/scopes.h ('k') | src/usage-analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698