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>
......
This diff is collapsed.
...@@ -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