Commit 6fe0b39b authored by nikolaos's avatar nikolaos Committed by Commit bot

[parser] Clean up (pre)parser traits

This patch removes 26 elements of the (pre)parser traits objects.
Some methods are removed completely and called directly from the
implementation objects:

- ParseAsyncFunctionExpression
- ParseClassLiteral
- ParseDoExpression
- ParseEagerFunctionBody
- ParseFunctionLiteral
- ParseV8Intrinsic

Some methods have to be moved to at least one implementation object:

- AddTemplateExpression
- AddTemplateSpan
- CheckConflictingVarDeclarations
- CloseTemplateLiteral
- MarkCollectedTailCallExpressions
- MarkTailPosition
- OpenTemplateLiteral
- ParseAsyncArrowSingleExpressionBody
- PrepareSpreadArguments
- QueueDestructuringAssignmentForRewriting
- QueueNonPatternForRewriting
- RewriteAssignExponentiation
- RewriteAwaitExpression
- RewriteDestructuringAssignments
- RewriteExponentiation
- RewriteNonPattern
- RewriteYieldStar
- SkipLazyFunctionBody
- SpreadCall
- SpreadCallNew

Also, the inner class/struct TemplateLiteralState is moved to the
implementation objects.

R=adamk@chromium.org, marja@chromium.org
BUG=
LOG=N

