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

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: Fix tagged template NewExpression case 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') | test/mjsunit/harmony/templates.js » ('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..80f269f6bd0f7cef5c0568b01f4797ded8e0de6a 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -2653,23 +2653,6 @@ ParserBase<Traits>::ParseLeftHandSideExpression(bool* ok) {
break;
}
- 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);
- break;
- }
-
case Token::PERIOD: {
Consume(Token::PERIOD);
int pos = position();
@@ -2725,6 +2708,10 @@ ParserBase<Traits>::ParseMemberWithNewPrefixesExpression(bool* ok) {
// The expression can still continue with . or [ after the arguments.
result = this->ParseMemberExpressionContinuation(result, CHECK_OK);
return result;
+ } else if (peek() == Token::TEMPLATE_SPAN ||
+ peek() == Token::TEMPLATE_TAIL) {
+ // new tag`a` -> new(tag`a`)
marja 2015/03/12 11:43:35 Pls move this comment up in the comment block, it'
caitp (gmail) 2015/03/12 13:34:15 this whole block seems to be unneeded, since Parse
+ result = this->ParseMemberExpressionContinuation(result, CHECK_OK);
}
// NewExpression without arguments.
return factory()->NewCallNew(result, this->NewExpressionList(0, zone_),
@@ -2817,7 +2804,7 @@ typename ParserBase<Traits>::ExpressionT
ParserBase<Traits>::ParseMemberExpressionContinuation(ExpressionT expression,
bool* ok) {
// Parses this part of MemberExpression:
marja 2015/03/12 11:43:35 You probably need to change the comment in ParseMe
- // ('[' Expression ']' | '.' Identifier)*
+ // ('[' Expression ']' | '.' Identifier | TemplateLiteral)*
while (true) {
switch (peek()) {
case Token::LBRACK: {
@@ -2842,6 +2829,22 @@ ParserBase<Traits>::ParseMemberExpressionContinuation(ExpressionT expression,
}
break;
}
+ case Token::TEMPLATE_SPAN:
+ case Token::TEMPLATE_TAIL: {
+ 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();
+ }
+ }
+ expression = ParseTemplateLiteral(expression, pos, CHECK_OK);
+ break;
+ }
default:
return expression;
}
« no previous file with comments | « no previous file | src/scanner.h » ('j') | test/mjsunit/harmony/templates.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698