Chromium Code Reviews| Index: src/scopes.cc |
| diff --git a/src/scopes.cc b/src/scopes.cc |
| index ddde48a77c50eaccb92ef21376dfc510f1a5aeb0..80cbeb7d0b61a1df6cdb8bedd564721c281bdc64 100644 |
| --- a/src/scopes.cc |
| +++ b/src/scopes.cc |
| @@ -383,11 +383,11 @@ Variable* Scope::DeclareFunctionVar(Handle<String> name) { |
| } |
| -void Scope::DeclareParameter(Handle<String> name) { |
| +void Scope::DeclareParameter(Handle<String> name, Variable::Mode mode) { |
| ASSERT(!already_resolved()); |
| ASSERT(is_function_scope()); |
| Variable* var = |
| - variables_.Declare(this, name, Variable::VAR, true, Variable::NORMAL); |
| + variables_.Declare(this, name, mode, true, Variable::NORMAL); |
| params_.Add(var); |
| } |
| @@ -467,6 +467,25 @@ void Scope::VisitIllegalRedeclaration(AstVisitor* visitor) { |
| } |
| +Declaration* Scope::CheckConflictingVarDeclarations() { |
| + int length = decls_.length(); |
| + for (int i = 0; i < length; i++) { |
| + Declaration* decl = decls_[i]; |
| + if (decl->mode() != Variable::VAR) continue; |
| + Handle<String> name = decl->proxy()->name(); |
| + for (Scope* scope = decl->scope(); |
| + scope->is_block_scope() || scope->is_catch_scope(); |
| + scope = scope->outer_scope_) { |
| + Variable* other_var = scope->variables_.Lookup(name); |
|
Lasse Reichstein
2011/09/01 07:34:04
This should be able to skip the first scope, where
Steven
2011/09/01 15:01:33
When by first scope you mean the innermost scope w
|
| + if (other_var != NULL && other_var->mode() == Variable::LET) { |
|
Lasse Reichstein
2011/09/01 07:34:04
Is it only LET declarations that can conflict, or
Steven
2011/09/01 15:01:33
Yes any non-VAR. Will fix it.
On 2011/09/01 07:34:
|
| + return decl; |
| + } |
| + } |
| + } |
| + return NULL; |
| +} |
| + |
| + |
| template<class Allocator> |
| void Scope::CollectUsedVariables(List<Variable*, Allocator>* locals) { |
| // Collect variables in this scope. |