Review-Url: https://codereview.chromium.org/2267783002
Cr-Commit-Position: refs/heads/master@{#38837}
parent 9f4c8b74
...@@ -554,7 +554,7 @@ class ParserBase : public ParserBaseTraits<Impl> { ...@@ -554,7 +554,7 @@ class ParserBase : public ParserBaseTraits<Impl> {
// to this function. Filled in by constructor. // to this function. Filled in by constructor.
bool this_function_is_parenthesized_; bool this_function_is_parenthesized_;
friend class ParserBaseTraits<Impl>; friend Impl;
friend class Checkpoint; friend class Checkpoint;
}; };
...@@ -1157,7 +1157,6 @@ class ParserBase : public ParserBaseTraits<Impl> { ...@@ -1157,7 +1157,6 @@ class ParserBase : public ParserBaseTraits<Impl> {
bool* ok); bool* ok);
ExpressionT ParseTemplateLiteral(ExpressionT tag, int start, ExpressionT ParseTemplateLiteral(ExpressionT tag, int start,
ExpressionClassifier* classifier, bool* ok); ExpressionClassifier* classifier, bool* ok);
void AddTemplateExpression(ExpressionT);
ExpressionT ParseSuperExpression(bool is_new, bool* ok); ExpressionT ParseSuperExpression(bool is_new, bool* ok);
ExpressionT ParseNewTargetExpression(bool* ok); ExpressionT ParseNewTargetExpression(bool* ok);
...@@ -1597,7 +1596,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePrimaryExpression( ...@@ -1597,7 +1596,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePrimaryExpression(
!scanner()->HasAnyLineTerminatorAfterNext() && !scanner()->HasAnyLineTerminatorAfterNext() &&
PeekAhead() == Token::FUNCTION) { PeekAhead() == Token::FUNCTION) {
Consume(Token::ASYNC); Consume(Token::ASYNC);
return this->ParseAsyncFunctionExpression(CHECK_OK); return impl()->ParseAsyncFunctionExpression(CHECK_OK);
} }
// CoverCallExpressionAndAsyncArrowHead // CoverCallExpressionAndAsyncArrowHead
*is_async = true; *is_async = true;
...@@ -1701,7 +1700,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePrimaryExpression( ...@@ -1701,7 +1700,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePrimaryExpression(
CHECK_OK); CHECK_OK);
class_name_location = scanner()->location(); class_name_location = scanner()->location();
} }
return this->ParseClassLiteral(classifier, name, class_name_location, return impl()->ParseClassLiteral(classifier, name, class_name_location,
is_strict_reserved_name, is_strict_reserved_name,
class_token_position, ok); class_token_position, ok);
} }
...@@ -1715,14 +1714,14 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePrimaryExpression( ...@@ -1715,14 +1714,14 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePrimaryExpression(
case Token::MOD: case Token::MOD:
if (allow_natives() || extension_ != NULL) { if (allow_natives() || extension_ != NULL) {
BindingPatternUnexpectedToken(classifier); BindingPatternUnexpectedToken(classifier);
return this->ParseV8Intrinsic(ok); return impl()->ParseV8Intrinsic(ok);
} }
break; break;
case Token::DO: case Token::DO:
if (allow_harmony_do_expressions()) { if (allow_harmony_do_expressions()) {
BindingPatternUnexpectedToken(classifier); BindingPatternUnexpectedToken(classifier);
return Traits::ParseDoExpression(ok); return impl()->ParseDoExpression(ok);
} }
break; break;
...@@ -1740,7 +1739,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseExpression( ...@@ -1740,7 +1739,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseExpression(
bool accept_IN, bool* ok) { bool accept_IN, bool* ok) {
ExpressionClassifier classifier(this); ExpressionClassifier classifier(this);
ExpressionT result = ParseExpression(accept_IN, &classifier, CHECK_OK); ExpressionT result = ParseExpression(accept_IN, &classifier, CHECK_OK);
Traits::RewriteNonPattern(&classifier, CHECK_OK); impl()->RewriteNonPattern(&classifier, CHECK_OK);
return result; return result;
} }
...@@ -1872,7 +1871,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseArrayLiteral( ...@@ -1872,7 +1871,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseArrayLiteral(
literal_index, pos); literal_index, pos);
if (first_spread_index >= 0) { if (first_spread_index >= 0) {
result = factory()->NewRewritableExpression(result); result = factory()->NewRewritableExpression(result);
Traits::QueueNonPatternForRewriting(result, ok); impl()->QueueNonPatternForRewriting(result, ok);
if (!*ok) { if (!*ok) {
// If the non-pattern rewriting mechanism is used in the future for // If the non-pattern rewriting mechanism is used in the future for
// rewriting other things than spreads, this error message will have // rewriting other things than spreads, this error message will have
...@@ -1923,7 +1922,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePropertyName( ...@@ -1923,7 +1922,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePropertyName(
ExpressionClassifier computed_name_classifier(this); ExpressionClassifier computed_name_classifier(this);
ExpressionT expression = ExpressionT expression =
ParseAssignmentExpression(true, &computed_name_classifier, CHECK_OK); ParseAssignmentExpression(true, &computed_name_classifier, CHECK_OK);
Traits::RewriteNonPattern(&computed_name_classifier, CHECK_OK); impl()->RewriteNonPattern(&computed_name_classifier, CHECK_OK);
classifier->Accumulate(&computed_name_classifier, classifier->Accumulate(&computed_name_classifier,
ExpressionClassifier::ExpressionProductions); ExpressionClassifier::ExpressionProductions);
Expect(Token::RBRACK, CHECK_OK); Expect(Token::RBRACK, CHECK_OK);
...@@ -2037,7 +2036,7 @@ ParserBase<Impl>::ParsePropertyDefinition( ...@@ -2037,7 +2036,7 @@ ParserBase<Impl>::ParsePropertyDefinition(
ExpressionClassifier rhs_classifier(this); ExpressionClassifier rhs_classifier(this);
ExpressionT rhs = this->ParseAssignmentExpression( ExpressionT rhs = this->ParseAssignmentExpression(
true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
Traits::RewriteNonPattern(&rhs_classifier, impl()->RewriteNonPattern(&rhs_classifier,
CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
classifier->Accumulate(&rhs_classifier, classifier->Accumulate(&rhs_classifier,
ExpressionClassifier::ExpressionProductions); ExpressionClassifier::ExpressionProductions);
...@@ -2095,7 +2094,7 @@ ParserBase<Impl>::ParsePropertyDefinition( ...@@ -2095,7 +2094,7 @@ ParserBase<Impl>::ParsePropertyDefinition(
: FunctionKind::kBaseConstructor; : FunctionKind::kBaseConstructor;
} }
ExpressionT value = this->ParseFunctionLiteral( ExpressionT value = impl()->ParseFunctionLiteral(
*name, scanner()->location(), kSkipFunctionNameCheck, kind, *name, scanner()->location(), kSkipFunctionNameCheck, kind,
kNoSourcePosition, FunctionLiteral::kAccessorOrMethod, language_mode(), kNoSourcePosition, FunctionLiteral::kAccessorOrMethod, language_mode(),
CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
...@@ -2112,7 +2111,7 @@ ParserBase<Impl>::ParsePropertyDefinition( ...@@ -2112,7 +2111,7 @@ ParserBase<Impl>::ParsePropertyDefinition(
ObjectLiteralPropertyT property = ParsePropertyDefinition( ObjectLiteralPropertyT property = ParsePropertyDefinition(
checker, true, has_extends, MethodKind::kStatic, is_computed_name, checker, true, has_extends, MethodKind::kStatic, is_computed_name,
nullptr, classifier, name, ok); nullptr, classifier, name, ok);
Traits::RewriteNonPattern(classifier, ok); impl()->RewriteNonPattern(classifier, ok);
return property; return property;
} }
...@@ -2134,7 +2133,7 @@ ParserBase<Impl>::ParsePropertyDefinition( ...@@ -2134,7 +2133,7 @@ ParserBase<Impl>::ParsePropertyDefinition(
CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
} }
typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral( typename Traits::Type::FunctionLiteral value = impl()->ParseFunctionLiteral(
*name, scanner()->location(), kSkipFunctionNameCheck, *name, scanner()->location(), kSkipFunctionNameCheck,
is_get ? FunctionKind::kGetterFunction : FunctionKind::kSetterFunction, is_get ? FunctionKind::kGetterFunction : FunctionKind::kSetterFunction,
kNoSourcePosition, FunctionLiteral::kAccessorOrMethod, language_mode(), kNoSourcePosition, FunctionLiteral::kAccessorOrMethod, language_mode(),
...@@ -2240,7 +2239,7 @@ ParserBase<Impl>::ParseArguments(Scanner::Location* first_spread_arg_loc, ...@@ -2240,7 +2239,7 @@ ParserBase<Impl>::ParseArguments(Scanner::Location* first_spread_arg_loc,
true, classifier, CHECK_OK_CUSTOM(NullExpressionList)); true, classifier, CHECK_OK_CUSTOM(NullExpressionList));
CheckNoTailCallExpressions(classifier, CHECK_OK_CUSTOM(NullExpressionList)); CheckNoTailCallExpressions(classifier, CHECK_OK_CUSTOM(NullExpressionList));
if (!maybe_arrow) { if (!maybe_arrow) {
Traits::RewriteNonPattern(classifier, impl()->RewriteNonPattern(classifier,
CHECK_OK_CUSTOM(NullExpressionList)); CHECK_OK_CUSTOM(NullExpressionList));
} }
if (is_spread) { if (is_spread) {
...@@ -2285,7 +2284,7 @@ ParserBase<Impl>::ParseArguments(Scanner::Location* first_spread_arg_loc, ...@@ -2285,7 +2284,7 @@ ParserBase<Impl>::ParseArguments(Scanner::Location* first_spread_arg_loc,
if (!maybe_arrow || peek() != Token::ARROW) { if (!maybe_arrow || peek() != Token::ARROW) {
if (maybe_arrow) { if (maybe_arrow) {
Traits::RewriteNonPattern(classifier, impl()->RewriteNonPattern(classifier,
CHECK_OK_CUSTOM(NullExpressionList)); CHECK_OK_CUSTOM(NullExpressionList));
} }
if (spread_arg.IsValid()) { if (spread_arg.IsValid()) {
...@@ -2458,7 +2457,7 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN, ...@@ -2458,7 +2457,7 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN,
ExpressionT right = ExpressionT right =
this->ParseAssignmentExpression(accept_IN, &rhs_classifier, CHECK_OK); this->ParseAssignmentExpression(accept_IN, &rhs_classifier, CHECK_OK);
CheckNoTailCallExpressions(&rhs_classifier, CHECK_OK); CheckNoTailCallExpressions(&rhs_classifier, CHECK_OK);
Traits::RewriteNonPattern(&rhs_classifier, CHECK_OK); impl()->RewriteNonPattern(&rhs_classifier, CHECK_OK);
classifier->Accumulate( classifier->Accumulate(
&rhs_classifier, &rhs_classifier,
ExpressionClassifier::ExpressionProductions | ExpressionClassifier::ExpressionProductions |
...@@ -2494,14 +2493,14 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN, ...@@ -2494,14 +2493,14 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN,
if (op == Token::ASSIGN_EXP) { if (op == Token::ASSIGN_EXP) {
DCHECK(!is_destructuring_assignment); DCHECK(!is_destructuring_assignment);
return Traits::RewriteAssignExponentiation(expression, right, pos); return impl()->RewriteAssignExponentiation(expression, right, pos);
} }
ExpressionT result = factory()->NewAssignment(op, expression, right, pos); ExpressionT result = factory()->NewAssignment(op, expression, right, pos);
if (is_destructuring_assignment) { if (is_destructuring_assignment) {
result = factory()->NewRewritableExpression(result); result = factory()->NewRewritableExpression(result);
Traits::QueueDestructuringAssignmentForRewriting(result); impl()->QueueDestructuringAssignmentForRewriting(result);
} }
return result; return result;
...@@ -2541,13 +2540,13 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseYieldExpression( ...@@ -2541,13 +2540,13 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseYieldExpression(
// Delegating yields require an RHS; fall through. // Delegating yields require an RHS; fall through.
default: default:
expression = ParseAssignmentExpression(accept_IN, classifier, CHECK_OK); expression = ParseAssignmentExpression(accept_IN, classifier, CHECK_OK);
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
break; break;
} }
} }
if (delegating) { if (delegating) {
return Traits::RewriteYieldStar(generator_object, expression, pos); return impl()->RewriteYieldStar(generator_object, expression, pos);
} }
expression = Traits::BuildIteratorResult(expression, false); expression = Traits::BuildIteratorResult(expression, false);
...@@ -2636,7 +2635,7 @@ ParserBase<Impl>::ParseConditionalExpression(bool accept_IN, ...@@ -2636,7 +2635,7 @@ ParserBase<Impl>::ParseConditionalExpression(bool accept_IN,
this->ParseBinaryExpression(4, accept_IN, classifier, CHECK_OK); this->ParseBinaryExpression(4, accept_IN, classifier, CHECK_OK);
if (peek() != Token::CONDITIONAL) return expression; if (peek() != Token::CONDITIONAL) return expression;
CheckNoTailCallExpressions(classifier, CHECK_OK); CheckNoTailCallExpressions(classifier, CHECK_OK);
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
BindingPatternUnexpectedToken(classifier); BindingPatternUnexpectedToken(classifier);
ArrowFormalParametersUnexpectedToken(classifier); ArrowFormalParametersUnexpectedToken(classifier);
Consume(Token::CONDITIONAL); Consume(Token::CONDITIONAL);
...@@ -2644,11 +2643,11 @@ ParserBase<Impl>::ParseConditionalExpression(bool accept_IN, ...@@ -2644,11 +2643,11 @@ ParserBase<Impl>::ParseConditionalExpression(bool accept_IN,
// expressions we always accept the 'in' keyword; see ECMA-262, // expressions we always accept the 'in' keyword; see ECMA-262,
// section 11.12, page 58. // section 11.12, page 58.
ExpressionT left = ParseAssignmentExpression(true, classifier, CHECK_OK); ExpressionT left = ParseAssignmentExpression(true, classifier, CHECK_OK);
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
Expect(Token::COLON, CHECK_OK); Expect(Token::COLON, CHECK_OK);
ExpressionT right = ExpressionT right =
ParseAssignmentExpression(accept_IN, classifier, CHECK_OK); ParseAssignmentExpression(accept_IN, classifier, CHECK_OK);
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
return factory()->NewConditional(expression, left, right, pos); return factory()->NewConditional(expression, left, right, pos);
} }
...@@ -2663,7 +2662,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseBinaryExpression( ...@@ -2663,7 +2662,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseBinaryExpression(
// prec1 >= 4 // prec1 >= 4
while (Precedence(peek(), accept_IN) == prec1) { while (Precedence(peek(), accept_IN) == prec1) {
CheckNoTailCallExpressions(classifier, CHECK_OK); CheckNoTailCallExpressions(classifier, CHECK_OK);
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
BindingPatternUnexpectedToken(classifier); BindingPatternUnexpectedToken(classifier);
ArrowFormalParametersUnexpectedToken(classifier); ArrowFormalParametersUnexpectedToken(classifier);
Token::Value op = Next(); Token::Value op = Next();
...@@ -2676,7 +2675,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseBinaryExpression( ...@@ -2676,7 +2675,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseBinaryExpression(
if (op != Token::OR && op != Token::AND) { if (op != Token::OR && op != Token::AND) {
CheckNoTailCallExpressions(classifier, CHECK_OK); CheckNoTailCallExpressions(classifier, CHECK_OK);
} }
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
if (this->ShortcutNumericLiteralBinaryExpression(&x, y, op, pos, if (this->ShortcutNumericLiteralBinaryExpression(&x, y, op, pos,
factory())) { factory())) {
...@@ -2700,7 +2699,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseBinaryExpression( ...@@ -2700,7 +2699,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseBinaryExpression(
x = factory()->NewUnaryOperation(Token::NOT, x, pos); x = factory()->NewUnaryOperation(Token::NOT, x, pos);
} }
} else if (op == Token::EXP) { } else if (op == Token::EXP) {
x = Traits::RewriteExponentiation(x, y, pos); x = impl()->RewriteExponentiation(x, y, pos);
} else { } else {
// We have a "normal" binary operation. // We have a "normal" binary operation.
x = factory()->NewBinaryOperation(op, x, y, pos); x = factory()->NewBinaryOperation(op, x, y, pos);
...@@ -2735,7 +2734,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseUnaryExpression( ...@@ -2735,7 +2734,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseUnaryExpression(
int pos = position(); int pos = position();
ExpressionT expression = ParseUnaryExpression(classifier, CHECK_OK); ExpressionT expression = ParseUnaryExpression(classifier, CHECK_OK);
CheckNoTailCallExpressions(classifier, CHECK_OK); CheckNoTailCallExpressions(classifier, CHECK_OK);
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
if (op == Token::DELETE && is_strict(language_mode())) { if (op == Token::DELETE && is_strict(language_mode())) {
if (this->IsIdentifier(expression)) { if (this->IsIdentifier(expression)) {
...@@ -2765,7 +2764,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseUnaryExpression( ...@@ -2765,7 +2764,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseUnaryExpression(
expression, beg_pos, scanner()->location().end_pos, expression, beg_pos, scanner()->location().end_pos,
MessageTemplate::kInvalidLhsInPrefixOp, CHECK_OK); MessageTemplate::kInvalidLhsInPrefixOp, CHECK_OK);
this->MarkExpressionAsAssigned(expression); this->MarkExpressionAsAssigned(expression);
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
return factory()->NewCountOperation(op, return factory()->NewCountOperation(op,
true /* prefix */, true /* prefix */,
...@@ -2782,7 +2781,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseUnaryExpression( ...@@ -2782,7 +2781,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseUnaryExpression(
ExpressionT value = ParseUnaryExpression(classifier, CHECK_OK); ExpressionT value = ParseUnaryExpression(classifier, CHECK_OK);
return Traits::RewriteAwaitExpression(value, await_pos); return impl()->RewriteAwaitExpression(value, await_pos);
} else { } else {
return this->ParsePostfixExpression(classifier, ok); return this->ParsePostfixExpression(classifier, ok);
} }
...@@ -2807,7 +2806,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePostfixExpression( ...@@ -2807,7 +2806,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePostfixExpression(
expression, lhs_beg_pos, scanner()->location().end_pos, expression, lhs_beg_pos, scanner()->location().end_pos,
MessageTemplate::kInvalidLhsInPostfixOp, CHECK_OK); MessageTemplate::kInvalidLhsInPostfixOp, CHECK_OK);
expression = this->MarkExpressionAsAssigned(expression); expression = this->MarkExpressionAsAssigned(expression);
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
Token::Value next = Next(); Token::Value next = Next();
expression = expression =
...@@ -2838,13 +2837,13 @@ ParserBase<Impl>::ParseLeftHandSideExpression(ExpressionClassifier* classifier, ...@@ -2838,13 +2837,13 @@ ParserBase<Impl>::ParseLeftHandSideExpression(ExpressionClassifier* classifier,
switch (peek()) { switch (peek()) {
case Token::LBRACK: { case Token::LBRACK: {
CheckNoTailCallExpressions(classifier, CHECK_OK); CheckNoTailCallExpressions(classifier, CHECK_OK);
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
BindingPatternUnexpectedToken(classifier); BindingPatternUnexpectedToken(classifier);
ArrowFormalParametersUnexpectedToken(classifier); ArrowFormalParametersUnexpectedToken(classifier);
Consume(Token::LBRACK); Consume(Token::LBRACK);
int pos = position(); int pos = position();
ExpressionT index = ParseExpression(true, classifier, CHECK_OK); ExpressionT index = ParseExpression(true, classifier, CHECK_OK);
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
result = factory()->NewProperty(result, index, pos); result = factory()->NewProperty(result, index, pos);
Expect(Token::RBRACK, CHECK_OK); Expect(Token::RBRACK, CHECK_OK);
break; break;
...@@ -2853,7 +2852,7 @@ ParserBase<Impl>::ParseLeftHandSideExpression(ExpressionClassifier* classifier, ...@@ -2853,7 +2852,7 @@ ParserBase<Impl>::ParseLeftHandSideExpression(ExpressionClassifier* classifier,
case Token::LPAREN: { case Token::LPAREN: {
CheckNoTailCallExpressions(classifier, CHECK_OK); CheckNoTailCallExpressions(classifier, CHECK_OK);
int pos; int pos;
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
BindingPatternUnexpectedToken(classifier); BindingPatternUnexpectedToken(classifier);
if (scanner()->current_token() == Token::IDENTIFIER || if (scanner()->current_token() == Token::IDENTIFIER ||
scanner()->current_token() == Token::SUPER || scanner()->current_token() == Token::SUPER ||
...@@ -2919,8 +2918,8 @@ ParserBase<Impl>::ParseLeftHandSideExpression(ExpressionClassifier* classifier, ...@@ -2919,8 +2918,8 @@ ParserBase<Impl>::ParseLeftHandSideExpression(ExpressionClassifier* classifier,
bool is_super_call = result->IsSuperCallReference(); bool is_super_call = result->IsSuperCallReference();
if (spread_pos.IsValid()) { if (spread_pos.IsValid()) {
args = Traits::PrepareSpreadArguments(args); args = impl()->PrepareSpreadArguments(args);
result = Traits::SpreadCall(result, args, pos); result = impl()->SpreadCall(result, args, pos);
} else { } else {
result = factory()->NewCall(result, args, pos, is_possibly_eval); result = factory()->NewCall(result, args, pos, is_possibly_eval);
} }
...@@ -2939,7 +2938,7 @@ ParserBase<Impl>::ParseLeftHandSideExpression(ExpressionClassifier* classifier, ...@@ -2939,7 +2938,7 @@ ParserBase<Impl>::ParseLeftHandSideExpression(ExpressionClassifier* classifier,
case Token::PERIOD: { case Token::PERIOD: {
CheckNoTailCallExpressions(classifier, CHECK_OK); CheckNoTailCallExpressions(classifier, CHECK_OK);
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
BindingPatternUnexpectedToken(classifier); BindingPatternUnexpectedToken(classifier);
ArrowFormalParametersUnexpectedToken(classifier); ArrowFormalParametersUnexpectedToken(classifier);
Consume(Token::PERIOD); Consume(Token::PERIOD);
...@@ -2954,7 +2953,7 @@ ParserBase<Impl>::ParseLeftHandSideExpression(ExpressionClassifier* classifier, ...@@ -2954,7 +2953,7 @@ ParserBase<Impl>::ParseLeftHandSideExpression(ExpressionClassifier* classifier,
case Token::TEMPLATE_SPAN: case Token::TEMPLATE_SPAN:
case Token::TEMPLATE_TAIL: { case Token::TEMPLATE_TAIL: {
CheckNoTailCallExpressions(classifier, CHECK_OK); CheckNoTailCallExpressions(classifier, CHECK_OK);
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
BindingPatternUnexpectedToken(classifier); BindingPatternUnexpectedToken(classifier);
ArrowFormalParametersUnexpectedToken(classifier); ArrowFormalParametersUnexpectedToken(classifier);
result = ParseTemplateLiteral(result, position(), classifier, CHECK_OK); result = ParseTemplateLiteral(result, position(), classifier, CHECK_OK);
...@@ -3006,7 +3005,7 @@ ParserBase<Impl>::ParseMemberWithNewPrefixesExpression( ...@@ -3006,7 +3005,7 @@ ParserBase<Impl>::ParseMemberWithNewPrefixesExpression(
result = this->ParseMemberWithNewPrefixesExpression(classifier, is_async, result = this->ParseMemberWithNewPrefixesExpression(classifier, is_async,
CHECK_OK); CHECK_OK);
} }
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
if (peek() == Token::LPAREN) { if (peek() == Token::LPAREN) {
// NewExpression with arguments. // NewExpression with arguments.
Scanner::Location spread_pos; Scanner::Location spread_pos;
...@@ -3014,8 +3013,8 @@ ParserBase<Impl>::ParseMemberWithNewPrefixesExpression( ...@@ -3014,8 +3013,8 @@ ParserBase<Impl>::ParseMemberWithNewPrefixesExpression(
this->ParseArguments(&spread_pos, classifier, CHECK_OK); this->ParseArguments(&spread_pos, classifier, CHECK_OK);
if (spread_pos.IsValid()) { if (spread_pos.IsValid()) {
args = Traits::PrepareSpreadArguments(args); args = impl()->PrepareSpreadArguments(args);
result = Traits::SpreadCallNew(result, args, new_pos); result = impl()->SpreadCallNew(result, args, new_pos);
} else { } else {
result = factory()->NewCallNew(result, args, new_pos); result = factory()->NewCallNew(result, args, new_pos);
} }
...@@ -3082,7 +3081,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseMemberExpression( ...@@ -3082,7 +3081,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseMemberExpression(
function_name_location = scanner()->location(); function_name_location = scanner()->location();
function_type = FunctionLiteral::kNamedExpression; function_type = FunctionLiteral::kNamedExpression;
} }
result = this->ParseFunctionLiteral( result = impl()->ParseFunctionLiteral(
name, function_name_location, name, function_name_location,
is_strict_reserved_name ? kFunctionNameIsStrictReserved is_strict_reserved_name ? kFunctionNameIsStrictReserved
: kFunctionNameValidityUnknown, : kFunctionNameValidityUnknown,
...@@ -3169,14 +3168,14 @@ ParserBase<Impl>::ParseMemberExpressionContinuation( ...@@ -3169,14 +3168,14 @@ ParserBase<Impl>::ParseMemberExpressionContinuation(
switch (peek()) { switch (peek()) {
case Token::LBRACK: { case Token::LBRACK: {
*is_async = false; *is_async = false;
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
BindingPatternUnexpectedToken(classifier); BindingPatternUnexpectedToken(classifier);
ArrowFormalParametersUnexpectedToken(classifier); ArrowFormalParametersUnexpectedToken(classifier);
Consume(Token::LBRACK); Consume(Token::LBRACK);
int pos = position(); int pos = position();
ExpressionT index = this->ParseExpression(true, classifier, CHECK_OK); ExpressionT index = this->ParseExpression(true, classifier, CHECK_OK);
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
expression = factory()->NewProperty(expression, index, pos); expression = factory()->NewProperty(expression, index, pos);
if (fni_ != NULL) { if (fni_ != NULL) {
this->PushPropertyName(fni_, index); this->PushPropertyName(fni_, index);
...@@ -3186,7 +3185,7 @@ ParserBase<Impl>::ParseMemberExpressionContinuation( ...@@ -3186,7 +3185,7 @@ ParserBase<Impl>::ParseMemberExpressionContinuation(
} }
case Token::PERIOD: { case Token::PERIOD: {
*is_async = false; *is_async = false;
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
BindingPatternUnexpectedToken(classifier); BindingPatternUnexpectedToken(classifier);
ArrowFormalParametersUnexpectedToken(classifier); ArrowFormalParametersUnexpectedToken(classifier);
...@@ -3203,7 +3202,7 @@ ParserBase<Impl>::ParseMemberExpressionContinuation( ...@@ -3203,7 +3202,7 @@ ParserBase<Impl>::ParseMemberExpressionContinuation(
case Token::TEMPLATE_SPAN: case Token::TEMPLATE_SPAN:
case Token::TEMPLATE_TAIL: { case Token::TEMPLATE_TAIL: {
*is_async = false; *is_async = false;
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
BindingPatternUnexpectedToken(classifier); BindingPatternUnexpectedToken(classifier);
ArrowFormalParametersUnexpectedToken(classifier); ArrowFormalParametersUnexpectedToken(classifier);
int pos; int pos;
...@@ -3257,7 +3256,7 @@ void ParserBase<Impl>::ParseFormalParameter(FormalParametersT* parameters, ...@@ -3257,7 +3256,7 @@ void ParserBase<Impl>::ParseFormalParameter(FormalParametersT* parameters,
ExpressionClassifier init_classifier(this); ExpressionClassifier init_classifier(this);
initializer = ParseAssignmentExpression(true, &init_classifier, initializer = ParseAssignmentExpression(true, &init_classifier,
CHECK_OK_CUSTOM(Void)); CHECK_OK_CUSTOM(Void));
Traits::RewriteNonPattern(&init_classifier, CHECK_OK_CUSTOM(Void)); impl()->RewriteNonPattern(&init_classifier, CHECK_OK_CUSTOM(Void));
ValidateFormalParameterInitializer(&init_classifier, CHECK_OK_CUSTOM(Void)); ValidateFormalParameterInitializer(&init_classifier, CHECK_OK_CUSTOM(Void));
parameters->is_simple = false; parameters->is_simple = false;
init_classifier.Discard(); init_classifier.Discard();
...@@ -3429,14 +3428,14 @@ ParserBase<Impl>::ParseArrowFunctionLiteral( ...@@ -3429,14 +3428,14 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
formal_parameters.scope->AllowsLazyParsing()); formal_parameters.scope->AllowsLazyParsing());
if (is_lazily_parsed) { if (is_lazily_parsed) {
body = this->NewStatementList(0, zone()); body = this->NewStatementList(0, zone());
this->SkipLazyFunctionBody(&materialized_literal_count, impl()->SkipLazyFunctionBody(&materialized_literal_count,
&expected_property_count, CHECK_OK); &expected_property_count, CHECK_OK);
if (formal_parameters.materialized_literals_count > 0) { if (formal_parameters.materialized_literals_count > 0) {
materialized_literal_count += materialized_literal_count +=
formal_parameters.materialized_literals_count; formal_parameters.materialized_literals_count;
} }
} else { } else {
body = this->ParseEagerFunctionBody( body = impl()->ParseEagerFunctionBody(
this->EmptyIdentifier(), kNoSourcePosition, formal_parameters, this->EmptyIdentifier(), kNoSourcePosition, formal_parameters,
arrow_kind, FunctionLiteral::kAnonymousExpression, CHECK_OK); arrow_kind, FunctionLiteral::kAnonymousExpression, CHECK_OK);
materialized_literal_count = materialized_literal_count =
...@@ -3455,22 +3454,22 @@ ParserBase<Impl>::ParseArrowFunctionLiteral( ...@@ -3455,22 +3454,22 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
CHECK_OK); CHECK_OK);
ExpressionClassifier classifier(this); ExpressionClassifier classifier(this);
if (is_async) { if (is_async) {
this->ParseAsyncArrowSingleExpressionBody(body, accept_IN, &classifier, impl()->ParseAsyncArrowSingleExpressionBody(body, accept_IN,
pos, CHECK_OK); &classifier, pos, CHECK_OK);
Traits::RewriteNonPattern(&classifier, CHECK_OK); impl()->RewriteNonPattern(&classifier, CHECK_OK);
} else { } else {
ExpressionT expression = ExpressionT expression =
ParseAssignmentExpression(accept_IN, &classifier, CHECK_OK); ParseAssignmentExpression(accept_IN, &classifier, CHECK_OK);
Traits::RewriteNonPattern(&classifier, CHECK_OK); impl()->RewriteNonPattern(&classifier, CHECK_OK);
body->Add(factory()->NewReturnStatement(expression, pos), zone()); body->Add(factory()->NewReturnStatement(expression, pos), zone());
if (allow_tailcalls() && !is_sloppy(language_mode())) { if (allow_tailcalls() && !is_sloppy(language_mode())) {
// ES6 14.6.1 Static Semantics: IsInTailPosition // ES6 14.6.1 Static Semantics: IsInTailPosition
this->MarkTailPosition(expression); impl()->MarkTailPosition(expression);
} }
} }
materialized_literal_count = function_state.materialized_literal_count(); materialized_literal_count = function_state.materialized_literal_count();
expected_property_count = function_state.expected_property_count(); expected_property_count = function_state.expected_property_count();
this->MarkCollectedTailCallExpressions(); impl()->MarkCollectedTailCallExpressions();
} }
formal_parameters.scope->set_end_position(scanner()->location().end_pos); formal_parameters.scope->set_end_position(scanner()->location().end_pos);
...@@ -3488,9 +3487,9 @@ ParserBase<Impl>::ParseArrowFunctionLiteral( ...@@ -3488,9 +3487,9 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
CheckStrictOctalLiteral(formal_parameters.scope->start_position(), CheckStrictOctalLiteral(formal_parameters.scope->start_position(),
scanner()->location().end_pos, CHECK_OK); scanner()->location().end_pos, CHECK_OK);
} }
this->CheckConflictingVarDeclarations(formal_parameters.scope, CHECK_OK); impl()->CheckConflictingVarDeclarations(formal_parameters.scope, CHECK_OK);
Traits::RewriteDestructuringAssignments(); impl()->RewriteDestructuringAssignments();
} }
FunctionLiteralT function_literal = factory()->NewFunctionLiteral( FunctionLiteralT function_literal = factory()->NewFunctionLiteral(
...@@ -3531,15 +3530,15 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral( ...@@ -3531,15 +3530,15 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral(
Consume(Token::TEMPLATE_TAIL); Consume(Token::TEMPLATE_TAIL);
int pos = position(); int pos = position();
CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK); CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK);
typename Traits::TemplateLiteralState ts = Traits::OpenTemplateLiteral(pos); typename Impl::TemplateLiteralState ts = impl()->OpenTemplateLiteral(pos);
Traits::AddTemplateSpan(&ts, true); impl()->AddTemplateSpan(&ts, true);
return Traits::CloseTemplateLiteral(&ts, start, tag); return impl()->CloseTemplateLiteral(&ts, start, tag);
} }
Consume(Token::TEMPLATE_SPAN); Consume(Token::TEMPLATE_SPAN);
int pos = position(); int pos = position();
typename Traits::TemplateLiteralState ts = Traits::OpenTemplateLiteral(pos); typename Impl::TemplateLiteralState ts = impl()->OpenTemplateLiteral(pos);
Traits::AddTemplateSpan(&ts, false); impl()->AddTemplateSpan(&ts, false);
Token::Value next; Token::Value next;
// If we open with a TEMPLATE_SPAN, we must scan the subsequent expression, // If we open with a TEMPLATE_SPAN, we must scan the subsequent expression,
...@@ -3565,8 +3564,8 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral( ...@@ -3565,8 +3564,8 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral(
int expr_pos = peek_position(); int expr_pos = peek_position();
ExpressionT expression = this->ParseExpression(true, classifier, CHECK_OK); ExpressionT expression = this->ParseExpression(true, classifier, CHECK_OK);
CheckNoTailCallExpressions(classifier, CHECK_OK); CheckNoTailCallExpressions(classifier, CHECK_OK);
Traits::RewriteNonPattern(classifier, CHECK_OK); impl()->RewriteNonPattern(classifier, CHECK_OK);
Traits::AddTemplateExpression(&ts, expression); impl()->AddTemplateExpression(&ts, expression);
if (peek() != Token::RBRACE) { if (peek() != Token::RBRACE) {
ReportMessageAt(Scanner::Location(expr_pos, peek_position()), ReportMessageAt(Scanner::Location(expr_pos, peek_position()),
...@@ -3594,13 +3593,13 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral( ...@@ -3594,13 +3593,13 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral(
return Traits::EmptyExpression(); return Traits::EmptyExpression();
} }
Traits::AddTemplateSpan(&ts, next == Token::TEMPLATE_TAIL); impl()->AddTemplateSpan(&ts, next == Token::TEMPLATE_TAIL);
} while (next == Token::TEMPLATE_SPAN); } while (next == Token::TEMPLATE_SPAN);
DCHECK_EQ(next, Token::TEMPLATE_TAIL); DCHECK_EQ(next, Token::TEMPLATE_TAIL);
CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK); CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK);
// Once we've reached a TEMPLATE_TAIL, we can close the TemplateLiteral. // Once we've reached a TEMPLATE_TAIL, we can close the TemplateLiteral.
return Traits::CloseTemplateLiteral(&ts, start, tag); return impl()->CloseTemplateLiteral(&ts, start, tag);
} }
template <typename Impl> template <typename Impl>
......
...@@ -678,36 +678,10 @@ Literal* ParserBaseTraits<Parser>::GetLiteralTheHole( ...@@ -678,36 +678,10 @@ Literal* ParserBaseTraits<Parser>::GetLiteralTheHole(
return factory->NewTheHoleLiteral(kNoSourcePosition); return factory->NewTheHoleLiteral(kNoSourcePosition);
} }
Expression* ParserBaseTraits<Parser>::ParseV8Intrinsic(bool* ok) { void Parser::MarkTailPosition(Expression* expression) {
return delegate()->ParseV8Intrinsic(ok);
}
FunctionLiteral* ParserBaseTraits<Parser>::ParseFunctionLiteral(
const AstRawString* name, Scanner::Location function_name_location,
FunctionNameValidity function_name_validity, FunctionKind kind,
int function_token_position, FunctionLiteral::FunctionType type,
LanguageMode language_mode, bool* ok) {
return delegate()->ParseFunctionLiteral(
name, function_name_location, function_name_validity, kind,
function_token_position, type, language_mode, ok);
}
Expression* ParserBaseTraits<Parser>::ParseClassLiteral(
Type::ExpressionClassifier* classifier, const AstRawString* name,
Scanner::Location class_name_location, bool name_is_strict_reserved,
int pos, bool* ok) {
return delegate()->ParseClassLiteral(classifier, name, class_name_location,
name_is_strict_reserved, pos, ok);
}
void ParserBaseTraits<Parser>::MarkTailPosition(Expression* expression) {
expression->MarkTail(); expression->MarkTail();
} }
void ParserBaseTraits<Parser>::MarkCollectedTailCallExpressions() {
delegate()->MarkCollectedTailCallExpressions();
}
Parser::Parser(ParseInfo* info) Parser::Parser(ParseInfo* info)
: ParserBase<Parser>(info->zone(), &scanner_, info->stack_limit(), : ParserBase<Parser>(info->zone(), &scanner_, info->stack_limit(),
info->extension(), info->ast_value_factory(), NULL), info->extension(), info->ast_value_factory(), NULL),
...@@ -940,7 +914,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) { ...@@ -940,7 +914,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
} }
if (ok) { if (ok) {
ParserBaseTraits<Parser>::RewriteDestructuringAssignments(); RewriteDestructuringAssignments();
result = factory()->NewScriptOrEvalFunctionLiteral( result = factory()->NewScriptOrEvalFunctionLiteral(
scope, body, function_state.materialized_literal_count(), scope, body, function_state.materialized_literal_count(),
function_state.expected_property_count()); function_state.expected_property_count());
...@@ -3984,15 +3958,6 @@ void Parser::ParseArrowFunctionFormalParameters( ...@@ -3984,15 +3958,6 @@ void Parser::ParseArrowFunctionFormalParameters(
AddFormalParameter(parameters, expr, initializer, end_pos, is_rest); AddFormalParameter(parameters, expr, initializer, end_pos, is_rest);
} }
void ParserBaseTraits<Parser>::ParseAsyncArrowSingleExpressionBody(
ZoneList<Statement*>* body, bool accept_IN,
Type::ExpressionClassifier* classifier, int pos, bool* ok) {
delegate()->DesugarAsyncFunctionBody(
delegate()->ast_value_factory()->empty_string(), delegate()->scope(),
body, classifier, kAsyncArrowFunction,
Parser::FunctionBodyType::kSingleExpression, accept_IN, pos, ok);
}
void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name, void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name,
Scope* scope, ZoneList<Statement*>* body, Scope* scope, ZoneList<Statement*>* body,
ExpressionClassifier* classifier, ExpressionClassifier* classifier,
...@@ -4030,7 +3995,7 @@ void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name, ...@@ -4030,7 +3995,7 @@ void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name,
} else { } else {
return_value = return_value =
ParseAssignmentExpression(accept_IN, classifier, CHECK_OK_VOID); ParseAssignmentExpression(accept_IN, classifier, CHECK_OK_VOID);
ParserBaseTraits<Parser>::RewriteNonPattern(classifier, CHECK_OK_VOID); RewriteNonPattern(classifier, CHECK_OK_VOID);
} }
return_value = BuildPromiseResolve(return_value, return_value->position()); return_value = BuildPromiseResolve(return_value, return_value->position());
...@@ -4334,7 +4299,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral( ...@@ -4334,7 +4299,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
if (body) { if (body) {
// If body can be inspected, rewrite queued destructuring assignments // If body can be inspected, rewrite queued destructuring assignments
ParserBaseTraits<Parser>::RewriteDestructuringAssignments(); RewriteDestructuringAssignments();
} }
has_duplicate_parameters = has_duplicate_parameters =
!formals_classifier.is_valid_formal_parameter_list_without_duplicates(); !formals_classifier.is_valid_formal_parameter_list_without_duplicates();
...@@ -5354,9 +5319,8 @@ void Parser::ParseOnBackground(ParseInfo* info) { ...@@ -5354,9 +5319,8 @@ void Parser::ParseOnBackground(ParseInfo* info) {
} }
} }
ParserBaseTraits<Parser>::TemplateLiteralState Parser::OpenTemplateLiteral( Parser::TemplateLiteralState Parser::OpenTemplateLiteral(int pos) {
int pos) { return new (zone()) TemplateLiteral(zone(), pos);
return new (zone()) ParserBaseTraits<Parser>::TemplateLiteral(zone(), pos);
} }
...@@ -5632,28 +5596,7 @@ Expression* ParserBaseTraits<Parser>::ExpressionListToExpression( ...@@ -5632,28 +5596,7 @@ Expression* ParserBaseTraits<Parser>::ExpressionListToExpression(
return expr; return expr;
} }
void ParserBaseTraits<Parser>::RewriteDestructuringAssignments() { Expression* Parser::RewriteAwaitExpression(Expression* value, int await_pos) {
delegate()->RewriteDestructuringAssignments();
}
Expression* ParserBaseTraits<Parser>::RewriteExponentiation(Expression* left,
Expression* right,
int pos) {
return delegate()->RewriteExponentiation(left, right, pos);
}
Expression* ParserBaseTraits<Parser>::RewriteAssignExponentiation(
Expression* left, Expression* right, int pos) {
return delegate()->RewriteAssignExponentiation(left, right, pos);
}
void ParserBaseTraits<Parser>::RewriteNonPattern(
Type::ExpressionClassifier* classifier, bool* ok) {
delegate()->RewriteNonPattern(classifier, ok);
}
Expression* ParserBaseTraits<Parser>::RewriteAwaitExpression(Expression* value,
int await_pos) {
// yield %AsyncFunctionAwait(.generator_object, <operand>) // yield %AsyncFunctionAwait(.generator_object, <operand>)
Variable* generator_object_variable = Variable* generator_object_variable =
delegate()->function_state_->generator_object_variable(); delegate()->function_state_->generator_object_variable();
...@@ -5905,17 +5848,15 @@ Expression* Parser::RewriteSpreads(ArrayLiteral* lit) { ...@@ -5905,17 +5848,15 @@ Expression* Parser::RewriteSpreads(ArrayLiteral* lit) {
return factory()->NewDoExpression(do_block, result, lit->position()); return factory()->NewDoExpression(do_block, result, lit->position());
} }
void ParserBaseTraits<Parser>::QueueDestructuringAssignmentForRewriting( void Parser::QueueDestructuringAssignmentForRewriting(Expression* expr) {
Expression* expr) {
DCHECK(expr->IsRewritableExpression()); DCHECK(expr->IsRewritableExpression());
delegate()->function_state_->AddDestructuringAssignment( function_state_->AddDestructuringAssignment(
Parser::DestructuringAssignment(expr, delegate()->scope())); DestructuringAssignment(expr, delegate()->scope()));
} }
void ParserBaseTraits<Parser>::QueueNonPatternForRewriting(Expression* expr, void Parser::QueueNonPatternForRewriting(Expression* expr, bool* ok) {
bool* ok) {
DCHECK(expr->IsRewritableExpression()); DCHECK(expr->IsRewritableExpression());
delegate()->function_state_->AddNonPatternForRewriting(expr, ok); function_state_->AddNonPatternForRewriting(expr, ok);
} }
void ParserBaseTraits<Parser>::SetFunctionNameFromPropertyName( void ParserBaseTraits<Parser>::SetFunctionNameFromPropertyName(
......
...@@ -336,10 +336,6 @@ class ParserBaseTraits<Parser> { ...@@ -336,10 +336,6 @@ class ParserBaseTraits<Parser> {
const ParserFormalParameters& parameters, const ParserFormalParameters& parameters,
ZoneList<v8::internal::Statement*>* body, bool is_async, bool* ok); ZoneList<v8::internal::Statement*>* body, bool is_async, bool* ok);
void ParseAsyncArrowSingleExpressionBody(
ZoneList<Statement*>* body, bool accept_IN,
Type::ExpressionClassifier* classifier, int pos, bool* ok);
V8_INLINE void AddFormalParameter(ParserFormalParameters* parameters, V8_INLINE void AddFormalParameter(ParserFormalParameters* parameters,
Expression* pattern, Expression* pattern,
Expression* initializer, Expression* initializer,
...@@ -353,124 +349,28 @@ class ParserBaseTraits<Parser> { ...@@ -353,124 +349,28 @@ class ParserBaseTraits<Parser> {
const Scanner::Location& params_loc, Scanner::Location* duplicate_loc, const Scanner::Location& params_loc, Scanner::Location* duplicate_loc,
const Scope::Snapshot& scope_snapshot, bool* ok); const Scope::Snapshot& scope_snapshot, bool* ok);
V8_INLINE Expression* ParseAsyncFunctionExpression(bool* ok);
V8_INLINE DoExpression* ParseDoExpression(bool* ok);
void ReindexLiterals(const ParserFormalParameters& parameters); void ReindexLiterals(const ParserFormalParameters& parameters);
// Temporary glue; these functions will move to ParserBase.
Expression* ParseV8Intrinsic(bool* ok);
FunctionLiteral* ParseFunctionLiteral(
const AstRawString* name, Scanner::Location function_name_location,
FunctionNameValidity function_name_validity, FunctionKind kind,
int function_token_position, FunctionLiteral::FunctionType type,
LanguageMode language_mode, bool* ok);
V8_INLINE void SkipLazyFunctionBody(
int* materialized_literal_count, int* expected_property_count, bool* ok,
Scanner::BookmarkScope* bookmark = nullptr);
V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody(
const AstRawString* name, int pos,
const ParserFormalParameters& parameters, FunctionKind kind,
FunctionLiteral::FunctionType function_type, bool* ok);
Expression* ParseClassLiteral(Type::ExpressionClassifier* classifier,
const AstRawString* name,
Scanner::Location class_name_location,
bool name_is_strict_reserved, int pos,
bool* ok);
V8_INLINE void MarkCollectedTailCallExpressions();
V8_INLINE void MarkTailPosition(Expression* expression);
V8_INLINE void CheckConflictingVarDeclarations(Scope* scope, bool* ok);
class TemplateLiteral : public ZoneObject {
public:
TemplateLiteral(Zone* zone, int pos)
: cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {}
const ZoneList<Expression*>* cooked() const { return &cooked_; }
const ZoneList<Expression*>* raw() const { return &raw_; }
const ZoneList<Expression*>* expressions() const { return &expressions_; }
int position() const { return pos_; }
void AddTemplateSpan(Literal* cooked, Literal* raw, int end, Zone* zone) {
DCHECK_NOT_NULL(cooked);
DCHECK_NOT_NULL(raw);
cooked_.Add(cooked, zone);
raw_.Add(raw, zone);
}
void AddExpression(Expression* expression, Zone* zone) {
DCHECK_NOT_NULL(expression);
expressions_.Add(expression, zone);
}
private:
ZoneList<Expression*> cooked_;
ZoneList<Expression*> raw_;
ZoneList<Expression*> expressions_;
int pos_;
};
typedef TemplateLiteral* TemplateLiteralState;
V8_INLINE TemplateLiteralState OpenTemplateLiteral(int pos);
V8_INLINE void AddTemplateSpan(TemplateLiteralState* state, bool tail);
V8_INLINE void AddTemplateExpression(TemplateLiteralState* state,
Expression* expression);
V8_INLINE Expression* CloseTemplateLiteral(TemplateLiteralState* state,
int start, Expression* tag);
V8_INLINE Expression* NoTemplateTag() { return NULL; } V8_INLINE Expression* NoTemplateTag() { return NULL; }
V8_INLINE static bool IsTaggedTemplate(const Expression* tag) { V8_INLINE static bool IsTaggedTemplate(const Expression* tag) {
return tag != NULL; return tag != NULL;
} }
V8_INLINE ZoneList<v8::internal::Expression*>* PrepareSpreadArguments(
ZoneList<v8::internal::Expression*>* list);
V8_INLINE void MaterializeUnspreadArgumentsLiterals(int count) {} V8_INLINE void MaterializeUnspreadArgumentsLiterals(int count) {}
V8_INLINE Expression* SpreadCall(Expression* function,
ZoneList<v8::internal::Expression*>* args,
int pos);
V8_INLINE Expression* SpreadCallNew(Expression* function,
ZoneList<v8::internal::Expression*>* args,
int pos);
Expression* ExpressionListToExpression(ZoneList<Expression*>* args); Expression* ExpressionListToExpression(ZoneList<Expression*>* args);
// Rewrite all DestructuringAssignments in the current FunctionState.
V8_INLINE void RewriteDestructuringAssignments();
V8_INLINE Expression* RewriteExponentiation(Expression* left,
Expression* right, int pos);
V8_INLINE Expression* RewriteAssignExponentiation(Expression* left,
Expression* right, int pos);
V8_INLINE Expression* RewriteAwaitExpression(Expression* value, int pos);
V8_INLINE void QueueDestructuringAssignmentForRewriting(
Expression* assignment);
V8_INLINE void QueueNonPatternForRewriting(Expression* expr, bool* ok);
void SetFunctionNameFromPropertyName(ObjectLiteralProperty* property, void SetFunctionNameFromPropertyName(ObjectLiteralProperty* property,
const AstRawString* name); const AstRawString* name);
void SetFunctionNameFromIdentifierRef(Expression* value, void SetFunctionNameFromIdentifierRef(Expression* value,
Expression* identifier); Expression* identifier);
// Rewrite expressions that are not used as patterns
V8_INLINE void RewriteNonPattern(Type::ExpressionClassifier* classifier,
bool* ok);
V8_INLINE ZoneList<typename Type::ExpressionClassifier::Error>* V8_INLINE ZoneList<typename Type::ExpressionClassifier::Error>*
GetReportedErrorList() const; GetReportedErrorList() const;
V8_INLINE Zone* zone() const; V8_INLINE Zone* zone() const;
V8_INLINE ZoneList<Expression*>* GetNonPatternList() const; V8_INLINE ZoneList<Expression*>* GetNonPatternList() const;
V8_INLINE Expression* RewriteYieldStar(Expression* generator,
Expression* expression, int pos);
}; };
class Parser : public ParserBase<Parser> { class Parser : public ParserBase<Parser> {
...@@ -499,6 +399,7 @@ class Parser : public ParserBase<Parser> { ...@@ -499,6 +399,7 @@ class Parser : public ParserBase<Parser> {
void HandleSourceURLComments(Isolate* isolate, Handle<Script> script); void HandleSourceURLComments(Isolate* isolate, Handle<Script> script);
private: private:
friend class ParserBase<Parser>;
// TODO(nikolaos): This should not be necessary. It will be removed // TODO(nikolaos): This should not be necessary. It will be removed
// when the traits object stops delegating to the implementation object. // when the traits object stops delegating to the implementation object.
friend class ParserBaseTraits<Parser>; friend class ParserBaseTraits<Parser>;
...@@ -877,6 +778,37 @@ class Parser : public ParserBase<Parser> { ...@@ -877,6 +778,37 @@ class Parser : public ParserBase<Parser> {
void ThrowPendingError(Isolate* isolate, Handle<Script> script); void ThrowPendingError(Isolate* isolate, Handle<Script> script);
class TemplateLiteral : public ZoneObject {
public:
TemplateLiteral(Zone* zone, int pos)
: cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {}
const ZoneList<Expression*>* cooked() const { return &cooked_; }
const ZoneList<Expression*>* raw() const { return &raw_; }
const ZoneList<Expression*>* expressions() const { return &expressions_; }
int position() const { return pos_; }
void AddTemplateSpan(Literal* cooked, Literal* raw, int end, Zone* zone) {
DCHECK_NOT_NULL(cooked);
DCHECK_NOT_NULL(raw);
cooked_.Add(cooked, zone);
raw_.Add(raw, zone);
}
void AddExpression(Expression* expression, Zone* zone) {
DCHECK_NOT_NULL(expression);
expressions_.Add(expression, zone);
}
private:
ZoneList<Expression*> cooked_;
ZoneList<Expression*> raw_;
ZoneList<Expression*> expressions_;
int pos_;
};
typedef TemplateLiteral* TemplateLiteralState;
TemplateLiteralState OpenTemplateLiteral(int pos); TemplateLiteralState OpenTemplateLiteral(int pos);
void AddTemplateSpan(TemplateLiteralState* state, bool tail); void AddTemplateSpan(TemplateLiteralState* state, bool tail);
void AddTemplateExpression(TemplateLiteralState* state, void AddTemplateExpression(TemplateLiteralState* state,
...@@ -885,6 +817,16 @@ class Parser : public ParserBase<Parser> { ...@@ -885,6 +817,16 @@ class Parser : public ParserBase<Parser> {
Expression* tag); Expression* tag);
uint32_t ComputeTemplateLiteralHash(const TemplateLiteral* lit); uint32_t ComputeTemplateLiteralHash(const TemplateLiteral* lit);
void ParseAsyncArrowSingleExpressionBody(ZoneList<Statement*>* body,
bool accept_IN,
ExpressionClassifier* classifier,
int pos, bool* ok) {
DesugarAsyncFunctionBody(ast_value_factory()->empty_string(), scope(), body,
classifier, kAsyncArrowFunction,
FunctionBodyType::kSingleExpression, accept_IN,
pos, ok);
}
ZoneList<v8::internal::Expression*>* PrepareSpreadArguments( ZoneList<v8::internal::Expression*>* PrepareSpreadArguments(
ZoneList<v8::internal::Expression*>* list); ZoneList<v8::internal::Expression*>* list);
Expression* SpreadCall(Expression* function, Expression* SpreadCall(Expression* function,
...@@ -896,7 +838,9 @@ class Parser : public ParserBase<Parser> { ...@@ -896,7 +838,9 @@ class Parser : public ParserBase<Parser> {
void RaiseLanguageMode(LanguageMode mode); void RaiseLanguageMode(LanguageMode mode);
V8_INLINE void MarkCollectedTailCallExpressions(); V8_INLINE void MarkCollectedTailCallExpressions();
V8_INLINE void MarkTailPosition(Expression* expression);
// Rewrite all DestructuringAssignments in the current FunctionState.
V8_INLINE void RewriteDestructuringAssignments(); V8_INLINE void RewriteDestructuringAssignments();
V8_INLINE Expression* RewriteExponentiation(Expression* left, V8_INLINE Expression* RewriteExponentiation(Expression* left,
...@@ -907,8 +851,13 @@ class Parser : public ParserBase<Parser> { ...@@ -907,8 +851,13 @@ class Parser : public ParserBase<Parser> {
friend class NonPatternRewriter; friend class NonPatternRewriter;
V8_INLINE Expression* RewriteSpreads(ArrayLiteral* lit); V8_INLINE Expression* RewriteSpreads(ArrayLiteral* lit);
// Rewrite expressions that are not used as patterns
V8_INLINE void RewriteNonPattern(ExpressionClassifier* classifier, bool* ok); V8_INLINE void RewriteNonPattern(ExpressionClassifier* classifier, bool* ok);
V8_INLINE void QueueDestructuringAssignmentForRewriting(
Expression* assignment);
V8_INLINE void QueueNonPatternForRewriting(Expression* expr, bool* ok);
friend class InitializerRewriter; friend class InitializerRewriter;
void RewriteParameterInitializer(Expression* expr, Scope* scope); void RewriteParameterInitializer(Expression* expr, Scope* scope);
...@@ -933,6 +882,8 @@ class Parser : public ParserBase<Parser> { ...@@ -933,6 +882,8 @@ class Parser : public ParserBase<Parser> {
Expression* completion); Expression* completion);
Statement* CheckCallable(Variable* var, Expression* error, int pos); Statement* CheckCallable(Variable* var, Expression* error, int pos);
V8_INLINE Expression* RewriteAwaitExpression(Expression* value, int pos);
Expression* RewriteYieldStar(Expression* generator, Expression* expression, Expression* RewriteYieldStar(Expression* generator, Expression* expression,
int pos); int pos);
...@@ -972,25 +923,6 @@ const AstRawString* ParserBaseTraits<Parser>::EmptyIdentifierString() const { ...@@ -972,25 +923,6 @@ const AstRawString* ParserBaseTraits<Parser>::EmptyIdentifierString() const {
return delegate()->ast_value_factory()->empty_string(); return delegate()->ast_value_factory()->empty_string();
} }
void ParserBaseTraits<Parser>::SkipLazyFunctionBody(
int* materialized_literal_count, int* expected_property_count, bool* ok,
Scanner::BookmarkScope* bookmark) {
return delegate()->SkipLazyFunctionBody(
materialized_literal_count, expected_property_count, ok, bookmark);
}
ZoneList<Statement*>* ParserBaseTraits<Parser>::ParseEagerFunctionBody(
const AstRawString* name, int pos, const ParserFormalParameters& parameters,
FunctionKind kind, FunctionLiteral::FunctionType function_type, bool* ok) {
return delegate()->ParseEagerFunctionBody(name, pos, parameters, kind,
function_type, ok);
}
void ParserBaseTraits<Parser>::CheckConflictingVarDeclarations(Scope* scope,
bool* ok) {
delegate()->CheckConflictingVarDeclarations(scope, ok);
}
// Support for handling complex values (array and object literals) that // Support for handling complex values (array and object literals) that
// can be fully handled at compile time. // can be fully handled at compile time.
...@@ -1020,41 +952,6 @@ class CompileTimeValue: public AllStatic { ...@@ -1020,41 +952,6 @@ class CompileTimeValue: public AllStatic {
DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
}; };
ParserBaseTraits<Parser>::TemplateLiteralState
ParserBaseTraits<Parser>::OpenTemplateLiteral(int pos) {
return delegate()->OpenTemplateLiteral(pos);
}
void ParserBaseTraits<Parser>::AddTemplateSpan(TemplateLiteralState* state,
bool tail) {
delegate()->AddTemplateSpan(state, tail);
}
void ParserBaseTraits<Parser>::AddTemplateExpression(
TemplateLiteralState* state, Expression* expression) {
delegate()->AddTemplateExpression(state, expression);
}
Expression* ParserBaseTraits<Parser>::CloseTemplateLiteral(
TemplateLiteralState* state, int start, Expression* tag) {
return delegate()->CloseTemplateLiteral(state, start, tag);
}
ZoneList<v8::internal::Expression*>* ParserBaseTraits<
Parser>::PrepareSpreadArguments(ZoneList<v8::internal::Expression*>* list) {
return delegate()->PrepareSpreadArguments(list);
}
Expression* ParserBaseTraits<Parser>::SpreadCall(
Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) {
return delegate()->SpreadCall(function, args, pos);
}
Expression* ParserBaseTraits<Parser>::SpreadCallNew(
Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) {
return delegate()->SpreadCallNew(function, args, pos);
}
void ParserBaseTraits<Parser>::AddFormalParameter( void ParserBaseTraits<Parser>::AddFormalParameter(
ParserFormalParameters* parameters, Expression* pattern, ParserFormalParameters* parameters, Expression* pattern,
Expression* initializer, int initializer_end_position, bool is_rest) { Expression* initializer, int initializer_end_position, bool is_rest) {
...@@ -1112,20 +1009,6 @@ void ParserBaseTraits<Parser>::AddParameterInitializationBlock( ...@@ -1112,20 +1009,6 @@ void ParserBaseTraits<Parser>::AddParameterInitializationBlock(
} }
} }
Expression* ParserBaseTraits<Parser>::ParseAsyncFunctionExpression(bool* ok) {
return delegate()->ParseAsyncFunctionExpression(ok);
}
DoExpression* ParserBaseTraits<Parser>::ParseDoExpression(bool* ok) {
return delegate()->ParseDoExpression(ok);
}
Expression* ParserBaseTraits<Parser>::RewriteYieldStar(Expression* generator,
Expression* iterable,
int pos) {
return delegate()->RewriteYieldStar(generator, iterable, pos);
}
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -94,20 +94,6 @@ PreParserExpression ParserBaseTraits<PreParser>::ExpressionFromString( ...@@ -94,20 +94,6 @@ PreParserExpression ParserBaseTraits<PreParser>::ExpressionFromString(
return PreParserExpression::StringLiteral(); return PreParserExpression::StringLiteral();
} }
PreParserExpression ParserBaseTraits<PreParser>::ParseV8Intrinsic(bool* ok) {
return delegate()->ParseV8Intrinsic(ok);
}
PreParserExpression ParserBaseTraits<PreParser>::ParseFunctionLiteral(
PreParserIdentifier name, Scanner::Location function_name_location,
FunctionNameValidity function_name_validity, FunctionKind kind,
int function_token_position, FunctionLiteral::FunctionType type,
LanguageMode language_mode, bool* ok) {
return delegate()->ParseFunctionLiteral(
name, function_name_location, function_name_validity, kind,
function_token_position, type, language_mode, ok);
}
PreParser::PreParseResult PreParser::PreParseLazyFunction( PreParser::PreParseResult PreParser::PreParseLazyFunction(
LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters, LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters,
bool parsing_module, ParserRecorder* log, Scanner::BookmarkScope* bookmark, bool parsing_module, ParserRecorder* log, Scanner::BookmarkScope* bookmark,
...@@ -148,14 +134,6 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction( ...@@ -148,14 +134,6 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction(
return kPreParseSuccess; return kPreParseSuccess;
} }
PreParserExpression ParserBaseTraits<PreParser>::ParseClassLiteral(
Type::ExpressionClassifier* classifier, PreParserIdentifier name,
Scanner::Location class_name_location, bool name_is_strict_reserved,
int pos, bool* ok) {
return delegate()->ParseClassLiteral(classifier, name, class_name_location,
name_is_strict_reserved, pos, ok);
}
// Preparsing checks a JavaScript program and emits preparse-data that helps // Preparsing checks a JavaScript program and emits preparse-data that helps
// a later parsing to be faster. // a later parsing to be faster.
...@@ -1276,14 +1254,13 @@ PreParserExpression PreParser::ParseDoExpression(bool* ok) { ...@@ -1276,14 +1254,13 @@ PreParserExpression PreParser::ParseDoExpression(bool* ok) {
return PreParserExpression::Default(); return PreParserExpression::Default();
} }
void ParserBaseTraits<PreParser>::ParseAsyncArrowSingleExpressionBody( void PreParser::ParseAsyncArrowSingleExpressionBody(
PreParserStatementList body, bool accept_IN, PreParserStatementList body, bool accept_IN,
Type::ExpressionClassifier* classifier, int pos, bool* ok) { ExpressionClassifier* classifier, int pos, bool* ok) {
Scope* scope = delegate()->scope(); scope()->ForceContextAllocation();
scope->ForceContextAllocation();
PreParserExpression return_value = delegate()->ParseAssignmentExpression( PreParserExpression return_value =
accept_IN, classifier, CHECK_OK_CUSTOM(Void)); ParseAssignmentExpression(accept_IN, classifier, CHECK_OK_CUSTOM(Void));
body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); body->Add(PreParserStatement::ExpressionStatement(return_value), zone());
} }
......
...@@ -862,11 +862,6 @@ class ParserBaseTraits<PreParser> { ...@@ -862,11 +862,6 @@ class ParserBaseTraits<PreParser> {
const PreParserFormalParameters& parameters, PreParserStatementList body, const PreParserFormalParameters& parameters, PreParserStatementList body,
bool is_async, bool* ok) {} bool is_async, bool* ok) {}
void ParseAsyncArrowSingleExpressionBody(
PreParserStatementList body, bool accept_IN,
Type::ExpressionClassifier* classifier, int pos, bool* ok);
void AddFormalParameter(PreParserFormalParameters* parameters, void AddFormalParameter(PreParserFormalParameters* parameters,
PreParserExpression pattern, PreParserExpression pattern,
PreParserExpression initializer, PreParserExpression initializer,
...@@ -887,52 +882,8 @@ class ParserBaseTraits<PreParser> { ...@@ -887,52 +882,8 @@ class ParserBaseTraits<PreParser> {
const Scanner::Location& params_loc, Scanner::Location* duplicate_loc, const Scanner::Location& params_loc, Scanner::Location* duplicate_loc,
const Scope::Snapshot& scope_snapshot, bool* ok); const Scope::Snapshot& scope_snapshot, bool* ok);
V8_INLINE PreParserExpression ParseAsyncFunctionExpression(bool* ok);
V8_INLINE PreParserExpression ParseDoExpression(bool* ok);
void ReindexLiterals(const PreParserFormalParameters& parameters) {} void ReindexLiterals(const PreParserFormalParameters& parameters) {}
// Temporary glue; these functions will move to ParserBase.
PreParserExpression ParseV8Intrinsic(bool* ok);
PreParserExpression ParseFunctionLiteral(
PreParserIdentifier name, Scanner::Location function_name_location,
FunctionNameValidity function_name_validity, FunctionKind kind,
int function_token_position, FunctionLiteral::FunctionType type,
LanguageMode language_mode, bool* ok);
V8_INLINE void SkipLazyFunctionBody(
int* materialized_literal_count, int* expected_property_count, bool* ok,
Scanner::BookmarkScope* bookmark = nullptr) {
UNREACHABLE();
}
V8_INLINE PreParserStatementList ParseEagerFunctionBody(
PreParserIdentifier name, int pos,
const PreParserFormalParameters& parameters, FunctionKind kind,
FunctionLiteral::FunctionType function_type, bool* ok);
PreParserExpression ParseClassLiteral(Type::ExpressionClassifier* classifier,
PreParserIdentifier name,
Scanner::Location class_name_location,
bool name_is_strict_reserved, int pos,
bool* ok);
V8_INLINE void MarkCollectedTailCallExpressions() {}
V8_INLINE void MarkTailPosition(PreParserExpression expression) {}
void CheckConflictingVarDeclarations(Scope* scope, bool* ok) {}
struct TemplateLiteralState {};
V8_INLINE TemplateLiteralState OpenTemplateLiteral(int pos) {
return TemplateLiteralState();
}
V8_INLINE void AddTemplateSpan(TemplateLiteralState* state, bool tail) {}
V8_INLINE void AddTemplateExpression(TemplateLiteralState* state,
PreParserExpression expression) {}
V8_INLINE PreParserExpression CloseTemplateLiteral(
TemplateLiteralState* state, int start, PreParserExpression tag);
V8_INLINE PreParserExpression NoTemplateTag() { V8_INLINE PreParserExpression NoTemplateTag() {
return PreParserExpression::NoTemplateTag(); return PreParserExpression::NoTemplateTag();
} }
...@@ -940,59 +891,22 @@ class ParserBaseTraits<PreParser> { ...@@ -940,59 +891,22 @@ class ParserBaseTraits<PreParser> {
return !tag.IsNoTemplateTag(); return !tag.IsNoTemplateTag();
} }
V8_INLINE PreParserExpressionList
PrepareSpreadArguments(PreParserExpressionList list) {
return list;
}
inline void MaterializeUnspreadArgumentsLiterals(int count); inline void MaterializeUnspreadArgumentsLiterals(int count);
inline PreParserExpression SpreadCall(PreParserExpression function,
PreParserExpressionList args, int pos);
inline PreParserExpression SpreadCallNew(PreParserExpression function,
PreParserExpressionList args,
int pos);
inline PreParserExpression ExpressionListToExpression( inline PreParserExpression ExpressionListToExpression(
PreParserExpressionList args) { PreParserExpressionList args) {
return PreParserExpression::Default(); return PreParserExpression::Default();
} }
inline void RewriteDestructuringAssignments() {}
inline PreParserExpression RewriteExponentiation(PreParserExpression left,
PreParserExpression right,
int pos) {
return left;
}
inline PreParserExpression RewriteAssignExponentiation(
PreParserExpression left, PreParserExpression right, int pos) {
return left;
}
inline PreParserExpression RewriteAwaitExpression(PreParserExpression value,
int pos);
inline void QueueDestructuringAssignmentForRewriting(
PreParserExpression assignment) {}
inline void QueueNonPatternForRewriting(PreParserExpression expr, bool* ok) {}
void SetFunctionNameFromPropertyName(PreParserExpression property, void SetFunctionNameFromPropertyName(PreParserExpression property,
PreParserIdentifier name) {} PreParserIdentifier name) {}
void SetFunctionNameFromIdentifierRef(PreParserExpression value, void SetFunctionNameFromIdentifierRef(PreParserExpression value,
PreParserExpression identifier) {} PreParserExpression identifier) {}
inline void RewriteNonPattern(Type::ExpressionClassifier* classifier,
bool* ok);
V8_INLINE ZoneList<typename Type::ExpressionClassifier::Error>* V8_INLINE ZoneList<typename Type::ExpressionClassifier::Error>*
GetReportedErrorList() const; GetReportedErrorList() const;
V8_INLINE Zone* zone() const; V8_INLINE Zone* zone() const;
V8_INLINE ZoneList<PreParserExpression>* GetNonPatternList() const; V8_INLINE ZoneList<PreParserExpression>* GetNonPatternList() const;
inline PreParserExpression RewriteYieldStar(PreParserExpression generator,
PreParserExpression expression,
int pos);
}; };
...@@ -1009,6 +923,7 @@ class ParserBaseTraits<PreParser> { ...@@ -1009,6 +923,7 @@ class ParserBaseTraits<PreParser> {
// That means that contextual checks (like a label being declared where // That means that contextual checks (like a label being declared where
// it is used) are generally omitted. // it is used) are generally omitted.
class PreParser : public ParserBase<PreParser> { class PreParser : public ParserBase<PreParser> {
friend class ParserBase<PreParser>;
// TODO(nikolaos): This should not be necessary. It will be removed // TODO(nikolaos): This should not be necessary. It will be removed
// when the traits object stops delegating to the implementation object. // when the traits object stops delegating to the implementation object.
friend class ParserBaseTraits<PreParser>; friend class ParserBaseTraits<PreParser>;
...@@ -1139,6 +1054,11 @@ class PreParser : public ParserBase<PreParser> { ...@@ -1139,6 +1054,11 @@ class PreParser : public ParserBase<PreParser> {
const PreParserFormalParameters& parameters, FunctionKind kind, const PreParserFormalParameters& parameters, FunctionKind kind,
FunctionLiteral::FunctionType function_type, bool* ok); FunctionLiteral::FunctionType function_type, bool* ok);
V8_INLINE void SkipLazyFunctionBody(
int* materialized_literal_count, int* expected_property_count, bool* ok,
Scanner::BookmarkScope* bookmark = nullptr) {
UNREACHABLE();
}
Expression ParseFunctionLiteral( Expression ParseFunctionLiteral(
Identifier name, Scanner::Location function_name_location, Identifier name, Scanner::Location function_name_location,
FunctionNameValidity function_name_validity, FunctionKind kind, FunctionNameValidity function_name_validity, FunctionKind kind,
...@@ -1153,6 +1073,69 @@ class PreParser : public ParserBase<PreParser> { ...@@ -1153,6 +1073,69 @@ class PreParser : public ParserBase<PreParser> {
bool name_is_strict_reserved, int pos, bool name_is_strict_reserved, int pos,
bool* ok); bool* ok);
struct TemplateLiteralState {};
V8_INLINE TemplateLiteralState OpenTemplateLiteral(int pos) {
return TemplateLiteralState();
}
V8_INLINE void AddTemplateExpression(TemplateLiteralState* state,
PreParserExpression expression) {}
V8_INLINE void AddTemplateSpan(TemplateLiteralState* state, bool tail) {}
V8_INLINE PreParserExpression CloseTemplateLiteral(
TemplateLiteralState* state, int start, PreParserExpression tag);
V8_INLINE void CheckConflictingVarDeclarations(Scope* scope, bool* ok) {}
V8_INLINE void MarkCollectedTailCallExpressions() {}
V8_INLINE void MarkTailPosition(PreParserExpression expression) {}
void ParseAsyncArrowSingleExpressionBody(PreParserStatementList body,
bool accept_IN,
ExpressionClassifier* classifier,
int pos, bool* ok);
V8_INLINE PreParserExpressionList
PrepareSpreadArguments(PreParserExpressionList list) {
return list;
}
V8_INLINE PreParserExpression SpreadCall(PreParserExpression function,
PreParserExpressionList args,
int pos);
V8_INLINE PreParserExpression SpreadCallNew(PreParserExpression function,
PreParserExpressionList args,
int pos);
V8_INLINE void RewriteDestructuringAssignments() {}
V8_INLINE PreParserExpression RewriteExponentiation(PreParserExpression left,
PreParserExpression right,
int pos) {
return left;
}
V8_INLINE PreParserExpression RewriteAssignExponentiation(
PreParserExpression left, PreParserExpression right, int pos) {
return left;
}
V8_INLINE PreParserExpression
RewriteAwaitExpression(PreParserExpression value, int pos) {
return value;
}
V8_INLINE PreParserExpression RewriteYieldStar(PreParserExpression generator,
PreParserExpression expression,
int pos) {
return PreParserExpression::Default();
}
V8_INLINE void RewriteNonPattern(Type::ExpressionClassifier* classifier,
bool* ok) {
ValidateExpression(classifier, ok);
}
V8_INLINE void QueueDestructuringAssignmentForRewriting(
PreParserExpression assignment) {}
V8_INLINE void QueueNonPatternForRewriting(PreParserExpression expr,
bool* ok) {}
int* use_counts_; int* use_counts_;
}; };
...@@ -1163,14 +1146,16 @@ void ParserBaseTraits<PreParser>::MaterializeUnspreadArgumentsLiterals( ...@@ -1163,14 +1146,16 @@ void ParserBaseTraits<PreParser>::MaterializeUnspreadArgumentsLiterals(
} }
} }
PreParserExpression ParserBaseTraits<PreParser>::SpreadCall( PreParserExpression PreParser::SpreadCall(PreParserExpression function,
PreParserExpression function, PreParserExpressionList args, int pos) { PreParserExpressionList args,
return delegate()->factory()->NewCall(function, args, pos); int pos) {
return factory()->NewCall(function, args, pos);
} }
PreParserExpression ParserBaseTraits<PreParser>::SpreadCallNew( PreParserExpression PreParser::SpreadCallNew(PreParserExpression function,
PreParserExpression function, PreParserExpressionList args, int pos) { PreParserExpressionList args,
return delegate()->factory()->NewCallNew(function, args, pos); int pos) {
return factory()->NewCallNew(function, args, pos);
} }
void ParserBaseTraits<PreParser>::ParseArrowFunctionFormalParameterList( void ParserBaseTraits<PreParser>::ParseArrowFunctionFormalParameterList(
...@@ -1181,25 +1166,6 @@ void ParserBaseTraits<PreParser>::ParseArrowFunctionFormalParameterList( ...@@ -1181,25 +1166,6 @@ void ParserBaseTraits<PreParser>::ParseArrowFunctionFormalParameterList(
// lists that are too long. // lists that are too long.
} }
PreParserExpression ParserBaseTraits<PreParser>::ParseAsyncFunctionExpression(
bool* ok) {
return delegate()->ParseAsyncFunctionExpression(ok);
}
PreParserExpression ParserBaseTraits<PreParser>::ParseDoExpression(bool* ok) {
return delegate()->ParseDoExpression(ok);
}
void ParserBaseTraits<PreParser>::RewriteNonPattern(
Type::ExpressionClassifier* classifier, bool* ok) {
delegate()->ValidateExpression(classifier, ok);
}
PreParserExpression ParserBaseTraits<PreParser>::RewriteAwaitExpression(
PreParserExpression value, int pos) {
return value;
}
ZoneList<PreParserExpression>* ParserBaseTraits<PreParser>::GetNonPatternList() ZoneList<PreParserExpression>* ParserBaseTraits<PreParser>::GetNonPatternList()
const { const {
return delegate()->function_state_->non_patterns_to_rewrite(); return delegate()->function_state_->non_patterns_to_rewrite();
...@@ -1215,11 +1181,6 @@ Zone* ParserBaseTraits<PreParser>::zone() const { ...@@ -1215,11 +1181,6 @@ Zone* ParserBaseTraits<PreParser>::zone() const {
return delegate()->function_state_->scope()->zone(); return delegate()->function_state_->scope()->zone();
} }
PreParserExpression ParserBaseTraits<PreParser>::RewriteYieldStar(
PreParserExpression generator, PreParserExpression expression, int pos) {
return PreParserExpression::Default();
}
PreParserStatementList PreParser::ParseEagerFunctionBody( PreParserStatementList PreParser::ParseEagerFunctionBody(
PreParserIdentifier function_name, int pos, PreParserIdentifier function_name, int pos,
const PreParserFormalParameters& parameters, FunctionKind kind, const PreParserFormalParameters& parameters, FunctionKind kind,
...@@ -1239,21 +1200,14 @@ PreParserStatementList PreParser::ParseEagerFunctionBody( ...@@ -1239,21 +1200,14 @@ PreParserStatementList PreParser::ParseEagerFunctionBody(
return PreParserStatementList(); return PreParserStatementList();
} }
PreParserStatementList ParserBaseTraits<PreParser>::ParseEagerFunctionBody( PreParserExpression PreParser::CloseTemplateLiteral(TemplateLiteralState* state,
PreParserIdentifier function_name, int pos, int start,
const PreParserFormalParameters& parameters, FunctionKind kind, PreParserExpression tag) {
FunctionLiteral::FunctionType function_type, bool* ok) {
return delegate()->ParseEagerFunctionBody(function_name, pos, parameters,
kind, function_type, ok);
}
PreParserExpression ParserBaseTraits<PreParser>::CloseTemplateLiteral(
TemplateLiteralState* state, int start, PreParserExpression tag) {
if (IsTaggedTemplate(tag)) { if (IsTaggedTemplate(tag)) {
// Emulate generation of array literals for tag callsite // Emulate generation of array literals for tag callsite
// 1st is array of cooked strings, second is array of raw strings // 1st is array of cooked strings, second is array of raw strings
delegate()->function_state_->NextMaterializedLiteralIndex(); function_state_->NextMaterializedLiteralIndex();
delegate()->function_state_->NextMaterializedLiteralIndex(); function_state_->NextMaterializedLiteralIndex();
} }
return EmptyExpression(); return EmptyExpression();
} }
......
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