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

Unified Diff: src/ast/scopes.h

Issue 2252223002: Introduce ModuleScope subclass of DeclarationScope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 months 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
« no previous file with comments | « src/ast/modules.cc ('k') | src/ast/scopes.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.h
diff --git a/src/ast/scopes.h b/src/ast/scopes.h
index 8cfac5262a5a372db2433ba0472273e643daeb06..05df42c198a84b5ddb255285cef8f13953bf09ef 100644
--- a/src/ast/scopes.h
+++ b/src/ast/scopes.h
@@ -69,13 +69,10 @@ class SloppyBlockFunctionMap : public ZoneHashMap {
// a location. Note that many VariableProxy nodes may refer to the same Java-
// Script variable.
-class DeclarationScope;
-
-// JS environments are represented in the parser using two scope classes, Scope
-// and its subclass DeclarationScope. DeclarationScope is used for any scope
-// that hosts 'var' declarations. This includes script, module, eval, varblock,
-// and function scope. All fields required by such scopes are only available on
-// DeclarationScope.
+// JS environments are represented in the parser using Scope, DeclarationScope
+// and ModuleScope. DeclarationScope is used for any scope that hosts 'var'
+// declarations. This includes script, module, eval, varblock, and function
+// scope. ModuleScope further specializes DeclarationScope.
class Scope: public ZoneObject {
public:
// ---------------------------------------------------------------------------
@@ -95,6 +92,8 @@ class Scope: public ZoneObject {
DeclarationScope* AsDeclarationScope();
const DeclarationScope* AsDeclarationScope() const;
+ ModuleScope* AsModuleScope();
+ const ModuleScope* AsModuleScope() const;
class Snapshot final BASE_EMBEDDED {
public:
@@ -444,6 +443,11 @@ class Scope: public ZoneObject {
bool HasSimpleParameters();
void set_is_debug_evaluate_scope() { is_debug_evaluate_scope_ = true; }
+ protected:
+ void set_language_mode(LanguageMode language_mode) {
+ language_mode_ = language_mode;
+ }
+
private:
Zone* zone_;
@@ -673,14 +677,6 @@ class DeclarationScope : public Scope {
IsClassConstructor(function_kind())));
}
- // The ModuleDescriptor for this scope; only for module scopes.
- // TODO(verwaest): Move to ModuleScope?
- ModuleDescriptor* module() const {
- DCHECK(is_module_scope());
- DCHECK_NOT_NULL(module_descriptor_);
- return module_descriptor_;
- }
-
void DeclareThis(AstValueFactory* ast_value_factory);
void DeclareDefaultFunctionVariables(AstValueFactory* ast_value_factory);
@@ -847,9 +843,6 @@ class DeclarationScope : public Scope {
void AllocateLocals();
void AllocateParameterLocals();
void AllocateReceiver();
- // Set MODULE as VariableLocation for all variables that will live in some
- // module's export table.
- void AllocateModuleVariables();
private:
void AllocateParameter(Variable* var, int index);
@@ -881,7 +874,23 @@ class DeclarationScope : public Scope {
Variable* arguments_;
// Convenience variable; Subclass constructor only
Variable* this_function_;
- // Module descriptor; module scopes only.
+};
+
+class ModuleScope final : public DeclarationScope {
+ public:
+ ModuleScope(Zone* zone, DeclarationScope* script_scope,
+ AstValueFactory* ast_value_factory);
+
+ ModuleDescriptor* module() const {
+ DCHECK_NOT_NULL(module_descriptor_);
+ return module_descriptor_;
+ }
+
+ // Set MODULE as VariableLocation for all variables that will live in some
+ // module's export table.
+ void AllocateModuleVariables();
+
+ private:
ModuleDescriptor* module_descriptor_;
};
« no previous file with comments | « src/ast/modules.cc ('k') | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698