Chromium Code Reviews| Index: src/ast/scopes.cc |
| diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc |
| index eb92cefb98f055f12081c00611624944e361c26a..1aaf5c5321b46403c08fc32effe192070f407e80 100644 |
| --- a/src/ast/scopes.cc |
| +++ b/src/ast/scopes.cc |
| @@ -135,9 +135,10 @@ DeclarationScope::DeclarationScope(Zone* zone, Scope* outer_scope, |
| asm_function_ = outer_scope_->IsAsmModule(); |
| } |
| -ModuleScope::ModuleScope(Zone* zone, DeclarationScope* script_scope, |
| +ModuleScope::ModuleScope(DeclarationScope* script_scope, |
| AstValueFactory* ast_value_factory) |
| - : DeclarationScope(zone, script_scope, MODULE_SCOPE) { |
| + : DeclarationScope(ast_value_factory->zone(), script_scope, MODULE_SCOPE) { |
| + Zone* zone = ast_value_factory->zone(); |
| module_descriptor_ = new (zone) ModuleDescriptor(zone); |
| set_language_mode(STRICT); |
| DeclareThis(ast_value_factory); |
| @@ -598,35 +599,37 @@ Variable* Scope::LookupInScopeInfo(const AstRawString* name) { |
| // There should be no local slot with the given name. |
| DCHECK(scope_info_->StackSlotIndex(*name_handle) < 0); |
| - // Check context slot lookup. |
| VariableMode mode; |
| - VariableLocation location = VariableLocation::CONTEXT; |
| InitializationFlag init_flag; |
| MaybeAssignedFlag maybe_assigned_flag; |
| + |
| + VariableLocation location = VariableLocation::CONTEXT; |
| int index = ScopeInfo::ContextSlotIndex(scope_info_, name_handle, &mode, |
| &init_flag, &maybe_assigned_flag); |
| if (index < 0) { |
| location = VariableLocation::GLOBAL; |
| index = ScopeInfo::ContextGlobalSlotIndex(scope_info_, name_handle, &mode, |
| &init_flag, &maybe_assigned_flag); |
| + DCHECK(index < 0 || (is_script_scope() && IsDeclaredVariableMode(mode) && |
| + !IsLexicalVariableMode(mode))); |
|
adamk
2016/08/25 16:04:08
You should actually be able to tighten this one mo
|
| } |
| if (index < 0) { |
| - // Check parameters. |
| - index = scope_info_->ParameterIndex(*name_handle); |
| - if (index < 0) return NULL; |
| - |
| - mode = DYNAMIC; |
| location = VariableLocation::LOOKUP; |
|
adamk
2016/08/25 16:04:09
Why did this move out of the "found a parameter" b
|
| - init_flag = kCreatedInitialized; |
| - // Be conservative and flag parameters as maybe assigned. Better information |
| - // would require ScopeInfo to serialize the maybe_assigned bit also for |
| - // parameters. |
| - maybe_assigned_flag = kMaybeAssigned; |
| - } else { |
| - DCHECK(location != VariableLocation::GLOBAL || |
| - (is_script_scope() && IsDeclaredVariableMode(mode) && |
| - !IsLexicalVariableMode(mode))); |
| + index = scope_info_->ParameterIndex(*name_handle); |
| + if (index >= 0) { |
| + mode = DYNAMIC; |
| + init_flag = kCreatedInitialized; |
| + // Be conservative and flag parameters as maybe assigned. Better |
| + // information would require ScopeInfo to serialize the maybe_assigned bit |
| + // also for parameters. |
| + maybe_assigned_flag = kMaybeAssigned; |
| + } |
| + } |
| + if (index < 0 && scope_type() == MODULE_SCOPE) { |
| + location = VariableLocation::MODULE; |
| + index = -1; // TODO(neis): Find module variables in scope info. |
| } |
| + if (index < 0) return nullptr; // Nowhere found. |
| Variable::Kind kind = Variable::NORMAL; |
| if (location == VariableLocation::CONTEXT && |
| @@ -802,9 +805,9 @@ Declaration* Scope::CheckLexDeclarationsConflictingWith( |
| return nullptr; |
| } |
| -void Scope::CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals, |
| - ZoneList<Variable*>* context_locals, |
| - ZoneList<Variable*>* context_globals) { |
| +void Scope::CollectVariables(ZoneList<Variable*>* stack_locals, |
| + ZoneList<Variable*>* context_locals, |
| + ZoneList<Variable*>* context_globals) { |
| DCHECK(stack_locals != NULL); |
| DCHECK(context_locals != NULL); |
| DCHECK(context_globals != NULL); |