Commit 0ca9bef3 authored by marja's avatar marja Committed by Commit bot

Get rid of PreParserScope.

It's unnecessary; PreParser can just use normal Scopes for the things it needs
to track. Note: the only functionalities of PreParserScope were keeping track of
the scope stack, and for each scope, the scope type and language mode. Those are
now done by Scope. PreParser doesn't yet put variables into scopes (that will be
done in a follow up).

R=rossberg@chromium.org
BUG=

Review URL: https://codereview.chromium.org/912563004

Cr-Commit-Position: refs/heads/master@{#26544}
parent 18e7f82b
......@@ -263,21 +263,6 @@ void Parser::SetCachedData() {
}
Scope* Parser::NewScope(Scope* parent, ScopeType scope_type,
FunctionKind kind) {
DCHECK(ast_value_factory());
DCHECK(scope_type != MODULE_SCOPE || allow_harmony_modules());
DCHECK((scope_type == FUNCTION_SCOPE && IsValidFunctionKind(kind)) ||
kind == kNormalFunction);
Scope* result = new (zone())
Scope(isolate(), zone(), parent, scope_type, ast_value_factory());
bool uninitialized_this =
FLAG_experimental_classes && IsSubclassConstructor(kind);
result->Initialize(uninitialized_this);
return result;
}
FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope,
int pos, int end_pos) {
int materialized_literal_count = -1;
......
......@@ -358,11 +358,6 @@ class ParserTraits {
// it needs.
typedef v8::internal::Parser* Parser;
// Used by FunctionState and BlockState.
typedef v8::internal::Scope Scope;
typedef v8::internal::Scope* ScopePtr;
inline static Scope* ptr_to_scope(ScopePtr scope) { return scope; }
typedef Variable GeneratorVariable;
typedef v8::internal::AstProperties AstProperties;
......@@ -846,10 +841,6 @@ class Parser : public ParserBase<ParserTraits> {
IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok);
// Factory methods.
Scope* NewScope(Scope* parent, ScopeType type,
FunctionKind kind = kNormalFunction);
FunctionLiteral* DefaultConstructor(bool call_super, Scope* scope, int pos,
int end_pos);
......
......@@ -107,14 +107,14 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction(
LanguageMode language_mode, FunctionKind kind, ParserRecorder* log) {
log_ = log;
// Lazy functions always have trivial outer scopes (no with/catch scopes).
PreParserScope top_scope(scope_, SCRIPT_SCOPE);
Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE);
PreParserFactory top_factory(NULL);
FunctionState top_state(&function_state_, &scope_, &top_scope,
kNormalFunction, &top_factory);
FunctionState top_state(&function_state_, &scope_, top_scope, kNormalFunction,
&top_factory);
scope_->SetLanguageMode(language_mode);
PreParserScope function_scope(scope_, FUNCTION_SCOPE);
Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE);
PreParserFactory function_factory(NULL);
FunctionState function_state(&function_state_, &scope_, &function_scope, kind,
FunctionState function_state(&function_state_, &scope_, function_scope, kind,
&function_factory);
DCHECK_EQ(Token::LBRACE, scanner()->current_token());
bool ok = true;
......@@ -628,8 +628,8 @@ PreParser::Statement PreParser::ParseWithStatement(bool* ok) {
ParseExpression(true, CHECK_OK);
Expect(Token::RPAREN, CHECK_OK);
PreParserScope with_scope(scope_, WITH_SCOPE);
BlockState block_state(&scope_, &with_scope);
Scope* with_scope = NewScope(scope_, WITH_SCOPE);
BlockState block_state(&scope_, with_scope);
ParseStatement(CHECK_OK);
return Statement::Default();
}
......@@ -813,8 +813,8 @@ PreParser::Statement PreParser::ParseTryStatement(bool* ok) {
ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK);
Expect(Token::RPAREN, CHECK_OK);
{
PreParserScope with_scope(scope_, WITH_SCOPE);
BlockState block_state(&scope_, &with_scope);
Scope* with_scope = NewScope(scope_, WITH_SCOPE);
BlockState block_state(&scope_, with_scope);
ParseBlock(CHECK_OK);
}
tok = peek();
......@@ -857,10 +857,10 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
// '(' FormalParameterList? ')' '{' FunctionBody '}'
// Parse function body.
ScopeType outer_scope_type = scope_->type();
PreParserScope function_scope(scope_, FUNCTION_SCOPE);
bool outer_is_script_scope = scope_->is_script_scope();
Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE);
PreParserFactory factory(NULL);
FunctionState function_state(&function_state_, &scope_, &function_scope, kind,
FunctionState function_state(&function_state_, &scope_, function_scope, kind,
&factory);
// FormalParameterList ::
// '(' (Identifier)*[','] ')'
......@@ -915,8 +915,8 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
// See Parser::ParseFunctionLiteral for more information about lazy parsing
// and lazy compilation.
bool is_lazily_parsed = (outer_scope_type == SCRIPT_SCOPE && allow_lazy() &&
!parenthesized_function_);
bool is_lazily_parsed =
(outer_is_script_scope && allow_lazy() && !parenthesized_function_);
parenthesized_function_ = false;
Expect(Token::LBRACE, CHECK_OK);
......@@ -974,11 +974,12 @@ PreParserExpression PreParser::ParseClassLiteral(
return EmptyExpression();
}
PreParserScope scope = NewScope(scope_, BLOCK_SCOPE);
BlockState block_state(&scope_, &scope);
Scope* scope = NewScope(scope_, BLOCK_SCOPE);
BlockState block_state(&scope_, scope);
scope_->SetLanguageMode(
static_cast<LanguageMode>(scope_->language_mode() | STRICT_BIT));
scope_->SetScopeName(name);
// TODO(marja): Make PreParser use scope names too.
// scope_->SetScopeName(name);
bool has_extends = Check(Token::EXTENDS);
if (has_extends) {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment