Index: src/preparser.h |
diff --git a/src/preparser.h b/src/preparser.h |
index a17296349b362df6afefbb5b8538d7c030915270..8e0bacb463b591d8e0bac68f10163f54d072fbce 100644 |
--- a/src/preparser.h |
+++ b/src/preparser.h |
@@ -589,6 +589,8 @@ class ParserBase : public Traits { |
ExpressionT ParseArrowFunctionLiteral(int start_pos, ExpressionT params_ast, |
bool* ok); |
ExpressionT ParseTemplateLiteral(ExpressionT tag, int start, bool* ok); |
+ ExpressionT ParseTemplateLiteralAsMemberExpressionContinuation( |
+ ExpressionT tag, bool* ok); |
void AddTemplateExpression(ExpressionT); |
ExpressionT ParseSuperExpression(bool is_new, bool* ok); |
@@ -2655,18 +2657,8 @@ ParserBase<Traits>::ParseLeftHandSideExpression(bool* ok) { |
case Token::TEMPLATE_SPAN: |
case Token::TEMPLATE_TAIL: { |
- int pos; |
- if (scanner()->current_token() == Token::IDENTIFIER) { |
- pos = position(); |
- } else { |
- pos = peek_position(); |
- if (result->IsFunctionLiteral() && mode() == PARSE_EAGERLY) { |
- // If the tag function looks like an IIFE, set_parenthesized() to |
- // force eager compilation. |
- result->AsFunctionLiteral()->set_parenthesized(); |
- } |
- } |
- result = ParseTemplateLiteral(result, pos, CHECK_OK); |
+ result = ParseTemplateLiteralAsMemberExpressionContinuation( |
+ result, CHECK_OK); |
break; |
} |
@@ -2842,6 +2834,12 @@ ParserBase<Traits>::ParseMemberExpressionContinuation(ExpressionT expression, |
} |
break; |
} |
+ case Token::TEMPLATE_SPAN: |
+ case Token::TEMPLATE_TAIL: { |
+ expression = ParseTemplateLiteralAsMemberExpressionContinuation( |
+ expression, CHECK_OK); |
+ break; |
+ } |
default: |
return expression; |
} |
@@ -2853,6 +2851,25 @@ ParserBase<Traits>::ParseMemberExpressionContinuation(ExpressionT expression, |
template <class Traits> |
typename ParserBase<Traits>::ExpressionT |
+ParserBase<Traits>::ParseTemplateLiteralAsMemberExpressionContinuation( |
+ ExpressionT expression, bool* ok) { |
+ int pos; |
+ if (scanner()->current_token() == Token::IDENTIFIER) { |
+ pos = position(); |
+ } else { |
+ pos = peek_position(); |
+ if (expression->IsFunctionLiteral() && mode() == PARSE_EAGERLY) { |
+ // If the tag function looks like an IIFE, set_parenthesized() to |
+ // force eager compilation. |
+ expression->AsFunctionLiteral()->set_parenthesized(); |
+ } |
+ } |
+ return ParseTemplateLiteral(expression, pos, CHECK_OK); |
+} |
+ |
+ |
+template <class Traits> |
+typename ParserBase<Traits>::ExpressionT |
ParserBase<Traits>::ParseArrowFunctionLiteral(int start_pos, |
ExpressionT params_ast, |
bool* ok) { |