Chromium Code Reviews| Index: src/ast/scopes.cc |
| diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc |
| index cc7a975c16cd8c8d09b0839723b9762505a20714..9bdcc5c5825baf25c6eab5923016bd7e0d995bfe 100644 |
| --- a/src/ast/scopes.cc |
| +++ b/src/ast/scopes.cc |
| @@ -950,7 +950,8 @@ Variable* Scope::DeclareLocal(const AstRawString* name, VariableMode mode, |
| // introduced during variable allocation, and TEMPORARY variables are |
| // allocated via NewTemporary(). |
| DCHECK(IsDeclaredVariableMode(mode)); |
| - DCHECK(!GetDeclarationScope()->is_being_lazily_parsed()); |
| + DCHECK_IMPLIES(GetDeclarationScope()->is_being_lazily_parsed(), |
| + mode == VAR || mode == LET || mode == CONST); |
| DCHECK(!GetDeclarationScope()->was_lazily_parsed()); |
| return Declare(zone(), name, mode, kind, init_flag, maybe_assigned_flag); |
| } |
| @@ -1079,8 +1080,11 @@ void Scope::DeclareVariableName(const AstRawString* name, VariableMode mode) { |
| (is_block_scope() || is_catch_scope()))); |
| DCHECK(scope_info_.is_null()); |
| - // Declare the variable in the declaration scope. |
| - variables_.DeclareName(zone(), name, mode); |
| + Variable* var = LookupLocal(name); |
|
jochen (gone - plz use gerrit)
2017/01/25 16:34:14
can you please explain this change?
marja
2017/01/25 17:10:44
This is kinda covered by the title line; in order
|
| + if (var == nullptr) { |
| + var = DeclareLocal(name, mode); |
| + } |
| + var->set_is_used(); |
| } |
| VariableProxy* Scope::NewUnresolved(AstNodeFactory* factory, |
| @@ -2084,13 +2088,14 @@ void ModuleScope::AllocateModuleVariables() { |
| } |
| void Scope::AllocateVariablesRecursively() { |
| - DCHECK(!already_resolved_); |
| - DCHECK_EQ(0, num_stack_slots_); |
| // Don't allocate variables of preparsed scopes. |
| if (is_declaration_scope() && AsDeclarationScope()->was_lazily_parsed()) { |
| return; |
| } |
| + DCHECK(!already_resolved_); |
| + DCHECK_EQ(0, num_stack_slots_); |
| + |
| // Allocate variables for inner scopes. |
| for (Scope* scope = inner_scope_; scope != nullptr; scope = scope->sibling_) { |
| scope->AllocateVariablesRecursively(); |
| @@ -2164,8 +2169,12 @@ void Scope::AllocateDebuggerScopeInfos(Isolate* isolate, |
| void Scope::CollectVariableData(PreParsedScopeData* data) { |
| PreParsedScopeData::ScopeScope scope_scope(data, scope_type(), |
| start_position(), end_position()); |
| - // TODO(marja): Add data about the variables. |
| - |
| + for (Variable* local : locals_) { |
| + if (local->mode() == VAR || local->mode() == LET || |
| + local->mode() == CONST) { |
| + scope_scope.AddVariable(local->location(), local->maybe_assigned()); |
| + } |
| + } |
| for (Scope* inner = inner_scope_; inner != nullptr; inner = inner->sibling_) { |
| inner->CollectVariableData(data); |
| } |