| Index: src/ast/scopes.cc
|
| diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
|
| index c6f7e0c15e82f926d30f761a74ba7010660e9c48..7df1a00b2966c91c4919de3bcf171fcf3bea174e 100644
|
| --- a/src/ast/scopes.cc
|
| +++ b/src/ast/scopes.cc
|
| @@ -111,10 +111,14 @@ DeclarationScope::DeclarationScope(Zone* zone, Scope* outer_scope,
|
| params_(4, zone),
|
| sloppy_block_function_map_(zone) {
|
| SetDefaults();
|
| - if (scope_type == MODULE_SCOPE) {
|
| - module_descriptor_ = new (zone) ModuleDescriptor(zone);
|
| - language_mode_ = STRICT;
|
| - }
|
| +}
|
| +
|
| +ModuleScope::ModuleScope(Zone* zone, DeclarationScope* script_scope,
|
| + AstValueFactory* ast_value_factory)
|
| + : DeclarationScope(zone, script_scope, MODULE_SCOPE) {
|
| + module_descriptor_ = new (zone) ModuleDescriptor(zone);
|
| + set_language_mode(STRICT);
|
| + DeclareThis(ast_value_factory);
|
| }
|
|
|
| Scope::Scope(Zone* zone, Scope* inner_scope, ScopeType scope_type,
|
| @@ -181,7 +185,6 @@ void DeclarationScope::SetDefaults() {
|
| arity_ = 0;
|
| rest_parameter_ = nullptr;
|
| rest_index_ = -1;
|
| - module_descriptor_ = nullptr;
|
| }
|
|
|
| void Scope::SetDefaults() {
|
| @@ -366,6 +369,16 @@ const DeclarationScope* Scope::AsDeclarationScope() const {
|
| return static_cast<const DeclarationScope*>(this);
|
| }
|
|
|
| +ModuleScope* Scope::AsModuleScope() {
|
| + DCHECK(is_module_scope());
|
| + return static_cast<ModuleScope*>(this);
|
| +}
|
| +
|
| +const ModuleScope* Scope::AsModuleScope() const {
|
| + DCHECK(is_module_scope());
|
| + return static_cast<const ModuleScope*>(this);
|
| +}
|
| +
|
| int Scope::num_parameters() const {
|
| return is_declaration_scope() ? AsDeclarationScope()->num_parameters() : 0;
|
| }
|
| @@ -1690,7 +1703,7 @@ void DeclarationScope::AllocateLocals() {
|
| }
|
| }
|
|
|
| -void DeclarationScope::AllocateModuleVariables() {
|
| +void ModuleScope::AllocateModuleVariables() {
|
| for (auto it = module()->regular_imports().begin();
|
| it != module()->regular_imports().end(); ++it) {
|
| Variable* var = LookupLocal(it->second->local_name);
|
| @@ -1721,7 +1734,7 @@ void Scope::AllocateVariablesRecursively() {
|
| // Parameters must be allocated first, if any.
|
| if (is_declaration_scope()) {
|
| if (is_module_scope()) {
|
| - AsDeclarationScope()->AllocateModuleVariables();
|
| + AsModuleScope()->AllocateModuleVariables();
|
| } else if (is_function_scope()) {
|
| AsDeclarationScope()->AllocateParameterLocals();
|
| }
|
|
|