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

Unified Diff: src/parsing/parser-base.h

Issue 2212383003: Revert of Separate Scope into DeclarationScope and Scope (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/parsing/parser.cc ('k') | src/parsing/pattern-rewriter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index 6058d25c6f887069b59e777fb3815366e9f0c79b..134c576b6cb6e35ac4e6d46230d8050ec15ea8a3 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -111,8 +111,8 @@
inline bool IsAsyncMethod(MethodKind kind) { return kind & MethodKind::Async; }
struct FormalParametersBase {
- explicit FormalParametersBase(DeclarationScope* scope) : scope(scope) {}
- DeclarationScope* scope;
+ explicit FormalParametersBase(Scope* scope) : scope(scope) {}
+ Scope* scope;
bool has_rest = false;
bool is_simple = true;
int materialized_literals_count = 0;
@@ -287,7 +287,7 @@
private:
ScopeState** const scope_stack_;
ScopeState* const outer_scope_;
- Scope* const scope_;
+ Scope* scope_;
};
class BlockState final : public ScopeState {
@@ -317,7 +317,7 @@
Scope* NewScope(ScopeState* outer_state) {
Scope* parent = outer_state->scope();
Zone* zone = outer_state->zone();
- return new (zone) Scope(zone, parent, BLOCK_SCOPE);
+ return new (zone) Scope(zone, parent, BLOCK_SCOPE, kNormalFunction);
}
};
@@ -611,24 +611,8 @@
Mode old_mode_;
};
- DeclarationScope* NewScriptScope() {
- return new (zone()) DeclarationScope(zone(), nullptr, SCRIPT_SCOPE);
- }
-
- DeclarationScope* NewVarblockScope() {
- return new (zone()) DeclarationScope(zone(), scope(), BLOCK_SCOPE);
- }
-
- DeclarationScope* NewModuleScope(Scope* parent) {
- DeclarationScope* result =
- new (zone()) DeclarationScope(zone(), parent, MODULE_SCOPE);
- // TODO(verwaest): Move into the DeclarationScope constructor.
- result->DeclareThis(ast_value_factory());
- return result;
- }
-
- DeclarationScope* NewEvalScope(Scope* parent) {
- return new (zone()) DeclarationScope(zone(), parent, EVAL_SCOPE);
+ Scope* NewScriptScope() {
+ return new (zone()) Scope(zone(), nullptr, SCRIPT_SCOPE, kNormalFunction);
}
Scope* NewScope(ScopeType scope_type) {
@@ -643,16 +627,16 @@
// types.
DCHECK_NE(FUNCTION_SCOPE, scope_type);
DCHECK_NE(SCRIPT_SCOPE, scope_type);
- DCHECK_NE(MODULE_SCOPE, scope_type);
DCHECK_NOT_NULL(parent);
- return new (zone()) Scope(zone(), parent, scope_type);
- }
-
- DeclarationScope* NewFunctionScope(FunctionKind kind) {
+ Scope* result =
+ new (zone()) Scope(zone(), parent, scope_type, kNormalFunction);
+ if (scope_type == MODULE_SCOPE) result->DeclareThis(ast_value_factory());
+ return result;
+ }
+
+ Scope* NewFunctionScope(FunctionKind kind) {
DCHECK(ast_value_factory());
- DeclarationScope* result =
- new (zone()) DeclarationScope(zone(), scope(), FUNCTION_SCOPE, kind);
- // TODO(verwaest): Move into the DeclarationScope constructor.
+ Scope* result = new (zone()) Scope(zone(), scope(), FUNCTION_SCOPE, kind);
if (!IsArrowFunction(kind)) {
result->DeclareThis(ast_value_factory());
result->DeclareDefaultFunctionVariables(ast_value_factory());
@@ -1163,7 +1147,7 @@
if (is_sloppy(scope->language_mode())) {
// For sloppy scopes we also have to record the call at function level,
// in case it includes declarations that will be hoisted.
- scope->GetDeclarationScope()->RecordEvalCall();
+ scope->DeclarationScope()->RecordEvalCall();
}
}
}
@@ -1227,9 +1211,7 @@
bool has_seen_constructor_;
};
- ModuleDescriptor* module() const {
- return scope()->AsDeclarationScope()->module();
- }
+ ModuleDescriptor* module() const { return scope()->module(); }
Scope* scope() const { return scope_state_->scope(); }
ScopeState* scope_state_; // Scope stack.
@@ -2331,7 +2313,7 @@
ValidateFormalParameterInitializer(&arrow_formals_classifier, ok);
Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos);
- DeclarationScope* scope =
+ Scope* scope =
this->NewFunctionScope(is_async ? FunctionKind::kAsyncArrowFunction
: FunctionKind::kArrowFunction);
// Because the arrow's parameters were parsed in the outer scope, any
@@ -3096,7 +3078,7 @@
Expect(Token::SUPER, CHECK_OK);
int pos = position();
- DeclarationScope* scope = this->scope()->GetReceiverScope();
+ Scope* scope = this->scope()->ReceiverScope();
FunctionKind kind = scope->function_kind();
if (IsConciseMethod(kind) || IsAccessorFunction(kind) ||
IsClassConstructor(kind)) {
@@ -3138,7 +3120,7 @@
int pos = position();
ExpectMetaProperty(CStrVector("target"), "new.target", pos, CHECK_OK);
- if (!scope()->GetReceiverScope()->is_function_scope()) {
+ if (!scope()->ReceiverScope()->is_function_scope()) {
ReportMessageAt(scanner()->location(),
MessageTemplate::kUnexpectedNewTarget);
*ok = false;
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/pattern-rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698