Commit 748517f7 authored by verwaest's avatar verwaest Committed by Commit bot

Redirect most NewUnresolved calls over Parser

BUG=v8:5209

Review-Url: https://codereview.chromium.org/2233473002
Cr-Commit-Position: refs/heads/master@{#38575}
parent 76b53534
...@@ -160,9 +160,9 @@ class Scope: public ZoneObject { ...@@ -160,9 +160,9 @@ class Scope: public ZoneObject {
// Create a new unresolved variable. // Create a new unresolved variable.
VariableProxy* NewUnresolved(AstNodeFactory* factory, VariableProxy* NewUnresolved(AstNodeFactory* factory,
const AstRawString* name, const AstRawString* name,
Variable::Kind kind = Variable::NORMAL,
int start_position = kNoSourcePosition, int start_position = kNoSourcePosition,
int end_position = kNoSourcePosition) { int end_position = kNoSourcePosition,
Variable::Kind kind = Variable::NORMAL) {
// Note that we must not share the unresolved variables with // Note that we must not share the unresolved variables with
// the same name because they may be removed selectively via // the same name because they may be removed selectively via
// RemoveUnresolved(). // RemoveUnresolved().
......
...@@ -1550,7 +1550,7 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier, ...@@ -1550,7 +1550,7 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier,
case Token::THIS: { case Token::THIS: {
BindingPatternUnexpectedToken(classifier); BindingPatternUnexpectedToken(classifier);
Consume(Token::THIS); Consume(Token::THIS);
return this->ThisExpression(factory(), beg_pos); return this->ThisExpression(beg_pos);
} }
case Token::NULL_LITERAL: case Token::NULL_LITERAL:
...@@ -1582,8 +1582,8 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier, ...@@ -1582,8 +1582,8 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier,
case Token::FUTURE_STRICT_RESERVED_WORD: { case Token::FUTURE_STRICT_RESERVED_WORD: {
// Using eval or arguments in this context is OK even in strict mode. // Using eval or arguments in this context is OK even in strict mode.
IdentifierT name = ParseAndClassifyIdentifier(classifier, CHECK_OK); IdentifierT name = ParseAndClassifyIdentifier(classifier, CHECK_OK);
return this->ExpressionFromIdentifier( return this->ExpressionFromIdentifier(name, beg_pos,
name, beg_pos, scanner()->location().end_pos, factory()); scanner()->location().end_pos);
} }
case Token::STRING: { case Token::STRING: {
...@@ -2007,8 +2007,8 @@ ParserBase<Traits>::ParsePropertyDefinition( ...@@ -2007,8 +2007,8 @@ ParserBase<Traits>::ParsePropertyDefinition(
MessageTemplate::kAwaitBindingIdentifier); MessageTemplate::kAwaitBindingIdentifier);
} }
} }
ExpressionT lhs = this->ExpressionFromIdentifier(*name, next_beg_pos, ExpressionT lhs =
next_end_pos, factory()); this->ExpressionFromIdentifier(*name, next_beg_pos, next_end_pos);
CheckDestructuringElement(lhs, classifier, next_beg_pos, next_end_pos); CheckDestructuringElement(lhs, classifier, next_beg_pos, next_end_pos);
ExpressionT value; ExpressionT value;
...@@ -2317,8 +2317,8 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, ...@@ -2317,8 +2317,8 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN,
// async Identifier => AsyncConciseBody // async Identifier => AsyncConciseBody
IdentifierT name = IdentifierT name =
ParseAndClassifyIdentifier(&arrow_formals_classifier, CHECK_OK); ParseAndClassifyIdentifier(&arrow_formals_classifier, CHECK_OK);
expression = this->ExpressionFromIdentifier( expression = this->ExpressionFromIdentifier(name, position(),
name, position(), scanner()->location().end_pos, factory()); scanner()->location().end_pos);
} }
if (peek() == Token::ARROW) { if (peek() == Token::ARROW) {
...@@ -2762,8 +2762,8 @@ ParserBase<Traits>::ParseUnaryExpression(ExpressionClassifier* classifier, ...@@ -2762,8 +2762,8 @@ ParserBase<Traits>::ParseUnaryExpression(ExpressionClassifier* classifier,
Scanner::Location(beg_pos, scanner()->location().end_pos), Scanner::Location(beg_pos, scanner()->location().end_pos),
MessageTemplate::kAwaitBindingIdentifier); MessageTemplate::kAwaitBindingIdentifier);
return this->ExpressionFromIdentifier( return this->ExpressionFromIdentifier(name, beg_pos,
name, beg_pos, scanner()->location().end_pos, factory()); scanner()->location().end_pos);
} }
default: default:
break; break;
...@@ -2921,7 +2921,7 @@ ParserBase<Traits>::ParseLeftHandSideExpression( ...@@ -2921,7 +2921,7 @@ ParserBase<Traits>::ParseLeftHandSideExpression(
// Explicit calls to the super constructor using super() perform an // Explicit calls to the super constructor using super() perform an
// implicit binding assignment to the 'this' variable. // implicit binding assignment to the 'this' variable.
if (is_super_call) { if (is_super_call) {
ExpressionT this_expr = this->ThisExpression(factory(), pos); ExpressionT this_expr = this->ThisExpression(pos);
result = result =
factory()->NewAssignment(Token::INIT, this_expr, result, pos); factory()->NewAssignment(Token::INIT, this_expr, result, pos);
} }
...@@ -3148,7 +3148,7 @@ ParserBase<Traits>::ParseNewTargetExpression(bool* ok) { ...@@ -3148,7 +3148,7 @@ ParserBase<Traits>::ParseNewTargetExpression(bool* ok) {
return this->EmptyExpression(); return this->EmptyExpression();
} }
return this->NewTargetExpression(factory(), pos); return this->NewTargetExpression(pos);
} }
template <class Traits> template <class Traits>
......
...@@ -275,9 +275,8 @@ FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name, ...@@ -275,9 +275,8 @@ FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name,
ZoneList<Expression*>* args = ZoneList<Expression*>* args =
new (zone()) ZoneList<Expression*>(2, zone()); new (zone()) ZoneList<Expression*>(2, zone());
VariableProxy* this_function_proxy = this->scope()->NewUnresolved( VariableProxy* this_function_proxy =
factory(), ast_value_factory()->this_function_string(), NewUnresolved(ast_value_factory()->this_function_string(), pos);
Variable::NORMAL, pos);
ZoneList<Expression*>* tmp = ZoneList<Expression*>* tmp =
new (zone()) ZoneList<Expression*>(1, zone()); new (zone()) ZoneList<Expression*>(1, zone());
tmp->Add(this_function_proxy, zone()); tmp->Add(this_function_proxy, zone());
...@@ -290,9 +289,8 @@ FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name, ...@@ -290,9 +289,8 @@ FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name,
new (zone()) ZoneList<Expression*>(1, zone()); new (zone()) ZoneList<Expression*>(1, zone());
spread_args_expr->Add(spread_args, zone()); spread_args_expr->Add(spread_args, zone());
args->AddAll(*PrepareSpreadArguments(spread_args_expr), zone()); args->AddAll(*PrepareSpreadArguments(spread_args_expr), zone());
VariableProxy* new_target_proxy = this->scope()->NewUnresolved( VariableProxy* new_target_proxy =
factory(), ast_value_factory()->new_target_string(), Variable::NORMAL, NewUnresolved(ast_value_factory()->new_target_string(), pos);
pos);
args->Add(new_target_proxy, zone()); args->Add(new_target_proxy, zone());
CallRuntime* call = factory()->NewCallRuntime( CallRuntime* call = factory()->NewCallRuntime(
Context::REFLECT_CONSTRUCT_INDEX, args, pos); Context::REFLECT_CONSTRUCT_INDEX, args, pos);
...@@ -690,45 +688,40 @@ const AstRawString* ParserTraits::GetNextSymbol(Scanner* scanner) { ...@@ -690,45 +688,40 @@ const AstRawString* ParserTraits::GetNextSymbol(Scanner* scanner) {
return parser_->scanner()->NextSymbol(parser_->ast_value_factory()); return parser_->scanner()->NextSymbol(parser_->ast_value_factory());
} }
Expression* ParserTraits::ThisExpression(AstNodeFactory* factory, int pos) { Expression* ParserTraits::ThisExpression(int pos) {
return parser_->scope()->NewUnresolved( return parser_->NewUnresolved(parser_->ast_value_factory()->this_string(),
factory, parser_->ast_value_factory()->this_string(), Variable::THIS, pos, pos, pos + 4, Variable::THIS);
pos + 4);
} }
Expression* ParserTraits::NewSuperPropertyReference(AstNodeFactory* factory, Expression* ParserTraits::NewSuperPropertyReference(AstNodeFactory* factory,
int pos) { int pos) {
// this_function[home_object_symbol] // this_function[home_object_symbol]
VariableProxy* this_function_proxy = parser_->scope()->NewUnresolved( VariableProxy* this_function_proxy = parser_->NewUnresolved(
factory, parser_->ast_value_factory()->this_function_string(), parser_->ast_value_factory()->this_function_string(), pos);
Variable::NORMAL, pos);
Expression* home_object_symbol_literal = Expression* home_object_symbol_literal =
factory->NewSymbolLiteral("home_object_symbol", kNoSourcePosition); factory->NewSymbolLiteral("home_object_symbol", kNoSourcePosition);
Expression* home_object = factory->NewProperty( Expression* home_object = factory->NewProperty(
this_function_proxy, home_object_symbol_literal, pos); this_function_proxy, home_object_symbol_literal, pos);
return factory->NewSuperPropertyReference( return factory->NewSuperPropertyReference(
ThisExpression(factory, pos)->AsVariableProxy(), home_object, pos); ThisExpression(pos)->AsVariableProxy(), home_object, pos);
} }
Expression* ParserTraits::NewSuperCallReference(AstNodeFactory* factory, Expression* ParserTraits::NewSuperCallReference(AstNodeFactory* factory,
int pos) { int pos) {
VariableProxy* new_target_proxy = parser_->scope()->NewUnresolved( VariableProxy* new_target_proxy = parser_->NewUnresolved(
factory, parser_->ast_value_factory()->new_target_string(), parser_->ast_value_factory()->new_target_string(), pos);
Variable::NORMAL, pos); VariableProxy* this_function_proxy = parser_->NewUnresolved(
VariableProxy* this_function_proxy = parser_->scope()->NewUnresolved( parser_->ast_value_factory()->this_function_string(), pos);
factory, parser_->ast_value_factory()->this_function_string(), return factory->NewSuperCallReference(ThisExpression(pos)->AsVariableProxy(),
Variable::NORMAL, pos); new_target_proxy, this_function_proxy,
return factory->NewSuperCallReference( pos);
ThisExpression(factory, pos)->AsVariableProxy(), new_target_proxy, }
this_function_proxy, pos);
} Expression* ParserTraits::NewTargetExpression(int pos) {
Expression* ParserTraits::NewTargetExpression(AstNodeFactory* factory,
int pos) {
static const int kNewTargetStringLength = 10; static const int kNewTargetStringLength = 10;
auto proxy = parser_->scope()->NewUnresolved( auto proxy =
factory, parser_->ast_value_factory()->new_target_string(), parser_->NewUnresolved(parser_->ast_value_factory()->new_target_string(),
Variable::NORMAL, pos, pos + kNewTargetStringLength); pos, pos + kNewTargetStringLength);
proxy->set_is_new_target(); proxy->set_is_new_target();
return proxy; return proxy;
} }
...@@ -771,14 +764,11 @@ Literal* ParserTraits::ExpressionFromLiteral(Token::Value token, int pos, ...@@ -771,14 +764,11 @@ Literal* ParserTraits::ExpressionFromLiteral(Token::Value token, int pos,
return NULL; return NULL;
} }
Expression* ParserTraits::ExpressionFromIdentifier(const AstRawString* name, Expression* ParserTraits::ExpressionFromIdentifier(const AstRawString* name,
int start_position, int start_position,
int end_position, int end_position) {
AstNodeFactory* factory) {
if (parser_->fni_ != NULL) parser_->fni_->PushVariableName(name); if (parser_->fni_ != NULL) parser_->fni_->PushVariableName(name);
return parser_->scope()->NewUnresolved(factory, name, Variable::NORMAL, return parser_->NewUnresolved(name, start_position, end_position);
start_position, end_position);
} }
...@@ -1949,18 +1939,14 @@ Statement* Parser::ParseStatementAsUnlabelled( ...@@ -1949,18 +1939,14 @@ Statement* Parser::ParseStatementAsUnlabelled(
} }
} }
VariableProxy* Parser::NewUnresolved(const AstRawString* name, int begin_pos,
int end_pos, Variable::Kind kind) {
return scope()->NewUnresolved(factory(), name, begin_pos, end_pos, kind);
}
VariableProxy* Parser::NewUnresolved(const AstRawString* name, VariableProxy* Parser::NewUnresolved(const AstRawString* name) {
VariableMode mode) { return scope()->NewUnresolved(factory(), name, scanner()->location().beg_pos,
// If we are inside a function, a declaration of a 'var' variable is a scanner()->location().end_pos);
// truly local variable, and the scope of the variable is always the function
// scope.
// Let/const variables are always added to the immediately enclosing scope.
Scope* scope =
IsLexicalVariableMode(mode) ? this->scope() : GetDeclarationScope();
return scope->NewUnresolved(factory(), name, Variable::NORMAL,
scanner()->location().beg_pos,
scanner()->location().end_pos);
} }
InitializationFlag Parser::DefaultInitializationFlag(VariableMode mode) { InitializationFlag Parser::DefaultInitializationFlag(VariableMode mode) {
...@@ -1977,9 +1963,13 @@ Declaration* Parser::DeclareVariable(const AstRawString* name, ...@@ -1977,9 +1963,13 @@ Declaration* Parser::DeclareVariable(const AstRawString* name,
VariableMode mode, InitializationFlag init, VariableMode mode, InitializationFlag init,
int pos, bool* ok) { int pos, bool* ok) {
DCHECK_NOT_NULL(name); DCHECK_NOT_NULL(name);
VariableProxy* proxy = NewUnresolved(name, mode); Scope* scope =
IsLexicalVariableMode(mode) ? this->scope() : GetDeclarationScope();
VariableProxy* proxy =
scope->NewUnresolved(factory(), name, scanner()->location().beg_pos,
scanner()->location().end_pos);
Declaration* declaration = Declaration* declaration =
factory()->NewVariableDeclaration(proxy, scope(), pos); factory()->NewVariableDeclaration(proxy, this->scope(), pos);
Declare(declaration, DeclarationDescriptor::NORMAL, mode, init, CHECK_OK); Declare(declaration, DeclarationDescriptor::NORMAL, mode, init, CHECK_OK);
return declaration; return declaration;
} }
...@@ -2212,7 +2202,7 @@ Statement* Parser::ParseHoistableDeclaration( ...@@ -2212,7 +2202,7 @@ Statement* Parser::ParseHoistableDeclaration(
VariableMode mode = VariableMode mode =
(!scope()->is_declaration_scope() || scope()->is_module_scope()) ? LET (!scope()->is_declaration_scope() || scope()->is_module_scope()) ? LET
: VAR; : VAR;
VariableProxy* proxy = NewUnresolved(variable_name, mode); VariableProxy* proxy = NewUnresolved(variable_name);
Declaration* declaration = Declaration* declaration =
factory()->NewFunctionDeclaration(proxy, fun, scope(), pos); factory()->NewFunctionDeclaration(proxy, fun, scope(), pos);
Declare(declaration, DeclarationDescriptor::NORMAL, mode, kCreatedInitialized, Declare(declaration, DeclarationDescriptor::NORMAL, mode, kCreatedInitialized,
...@@ -2720,7 +2710,7 @@ Statement* Parser::ParseReturnStatement(bool* ok) { ...@@ -2720,7 +2710,7 @@ Statement* Parser::ParseReturnStatement(bool* ok) {
tok == Token::RBRACE || tok == Token::RBRACE ||
tok == Token::EOS) { tok == Token::EOS) {
if (IsSubclassConstructor(function_state_->kind())) { if (IsSubclassConstructor(function_state_->kind())) {
return_value = ThisExpression(factory(), loc.beg_pos); return_value = ThisExpression(loc.beg_pos);
} else { } else {
return_value = GetLiteralUndefined(position()); return_value = GetLiteralUndefined(position());
} }
...@@ -2767,9 +2757,8 @@ Statement* Parser::ParseReturnStatement(bool* ok) { ...@@ -2767,9 +2757,8 @@ Statement* Parser::ParseReturnStatement(bool* ok) {
factory()->NewUndefinedLiteral(kNoSourcePosition), pos); factory()->NewUndefinedLiteral(kNoSourcePosition), pos);
// is_undefined ? this : is_object_conditional // is_undefined ? this : is_object_conditional
return_value = factory()->NewConditional(is_undefined, return_value = factory()->NewConditional(
ThisExpression(factory(), pos), is_undefined, ThisExpression(pos), is_object_conditional, pos);
is_object_conditional, pos);
} else { } else {
ReturnExprScope maybe_allow_tail_calls( ReturnExprScope maybe_allow_tail_calls(
function_state_, ReturnExprContext::kInsideValidReturnStatement); function_state_, ReturnExprContext::kInsideValidReturnStatement);
...@@ -3448,7 +3437,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement( ...@@ -3448,7 +3437,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
// For each lexical variable x: // For each lexical variable x:
// make statement: temp_x = x. // make statement: temp_x = x.
for (int i = 0; i < names->length(); i++) { for (int i = 0; i < names->length(); i++) {
VariableProxy* proxy = NewUnresolved(names->at(i), LET); VariableProxy* proxy = NewUnresolved(names->at(i));
Variable* temp = NewTemporary(temp_name); Variable* temp = NewTemporary(temp_name);
VariableProxy* temp_proxy = factory()->NewVariableProxy(temp); VariableProxy* temp_proxy = factory()->NewVariableProxy(temp);
Assignment* assignment = factory()->NewAssignment(Token::ASSIGN, temp_proxy, Assignment* assignment = factory()->NewAssignment(Token::ASSIGN, temp_proxy,
...@@ -3719,7 +3708,7 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels, ...@@ -3719,7 +3708,7 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
++use_counts_[v8::Isolate::kForInInitializer]; ++use_counts_[v8::Isolate::kForInInitializer];
const AstRawString* name = const AstRawString* name =
decl.pattern->AsVariableProxy()->raw_name(); decl.pattern->AsVariableProxy()->raw_name();
VariableProxy* single_var = NewUnresolved(name, VAR); VariableProxy* single_var = NewUnresolved(name);
init_block = factory()->NewBlock( init_block = factory()->NewBlock(
nullptr, 2, true, parsing_result.descriptor.declaration_pos); nullptr, 2, true, parsing_result.descriptor.declaration_pos);
init_block->statements()->Add( init_block->statements()->Add(
...@@ -4762,9 +4751,8 @@ Expression* Parser::BuildCreateJSGeneratorObject(int pos, FunctionKind kind) { ...@@ -4762,9 +4751,8 @@ Expression* Parser::BuildCreateJSGeneratorObject(int pos, FunctionKind kind) {
DCHECK_NOT_NULL(function_state_->generator_object_variable()); DCHECK_NOT_NULL(function_state_->generator_object_variable());
ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone()); ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone());
args->Add(factory()->NewThisFunction(pos), zone()); args->Add(factory()->NewThisFunction(pos), zone());
args->Add(IsArrowFunction(kind) args->Add(IsArrowFunction(kind) ? GetLiteralUndefined(pos)
? GetLiteralUndefined(pos) : ThisExpression(kNoSourcePosition),
: ThisExpression(factory(), kNoSourcePosition),
zone()); zone());
return factory()->NewCallRuntime(Runtime::kCreateJSGeneratorObject, args, return factory()->NewCallRuntime(Runtime::kCreateJSGeneratorObject, args,
pos); pos);
...@@ -4885,8 +4873,7 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody( ...@@ -4885,8 +4873,7 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
if (IsSubclassConstructor(kind)) { if (IsSubclassConstructor(kind)) {
body->Add(factory()->NewReturnStatement( body->Add(factory()->NewReturnStatement(
this->ThisExpression(factory(), kNoSourcePosition), this->ThisExpression(kNoSourcePosition), kNoSourcePosition),
kNoSourcePosition),
zone()); zone());
} }
} }
...@@ -5009,7 +4996,7 @@ Expression* Parser::ParseClassLiteral(ExpressionClassifier* classifier, ...@@ -5009,7 +4996,7 @@ Expression* Parser::ParseClassLiteral(ExpressionClassifier* classifier,
VariableProxy* proxy = nullptr; VariableProxy* proxy = nullptr;
if (name != nullptr) { if (name != nullptr) {
proxy = NewUnresolved(name, CONST); proxy = NewUnresolved(name);
// TODO(verwaest): declare via block_state. // TODO(verwaest): declare via block_state.
Declaration* declaration = Declaration* declaration =
factory()->NewVariableDeclaration(proxy, block_state.scope(), pos); factory()->NewVariableDeclaration(proxy, block_state.scope(), pos);
...@@ -5213,7 +5200,7 @@ void Parser::InsertShadowingVarBindingInitializers(Block* inner_block) { ...@@ -5213,7 +5200,7 @@ void Parser::InsertShadowingVarBindingInitializers(Block* inner_block) {
const AstRawString* name = decl->proxy()->raw_name(); const AstRawString* name = decl->proxy()->raw_name();
Variable* parameter = function_scope->LookupLocal(name); Variable* parameter = function_scope->LookupLocal(name);
if (parameter == nullptr) continue; if (parameter == nullptr) continue;
VariableProxy* to = NewUnresolved(name, VAR); VariableProxy* to = NewUnresolved(name);
VariableProxy* from = factory()->NewVariableProxy(parameter); VariableProxy* from = factory()->NewVariableProxy(parameter);
Expression* assignment = Expression* assignment =
factory()->NewAssignment(Token::ASSIGN, to, from, kNoSourcePosition); factory()->NewAssignment(Token::ASSIGN, to, from, kNoSourcePosition);
...@@ -5694,7 +5681,7 @@ Expression* Parser::SpreadCall(Expression* function, ...@@ -5694,7 +5681,7 @@ Expression* Parser::SpreadCall(Expression* function,
if (function->IsProperty()) { if (function->IsProperty()) {
// Method calls // Method calls
if (function->AsProperty()->IsSuperAccess()) { if (function->AsProperty()->IsSuperAccess()) {
Expression* home = ThisExpression(factory(), kNoSourcePosition); Expression* home = ThisExpression(kNoSourcePosition);
args->InsertAt(0, function, zone()); args->InsertAt(0, function, zone());
args->InsertAt(1, home, zone()); args->InsertAt(1, home, zone());
} else { } else {
...@@ -5935,7 +5922,7 @@ Expression* Parser::RewriteAssignExponentiation(Expression* left, ...@@ -5935,7 +5922,7 @@ Expression* Parser::RewriteAssignExponentiation(Expression* left,
Expression* result; Expression* result;
DCHECK_NOT_NULL(lhs->raw_name()); DCHECK_NOT_NULL(lhs->raw_name());
result = this->ExpressionFromIdentifier(lhs->raw_name(), lhs->position(), result = this->ExpressionFromIdentifier(lhs->raw_name(), lhs->position(),
lhs->end_position(), factory()); lhs->end_position());
args->Add(left, zone()); args->Add(left, zone());
args->Add(right, zone()); args->Add(right, zone());
Expression* call = Expression* call =
......
...@@ -549,17 +549,15 @@ class ParserTraits { ...@@ -549,17 +549,15 @@ class ParserTraits {
const AstRawString* GetNextSymbol(Scanner* scanner); const AstRawString* GetNextSymbol(Scanner* scanner);
const AstRawString* GetNumberAsSymbol(Scanner* scanner); const AstRawString* GetNumberAsSymbol(Scanner* scanner);
Expression* ThisExpression(AstNodeFactory* factory, Expression* ThisExpression(int pos);
int pos = kNoSourcePosition);
Expression* NewSuperPropertyReference(AstNodeFactory* factory, int pos); Expression* NewSuperPropertyReference(AstNodeFactory* factory, int pos);
Expression* NewSuperCallReference(AstNodeFactory* factory, int pos); Expression* NewSuperCallReference(AstNodeFactory* factory, int pos);
Expression* NewTargetExpression(AstNodeFactory* factory, int pos); Expression* NewTargetExpression(int pos);
Expression* FunctionSentExpression(AstNodeFactory* factory, int pos); Expression* FunctionSentExpression(AstNodeFactory* factory, int pos);
Literal* ExpressionFromLiteral(Token::Value token, int pos, Scanner* scanner, Literal* ExpressionFromLiteral(Token::Value token, int pos, Scanner* scanner,
AstNodeFactory* factory); AstNodeFactory* factory);
Expression* ExpressionFromIdentifier(const AstRawString* name, Expression* ExpressionFromIdentifier(const AstRawString* name,
int start_position, int end_position, int start_position, int end_position);
AstNodeFactory* factory);
Expression* ExpressionFromString(int pos, Scanner* scanner, Expression* ExpressionFromString(int pos, Scanner* scanner,
AstNodeFactory* factory); AstNodeFactory* factory);
Expression* GetIterator(Expression* iterable, AstNodeFactory* factory, Expression* GetIterator(Expression* iterable, AstNodeFactory* factory,
...@@ -1086,7 +1084,10 @@ class Parser : public ParserBase<ParserTraits> { ...@@ -1086,7 +1084,10 @@ class Parser : public ParserBase<ParserTraits> {
bool* ok); bool* ok);
static InitializationFlag DefaultInitializationFlag(VariableMode mode); static InitializationFlag DefaultInitializationFlag(VariableMode mode);
VariableProxy* NewUnresolved(const AstRawString* name, VariableMode mode); VariableProxy* NewUnresolved(const AstRawString* name, int begin_pos,
int end_pos = kNoSourcePosition,
Variable::Kind kind = Variable::NORMAL);
VariableProxy* NewUnresolved(const AstRawString* name);
Variable* Declare(Declaration* declaration, Variable* Declare(Declaration* declaration,
DeclarationDescriptor::Kind declaration_kind, DeclarationDescriptor::Kind declaration_kind,
VariableMode mode, InitializationFlag init, bool* ok, VariableMode mode, InitializationFlag init, bool* ok,
......
...@@ -147,7 +147,9 @@ void Parser::PatternRewriter::VisitVariableProxy(VariableProxy* pattern) { ...@@ -147,7 +147,9 @@ void Parser::PatternRewriter::VisitVariableProxy(VariableProxy* pattern) {
// pre-resolve the proxy because it resides in the same scope as the // pre-resolve the proxy because it resides in the same scope as the
// declaration. // declaration.
const AstRawString* name = pattern->raw_name(); const AstRawString* name = pattern->raw_name();
VariableProxy* proxy = parser_->NewUnresolved(name, descriptor_->mode); VariableProxy* proxy = descriptor_->scope->NewUnresolved(
factory(), name, parser_->scanner()->location().beg_pos,
parser_->scanner()->location().end_pos);
Declaration* declaration = factory()->NewVariableDeclaration( Declaration* declaration = factory()->NewVariableDeclaration(
proxy, descriptor_->scope, descriptor_->declaration_pos); proxy, descriptor_->scope, descriptor_->declaration_pos);
Variable* var = parser_->Declare(declaration, descriptor_->declaration_kind, Variable* var = parser_->Declare(declaration, descriptor_->declaration_kind,
......
...@@ -801,8 +801,7 @@ class PreParserTraits { ...@@ -801,8 +801,7 @@ class PreParserTraits {
return PreParserIdentifier::Default(); return PreParserIdentifier::Default();
} }
static PreParserExpression ThisExpression(PreParserFactory* factory, static PreParserExpression ThisExpression(int pos) {
int pos) {
return PreParserExpression::This(); return PreParserExpression::This();
} }
...@@ -816,8 +815,7 @@ class PreParserTraits { ...@@ -816,8 +815,7 @@ class PreParserTraits {
return PreParserExpression::SuperCallReference(); return PreParserExpression::SuperCallReference();
} }
static PreParserExpression NewTargetExpression(PreParserFactory* factory, static PreParserExpression NewTargetExpression(int pos) {
int pos) {
return PreParserExpression::Default(); return PreParserExpression::Default();
} }
...@@ -832,9 +830,9 @@ class PreParserTraits { ...@@ -832,9 +830,9 @@ class PreParserTraits {
return PreParserExpression::Default(); return PreParserExpression::Default();
} }
static PreParserExpression ExpressionFromIdentifier( static PreParserExpression ExpressionFromIdentifier(PreParserIdentifier name,
PreParserIdentifier name, int start_position, int end_position, int start_position,
PreParserFactory* factory) { int end_position) {
return PreParserExpression::FromIdentifier(name); return PreParserExpression::FromIdentifier(name);
} }
......
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