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 {
// Create a new unresolved variable.
VariableProxy* NewUnresolved(AstNodeFactory* factory,
const AstRawString* name,
Variable::Kind kind = Variable::NORMAL,
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
// the same name because they may be removed selectively via
// RemoveUnresolved().
......
......@@ -1550,7 +1550,7 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier,
case Token::THIS: {
BindingPatternUnexpectedToken(classifier);
Consume(Token::THIS);
return this->ThisExpression(factory(), beg_pos);
return this->ThisExpression(beg_pos);
}
case Token::NULL_LITERAL:
......@@ -1582,8 +1582,8 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier,
case Token::FUTURE_STRICT_RESERVED_WORD: {
// Using eval or arguments in this context is OK even in strict mode.
IdentifierT name = ParseAndClassifyIdentifier(classifier, CHECK_OK);
return this->ExpressionFromIdentifier(
name, beg_pos, scanner()->location().end_pos, factory());
return this->ExpressionFromIdentifier(name, beg_pos,
scanner()->location().end_pos);
}
case Token::STRING: {
......@@ -2007,8 +2007,8 @@ ParserBase<Traits>::ParsePropertyDefinition(
MessageTemplate::kAwaitBindingIdentifier);
}
}
ExpressionT lhs = this->ExpressionFromIdentifier(*name, next_beg_pos,
next_end_pos, factory());
ExpressionT lhs =
this->ExpressionFromIdentifier(*name, next_beg_pos, next_end_pos);
CheckDestructuringElement(lhs, classifier, next_beg_pos, next_end_pos);
ExpressionT value;
......@@ -2317,8 +2317,8 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN,
// async Identifier => AsyncConciseBody
IdentifierT name =
ParseAndClassifyIdentifier(&arrow_formals_classifier, CHECK_OK);
expression = this->ExpressionFromIdentifier(
name, position(), scanner()->location().end_pos, factory());
expression = this->ExpressionFromIdentifier(name, position(),
scanner()->location().end_pos);
}
if (peek() == Token::ARROW) {
......@@ -2762,8 +2762,8 @@ ParserBase<Traits>::ParseUnaryExpression(ExpressionClassifier* classifier,
Scanner::Location(beg_pos, scanner()->location().end_pos),
MessageTemplate::kAwaitBindingIdentifier);
return this->ExpressionFromIdentifier(
name, beg_pos, scanner()->location().end_pos, factory());
return this->ExpressionFromIdentifier(name, beg_pos,
scanner()->location().end_pos);
}
default:
break;
......@@ -2921,7 +2921,7 @@ ParserBase<Traits>::ParseLeftHandSideExpression(
// Explicit calls to the super constructor using super() perform an
// implicit binding assignment to the 'this' variable.
if (is_super_call) {
ExpressionT this_expr = this->ThisExpression(factory(), pos);
ExpressionT this_expr = this->ThisExpression(pos);
result =
factory()->NewAssignment(Token::INIT, this_expr, result, pos);
}
......@@ -3148,7 +3148,7 @@ ParserBase<Traits>::ParseNewTargetExpression(bool* ok) {
return this->EmptyExpression();
}
return this->NewTargetExpression(factory(), pos);
return this->NewTargetExpression(pos);
}
template <class Traits>
......
This diff is collapsed.
......@@ -549,17 +549,15 @@ class ParserTraits {
const AstRawString* GetNextSymbol(Scanner* scanner);
const AstRawString* GetNumberAsSymbol(Scanner* scanner);
Expression* ThisExpression(AstNodeFactory* factory,
int pos = kNoSourcePosition);
Expression* ThisExpression(int pos);
Expression* NewSuperPropertyReference(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);
Literal* ExpressionFromLiteral(Token::Value token, int pos, Scanner* scanner,
AstNodeFactory* factory);
Expression* ExpressionFromIdentifier(const AstRawString* name,
int start_position, int end_position,
AstNodeFactory* factory);
int start_position, int end_position);
Expression* ExpressionFromString(int pos, Scanner* scanner,
AstNodeFactory* factory);
Expression* GetIterator(Expression* iterable, AstNodeFactory* factory,
......@@ -1086,7 +1084,10 @@ class Parser : public ParserBase<ParserTraits> {
bool* ok);
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,
DeclarationDescriptor::Kind declaration_kind,
VariableMode mode, InitializationFlag init, bool* ok,
......
......@@ -147,7 +147,9 @@ void Parser::PatternRewriter::VisitVariableProxy(VariableProxy* pattern) {
// pre-resolve the proxy because it resides in the same scope as the
// declaration.
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(
proxy, descriptor_->scope, descriptor_->declaration_pos);
Variable* var = parser_->Declare(declaration, descriptor_->declaration_kind,
......
......@@ -801,8 +801,7 @@ class PreParserTraits {
return PreParserIdentifier::Default();
}
static PreParserExpression ThisExpression(PreParserFactory* factory,
int pos) {
static PreParserExpression ThisExpression(int pos) {
return PreParserExpression::This();
}
......@@ -816,8 +815,7 @@ class PreParserTraits {
return PreParserExpression::SuperCallReference();
}
static PreParserExpression NewTargetExpression(PreParserFactory* factory,
int pos) {
static PreParserExpression NewTargetExpression(int pos) {
return PreParserExpression::Default();
}
......@@ -832,9 +830,9 @@ class PreParserTraits {
return PreParserExpression::Default();
}
static PreParserExpression ExpressionFromIdentifier(
PreParserIdentifier name, int start_position, int end_position,
PreParserFactory* factory) {
static PreParserExpression ExpressionFromIdentifier(PreParserIdentifier name,
int start_position,
int end_position) {
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