Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: src/preparser.h

Issue 996223003: [es6] support template literals after MemberExpression (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Delete meaningless edit Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/scanner.h » ('j') | src/scanner.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « no previous file | src/scanner.h » ('j') | src/scanner.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698