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

Side by Side Diff: src/parsing/parser-base.h

Issue 1567603005: Set up rewriting triggers (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Merge RewriteExpression and ValidateExpression Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PARSING_PARSER_BASE_H 5 #ifndef V8_PARSING_PARSER_BASE_H
6 #define V8_PARSING_PARSER_BASE_H 6 #define V8_PARSING_PARSER_BASE_H
7 7
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/hashmap.h" 10 #include "src/hashmap.h"
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 ExpressionClassifier classifier; 1030 ExpressionClassifier classifier;
1031 auto result = ParseAndClassifyIdentifier(&classifier, ok); 1031 auto result = ParseAndClassifyIdentifier(&classifier, ok);
1032 if (!*ok) return Traits::EmptyIdentifier(); 1032 if (!*ok) return Traits::EmptyIdentifier();
1033 1033
1034 if (allow_restricted_identifiers == kDontAllowRestrictedIdentifiers) { 1034 if (allow_restricted_identifiers == kDontAllowRestrictedIdentifiers) {
1035 ValidateAssignmentPattern(&classifier, ok); 1035 ValidateAssignmentPattern(&classifier, ok);
1036 if (!*ok) return Traits::EmptyIdentifier(); 1036 if (!*ok) return Traits::EmptyIdentifier();
1037 ValidateBindingPattern(&classifier, ok); 1037 ValidateBindingPattern(&classifier, ok);
1038 if (!*ok) return Traits::EmptyIdentifier(); 1038 if (!*ok) return Traits::EmptyIdentifier();
1039 } else { 1039 } else {
1040 #if 0 // TODO(nikolaos): is this needed?
rossberg 2016/01/12 13:47:52 Yes, this is needed -- ParseAndClassifyIdentifier
nickie 2016/01/12 14:12:32 Acknowledged. I'm adding a test for this.
nickie 2016/01/12 15:16:09 Cannot find a test for this. This is the "else" c
rossberg 2016/01/14 13:28:40 Yes, I don't understand why this is the else case
nickie 2016/01/14 14:47:14 In the "then" case there is some validation. But
1040 ValidateExpression(&classifier, ok); 1041 ValidateExpression(&classifier, ok);
1041 if (!*ok) return Traits::EmptyIdentifier(); 1042 if (!*ok) return Traits::EmptyIdentifier();
1043 #endif
1042 } 1044 }
1043 1045
1044 return result; 1046 return result;
1045 } 1047 }
1046 1048
1047 1049
1048 template <class Traits> 1050 template <class Traits>
1049 typename ParserBase<Traits>::IdentifierT 1051 typename ParserBase<Traits>::IdentifierT
1050 ParserBase<Traits>::ParseAndClassifyIdentifier(ExpressionClassifier* classifier, 1052 ParserBase<Traits>::ParseAndClassifyIdentifier(ExpressionClassifier* classifier,
1051 bool* ok) { 1053 bool* ok) {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 Expect(Token::RPAREN, CHECK_OK); 1349 Expect(Token::RPAREN, CHECK_OK);
1348 return factory()->NewSpread(expr, ellipsis_pos); 1350 return factory()->NewSpread(expr, ellipsis_pos);
1349 } 1351 }
1350 // Heuristically try to detect immediately called functions before 1352 // Heuristically try to detect immediately called functions before
1351 // seeing the call parentheses. 1353 // seeing the call parentheses.
1352 parenthesized_function_ = (peek() == Token::FUNCTION); 1354 parenthesized_function_ = (peek() == Token::FUNCTION);
1353 ExpressionT expr = this->ParseExpression(true, kIsPossibleArrowFormals, 1355 ExpressionT expr = this->ParseExpression(true, kIsPossibleArrowFormals,
1354 classifier, CHECK_OK); 1356 classifier, CHECK_OK);
1355 Expect(Token::RPAREN, CHECK_OK); 1357 Expect(Token::RPAREN, CHECK_OK);
1356 if (peek() != Token::ARROW) { 1358 if (peek() != Token::ARROW) {
1359 #if 0 // TODO(nikolaos): is this needed?
rossberg 2016/01/12 13:47:52 Isn't this needed to catch syntax errors like "(()
caitp (gmail) 2016/01/12 13:50:39 This is needed to catch things like CoverInitializ
nickie 2016/01/12 14:12:32 Acknowledged. I'm adding a test for this.
nickie 2016/01/12 15:16:09 Cannot find a test for this either. It seems to m
nickie 2016/01/13 10:26:06 After Caitlin's patch for parenthesized patterns,
rossberg 2016/01/14 13:28:40 Hm, I wonder if it isn't a broader shortcoming tha
nickie 2016/01/14 14:47:14 There's two approaches, as I understand it. Eithe
caitp (gmail) 2016/01/14 15:06:25 Just a note about why the ValidateExpression was o
1357 ValidateExpression(classifier, CHECK_OK); 1360 ValidateExpression(classifier, CHECK_OK);
1361 #endif
1358 expr->set_is_parenthesized(); 1362 expr->set_is_parenthesized();
1359 } 1363 }
1360 return expr; 1364 return expr;
1361 } 1365 }
1362 1366
1363 case Token::CLASS: { 1367 case Token::CLASS: {
1364 BindingPatternUnexpectedToken(classifier); 1368 BindingPatternUnexpectedToken(classifier);
1365 Consume(Token::CLASS); 1369 Consume(Token::CLASS);
1366 if (!allow_harmony_sloppy() && is_sloppy(language_mode())) { 1370 if (!allow_harmony_sloppy() && is_sloppy(language_mode())) {
1367 ReportMessage(MessageTemplate::kSloppyLexical); 1371 ReportMessage(MessageTemplate::kSloppyLexical);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 *ok = false; 1416 *ok = false;
1413 return this->EmptyExpression(); 1417 return this->EmptyExpression();
1414 } 1418 }
1415 1419
1416 1420
1417 template <class Traits> 1421 template <class Traits>
1418 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseExpression( 1422 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseExpression(
1419 bool accept_IN, bool* ok) { 1423 bool accept_IN, bool* ok) {
1420 ExpressionClassifier classifier; 1424 ExpressionClassifier classifier;
1421 ExpressionT result = ParseExpression(accept_IN, &classifier, CHECK_OK); 1425 ExpressionT result = ParseExpression(accept_IN, &classifier, CHECK_OK);
1422 ValidateExpression(&classifier, CHECK_OK); 1426 result = Traits::RewriteExpression(result, &classifier, CHECK_OK);
1423 result = Traits::RewriteExpression(result);
1424 return result; 1427 return result;
1425 } 1428 }
1426 1429
1427 1430
1428 template <class Traits> 1431 template <class Traits>
1429 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseExpression( 1432 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseExpression(
1430 bool accept_IN, ExpressionClassifier* classifier, bool* ok) { 1433 bool accept_IN, ExpressionClassifier* classifier, bool* ok) {
1431 return ParseExpression(accept_IN, kIsLeftHandSide, classifier, ok); 1434 return ParseExpression(accept_IN, kIsLeftHandSide, classifier, ok);
1432 } 1435 }
1433 1436
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 Consume(Token::NUMBER); 1582 Consume(Token::NUMBER);
1580 *name = this->GetNumberAsSymbol(scanner()); 1583 *name = this->GetNumberAsSymbol(scanner());
1581 break; 1584 break;
1582 1585
1583 case Token::LBRACK: { 1586 case Token::LBRACK: {
1584 *is_computed_name = true; 1587 *is_computed_name = true;
1585 Consume(Token::LBRACK); 1588 Consume(Token::LBRACK);
1586 ExpressionClassifier computed_name_classifier; 1589 ExpressionClassifier computed_name_classifier;
1587 ExpressionT expression = 1590 ExpressionT expression =
1588 ParseAssignmentExpression(true, &computed_name_classifier, CHECK_OK); 1591 ParseAssignmentExpression(true, &computed_name_classifier, CHECK_OK);
1589 expression = Traits::RewriteExpression(expression); 1592 expression = Traits::RewriteExpression(
1593 expression, &computed_name_classifier, CHECK_OK);
1590 classifier->Accumulate(computed_name_classifier, 1594 classifier->Accumulate(computed_name_classifier,
1591 ExpressionClassifier::ExpressionProductions); 1595 ExpressionClassifier::ExpressionProductions);
1592 Expect(Token::RBRACK, CHECK_OK); 1596 Expect(Token::RBRACK, CHECK_OK);
1593 return expression; 1597 return expression;
1594 } 1598 }
1595 1599
1596 case Token::ESCAPED_KEYWORD: 1600 case Token::ESCAPED_KEYWORD:
1597 *is_escaped_keyword = true; 1601 *is_escaped_keyword = true;
1598 *name = ParseIdentifierNameOrGetOrSet(is_get, is_set, CHECK_OK); 1602 *name = ParseIdentifierNameOrGetOrSet(is_get, is_set, CHECK_OK);
1599 break; 1603 break;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 1697
1694 ExpressionT lhs = this->ExpressionFromIdentifier( 1698 ExpressionT lhs = this->ExpressionFromIdentifier(
1695 *name, next_beg_pos, next_end_pos, scope_, factory()); 1699 *name, next_beg_pos, next_end_pos, scope_, factory());
1696 CheckDestructuringElement(lhs, classifier, next_beg_pos, next_end_pos); 1700 CheckDestructuringElement(lhs, classifier, next_beg_pos, next_end_pos);
1697 1701
1698 if (peek() == Token::ASSIGN) { 1702 if (peek() == Token::ASSIGN) {
1699 Consume(Token::ASSIGN); 1703 Consume(Token::ASSIGN);
1700 ExpressionClassifier rhs_classifier; 1704 ExpressionClassifier rhs_classifier;
1701 ExpressionT rhs = this->ParseAssignmentExpression( 1705 ExpressionT rhs = this->ParseAssignmentExpression(
1702 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1706 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1703 rhs = Traits::RewriteExpression(rhs); 1707 rhs = Traits::RewriteExpression(
1708 rhs, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1704 classifier->Accumulate(rhs_classifier, 1709 classifier->Accumulate(rhs_classifier,
1705 ExpressionClassifier::ExpressionProductions); 1710 ExpressionClassifier::ExpressionProductions);
1706 value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs, 1711 value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs,
1707 RelocInfo::kNoPosition); 1712 RelocInfo::kNoPosition);
1708 classifier->RecordCoverInitializedNameError( 1713 classifier->RecordCoverInitializedNameError(
1709 Scanner::Location(next_beg_pos, scanner()->location().end_pos), 1714 Scanner::Location(next_beg_pos, scanner()->location().end_pos),
1710 MessageTemplate::kInvalidCoverInitializedName); 1715 MessageTemplate::kInvalidCoverInitializedName);
1711 } else { 1716 } else {
1712 value = lhs; 1717 value = lhs;
1713 } 1718 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 is_static, *is_computed_name); 1766 is_static, *is_computed_name);
1762 } 1767 }
1763 1768
1764 if (in_class && name_is_static && !is_static) { 1769 if (in_class && name_is_static && !is_static) {
1765 // ClassElement (static) 1770 // ClassElement (static)
1766 // 'static' MethodDefinition 1771 // 'static' MethodDefinition
1767 *name = this->EmptyIdentifier(); 1772 *name = this->EmptyIdentifier();
1768 ObjectLiteralPropertyT property = ParsePropertyDefinition( 1773 ObjectLiteralPropertyT property = ParsePropertyDefinition(
1769 checker, true, has_extends, true, is_computed_name, nullptr, classifier, 1774 checker, true, has_extends, true, is_computed_name, nullptr, classifier,
1770 name, ok); 1775 name, ok);
1771 property = Traits::RewriteObjectLiteralProperty(property); 1776 property = Traits::RewriteObjectLiteralProperty(property, classifier, ok);
1772 return property; 1777 return property;
1773 } 1778 }
1774 1779
1775 if (is_get || is_set) { 1780 if (is_get || is_set) {
1776 // MethodDefinition (Accessors) 1781 // MethodDefinition (Accessors)
1777 // get PropertyName '(' ')' '{' FunctionBody '}' 1782 // get PropertyName '(' ')' '{' FunctionBody '}'
1778 // set PropertyName '(' PropertySetParameterList ')' '{' FunctionBody '}' 1783 // set PropertyName '(' PropertySetParameterList ')' '{' FunctionBody '}'
1779 *name = this->EmptyIdentifier(); 1784 *name = this->EmptyIdentifier();
1780 bool dont_care = false; 1785 bool dont_care = false;
1781 name_token = peek(); 1786 name_token = peek();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 Expect(Token::LPAREN, CHECK_OK_CUSTOM(NullExpressionList)); 1906 Expect(Token::LPAREN, CHECK_OK_CUSTOM(NullExpressionList));
1902 bool done = (peek() == Token::RPAREN); 1907 bool done = (peek() == Token::RPAREN);
1903 bool was_unspread = false; 1908 bool was_unspread = false;
1904 int unspread_sequences_count = 0; 1909 int unspread_sequences_count = 0;
1905 while (!done) { 1910 while (!done) {
1906 int start_pos = peek_position(); 1911 int start_pos = peek_position();
1907 bool is_spread = Check(Token::ELLIPSIS); 1912 bool is_spread = Check(Token::ELLIPSIS);
1908 1913
1909 ExpressionT argument = this->ParseAssignmentExpression( 1914 ExpressionT argument = this->ParseAssignmentExpression(
1910 true, classifier, CHECK_OK_CUSTOM(NullExpressionList)); 1915 true, classifier, CHECK_OK_CUSTOM(NullExpressionList));
1911 argument = Traits::RewriteExpression(argument); 1916 argument = Traits::RewriteExpression(argument, classifier,
1917 CHECK_OK_CUSTOM(NullExpressionList));
1912 if (is_spread) { 1918 if (is_spread) {
1913 if (!spread_arg.IsValid()) { 1919 if (!spread_arg.IsValid()) {
1914 spread_arg.beg_pos = start_pos; 1920 spread_arg.beg_pos = start_pos;
1915 spread_arg.end_pos = peek_position(); 1921 spread_arg.end_pos = peek_position();
1916 } 1922 }
1917 argument = factory()->NewSpread(argument, start_pos); 1923 argument = factory()->NewSpread(argument, start_pos);
1918 } 1924 }
1919 result->Add(argument, zone_); 1925 result->Add(argument, zone_);
1920 1926
1921 // unspread_sequences_count is the number of sequences of parameters which 1927 // unspread_sequences_count is the number of sequences of parameters which
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 bool maybe_pattern = 2046 bool maybe_pattern =
2041 (expression->IsObjectLiteral() || expression->IsArrayLiteral()) && 2047 (expression->IsObjectLiteral() || expression->IsArrayLiteral()) &&
2042 !expression->is_parenthesized(); 2048 !expression->is_parenthesized();
2043 2049
2044 if (!Token::IsAssignmentOp(peek())) { 2050 if (!Token::IsAssignmentOp(peek())) {
2045 // Parsed conditional expression only (no assignment). 2051 // Parsed conditional expression only (no assignment).
2046 if (is_pattern_element) { 2052 if (is_pattern_element) {
2047 CheckDestructuringElement(expression, classifier, lhs_beg_pos, 2053 CheckDestructuringElement(expression, classifier, lhs_beg_pos,
2048 scanner()->location().end_pos); 2054 scanner()->location().end_pos);
2049 } else if (is_rhs && maybe_pattern) { 2055 } else if (is_rhs && maybe_pattern) {
2056 #if 0 // TODO(nikolaos): is this needed?
rossberg 2016/01/12 13:47:52 Hm, why is it not needed? Don't you even have to d
nickie 2016/01/12 14:12:32 I have a RewriteExpression at the place where the
caitp (gmail) 2016/01/12 14:25:55 It looks like you can remove this block, and the f
nickie 2016/01/12 15:16:09 Acknowledged.
2050 ValidateExpression(classifier, CHECK_OK); 2057 ValidateExpression(classifier, CHECK_OK);
2058 #endif
2051 } 2059 }
2052
2053 return expression; 2060 return expression;
2054 } 2061 }
2055 2062
2056 if (!(allow_harmony_destructuring_bind() || 2063 if (!(allow_harmony_destructuring_bind() ||
2057 allow_harmony_default_parameters())) { 2064 allow_harmony_default_parameters())) {
2058 BindingPatternUnexpectedToken(classifier); 2065 BindingPatternUnexpectedToken(classifier);
2059 } 2066 }
2060 2067
2061 if (allow_harmony_destructuring_assignment() && maybe_pattern && 2068 if (allow_harmony_destructuring_assignment() && maybe_pattern &&
2062 peek() == Token::ASSIGN) { 2069 peek() == Token::ASSIGN) {
(...skipping 24 matching lines...) Expand all
2087 } 2094 }
2088 int pos = position(); 2095 int pos = position();
2089 2096
2090 ExpressionClassifier rhs_classifier; 2097 ExpressionClassifier rhs_classifier;
2091 2098
2092 int rhs_flags = flags; 2099 int rhs_flags = flags;
2093 rhs_flags &= ~(kIsPatternElement | kIsPossibleArrowFormals); 2100 rhs_flags &= ~(kIsPatternElement | kIsPossibleArrowFormals);
2094 rhs_flags |= kIsRightHandSide; 2101 rhs_flags |= kIsRightHandSide;
2095 ExpressionT right = this->ParseAssignmentExpression( 2102 ExpressionT right = this->ParseAssignmentExpression(
2096 accept_IN, rhs_flags, &rhs_classifier, CHECK_OK); 2103 accept_IN, rhs_flags, &rhs_classifier, CHECK_OK);
2097 right = Traits::RewriteExpression(right); 2104 right = Traits::RewriteExpression(right, &rhs_classifier, CHECK_OK);
2098 classifier->Accumulate( 2105 classifier->Accumulate(
2099 rhs_classifier, ExpressionClassifier::ExpressionProductions | 2106 rhs_classifier, ExpressionClassifier::ExpressionProductions |
2100 ExpressionClassifier::CoverInitializedNameProduction); 2107 ExpressionClassifier::CoverInitializedNameProduction);
2101 2108
2102 // TODO(1231235): We try to estimate the set of properties set by 2109 // TODO(1231235): We try to estimate the set of properties set by
2103 // constructors. We define a new property whenever there is an 2110 // constructors. We define a new property whenever there is an
2104 // assignment to a property of 'this'. We should probably only add 2111 // assignment to a property of 'this'. We should probably only add
2105 // properties if we haven't seen them before. Otherwise we'll 2112 // properties if we haven't seen them before. Otherwise we'll
2106 // probably overestimate the number of properties. 2113 // probably overestimate the number of properties.
2107 if (op == Token::ASSIGN && this->IsThisProperty(expression)) { 2114 if (op == Token::ASSIGN && this->IsThisProperty(expression)) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2159 // The above set of tokens is the complete set of tokens that can appear 2166 // The above set of tokens is the complete set of tokens that can appear
2160 // after an AssignmentExpression, and none of them can start an 2167 // after an AssignmentExpression, and none of them can start an
2161 // AssignmentExpression. This allows us to avoid looking for an RHS for 2168 // AssignmentExpression. This allows us to avoid looking for an RHS for
2162 // a Yield::kSuspend operation, given only one look-ahead token. 2169 // a Yield::kSuspend operation, given only one look-ahead token.
2163 if (kind == Yield::kSuspend) 2170 if (kind == Yield::kSuspend)
2164 break; 2171 break;
2165 DCHECK_EQ(Yield::kDelegating, kind); 2172 DCHECK_EQ(Yield::kDelegating, kind);
2166 // Delegating yields require an RHS; fall through. 2173 // Delegating yields require an RHS; fall through.
2167 default: 2174 default:
2168 expression = ParseAssignmentExpression(false, classifier, CHECK_OK); 2175 expression = ParseAssignmentExpression(false, classifier, CHECK_OK);
2169 expression = Traits::RewriteExpression(expression); 2176 expression =
2177 Traits::RewriteExpression(expression, classifier, CHECK_OK);
2170 break; 2178 break;
2171 } 2179 }
2172 } 2180 }
2173 if (kind == Yield::kDelegating) { 2181 if (kind == Yield::kDelegating) {
2174 // var iterator = subject[Symbol.iterator](); 2182 // var iterator = subject[Symbol.iterator]();
2175 // Hackily disambiguate o from o.next and o [Symbol.iterator](). 2183 // Hackily disambiguate o from o.next and o [Symbol.iterator]().
2176 // TODO(verwaest): Come up with a better solution. 2184 // TODO(verwaest): Come up with a better solution.
2177 expression = this->GetIterator(expression, factory(), pos + 1); 2185 expression = this->GetIterator(expression, factory(), pos + 1);
2178 } 2186 }
2179 // Hackily disambiguate o from o.next and o [Symbol.iterator](). 2187 // Hackily disambiguate o from o.next and o [Symbol.iterator]().
(...skipping 12 matching lines...) Expand all
2192 bool* ok) { 2200 bool* ok) {
2193 // ConditionalExpression :: 2201 // ConditionalExpression ::
2194 // LogicalOrExpression 2202 // LogicalOrExpression
2195 // LogicalOrExpression '?' AssignmentExpression ':' AssignmentExpression 2203 // LogicalOrExpression '?' AssignmentExpression ':' AssignmentExpression
2196 2204
2197 int pos = peek_position(); 2205 int pos = peek_position();
2198 // We start using the binary expression parser for prec >= 4 only! 2206 // We start using the binary expression parser for prec >= 4 only!
2199 ExpressionT expression = 2207 ExpressionT expression =
2200 this->ParseBinaryExpression(4, accept_IN, classifier, CHECK_OK); 2208 this->ParseBinaryExpression(4, accept_IN, classifier, CHECK_OK);
2201 if (peek() != Token::CONDITIONAL) return expression; 2209 if (peek() != Token::CONDITIONAL) return expression;
2202 expression = Traits::RewriteExpression(expression); 2210 expression = Traits::RewriteExpression(expression, classifier, CHECK_OK);
2203 ArrowFormalParametersUnexpectedToken(classifier); 2211 ArrowFormalParametersUnexpectedToken(classifier);
2204 BindingPatternUnexpectedToken(classifier); 2212 BindingPatternUnexpectedToken(classifier);
2205 Consume(Token::CONDITIONAL); 2213 Consume(Token::CONDITIONAL);
2206 // In parsing the first assignment expression in conditional 2214 // In parsing the first assignment expression in conditional
2207 // expressions we always accept the 'in' keyword; see ECMA-262, 2215 // expressions we always accept the 'in' keyword; see ECMA-262,
2208 // section 11.12, page 58. 2216 // section 11.12, page 58.
2209 ExpressionT left = ParseAssignmentExpression(true, classifier, CHECK_OK); 2217 ExpressionT left = ParseAssignmentExpression(true, classifier, CHECK_OK);
2210 left = Traits::RewriteExpression(left); 2218 left = Traits::RewriteExpression(left, classifier, CHECK_OK);
2211 Expect(Token::COLON, CHECK_OK); 2219 Expect(Token::COLON, CHECK_OK);
2212 ExpressionT right = 2220 ExpressionT right =
2213 ParseAssignmentExpression(accept_IN, classifier, CHECK_OK); 2221 ParseAssignmentExpression(accept_IN, classifier, CHECK_OK);
2214 right = Traits::RewriteExpression(right); 2222 right = Traits::RewriteExpression(right, classifier, CHECK_OK);
2215 return factory()->NewConditional(expression, left, right, pos); 2223 return factory()->NewConditional(expression, left, right, pos);
2216 } 2224 }
2217 2225
2218 2226
2219 // Precedence >= 4 2227 // Precedence >= 4
2220 template <class Traits> 2228 template <class Traits>
2221 typename ParserBase<Traits>::ExpressionT 2229 typename ParserBase<Traits>::ExpressionT
2222 ParserBase<Traits>::ParseBinaryExpression(int prec, bool accept_IN, 2230 ParserBase<Traits>::ParseBinaryExpression(int prec, bool accept_IN,
2223 ExpressionClassifier* classifier, 2231 ExpressionClassifier* classifier,
2224 bool* ok) { 2232 bool* ok) {
2225 DCHECK(prec >= 4); 2233 DCHECK(prec >= 4);
2226 ExpressionT x = this->ParseUnaryExpression(classifier, CHECK_OK); 2234 ExpressionT x = this->ParseUnaryExpression(classifier, CHECK_OK);
2227 for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) { 2235 for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) {
2228 // prec1 >= 4 2236 // prec1 >= 4
2229 while (Precedence(peek(), accept_IN) == prec1) { 2237 while (Precedence(peek(), accept_IN) == prec1) {
2230 x = Traits::RewriteExpression(x); 2238 x = Traits::RewriteExpression(x, classifier, CHECK_OK);
2231 BindingPatternUnexpectedToken(classifier); 2239 BindingPatternUnexpectedToken(classifier);
2232 ArrowFormalParametersUnexpectedToken(classifier); 2240 ArrowFormalParametersUnexpectedToken(classifier);
2233 Token::Value op = Next(); 2241 Token::Value op = Next();
2234 Scanner::Location op_location = scanner()->location(); 2242 Scanner::Location op_location = scanner()->location();
2235 int pos = position(); 2243 int pos = position();
2236 ExpressionT y = 2244 ExpressionT y =
2237 ParseBinaryExpression(prec1 + 1, accept_IN, classifier, CHECK_OK); 2245 ParseBinaryExpression(prec1 + 1, accept_IN, classifier, CHECK_OK);
2238 y = Traits::RewriteExpression(y); 2246 y = Traits::RewriteExpression(y, classifier, CHECK_OK);
2239 2247
2240 if (this->ShortcutNumericLiteralBinaryExpression(&x, y, op, pos, 2248 if (this->ShortcutNumericLiteralBinaryExpression(&x, y, op, pos,
2241 factory())) { 2249 factory())) {
2242 continue; 2250 continue;
2243 } 2251 }
2244 2252
2245 // For now we distinguish between comparisons and other binary 2253 // For now we distinguish between comparisons and other binary
2246 // operations. (We could combine the two and get rid of this 2254 // operations. (We could combine the two and get rid of this
2247 // code and AST node eventually.) 2255 // code and AST node eventually.)
2248 if (Token::IsCompareOp(op)) { 2256 if (Token::IsCompareOp(op)) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2291 // '!' UnaryExpression 2299 // '!' UnaryExpression
2292 2300
2293 Token::Value op = peek(); 2301 Token::Value op = peek();
2294 if (Token::IsUnaryOp(op)) { 2302 if (Token::IsUnaryOp(op)) {
2295 BindingPatternUnexpectedToken(classifier); 2303 BindingPatternUnexpectedToken(classifier);
2296 ArrowFormalParametersUnexpectedToken(classifier); 2304 ArrowFormalParametersUnexpectedToken(classifier);
2297 2305
2298 op = Next(); 2306 op = Next();
2299 int pos = position(); 2307 int pos = position();
2300 ExpressionT expression = ParseUnaryExpression(classifier, CHECK_OK); 2308 ExpressionT expression = ParseUnaryExpression(classifier, CHECK_OK);
2301 expression = Traits::RewriteExpression(expression); 2309 expression = Traits::RewriteExpression(expression, classifier, CHECK_OK);
2302 2310
2303 if (op == Token::DELETE && is_strict(language_mode())) { 2311 if (op == Token::DELETE && is_strict(language_mode())) {
2304 if (is_strong(language_mode())) { 2312 if (is_strong(language_mode())) {
2305 ReportMessage(MessageTemplate::kStrongDelete); 2313 ReportMessage(MessageTemplate::kStrongDelete);
2306 *ok = false; 2314 *ok = false;
2307 return this->EmptyExpression(); 2315 return this->EmptyExpression();
2308 } else if (this->IsIdentifier(expression)) { 2316 } else if (this->IsIdentifier(expression)) {
2309 // "delete identifier" is a syntax error in strict mode. 2317 // "delete identifier" is a syntax error in strict mode.
2310 ReportMessage(MessageTemplate::kStrictDelete); 2318 ReportMessage(MessageTemplate::kStrictDelete);
2311 *ok = false; 2319 *ok = false;
2312 return this->EmptyExpression(); 2320 return this->EmptyExpression();
2313 } 2321 }
2314 } 2322 }
2315 2323
2316 // Allow Traits do rewrite the expression. 2324 // Allow Traits do rewrite the expression.
2317 return this->BuildUnaryExpression(expression, op, pos, factory()); 2325 return this->BuildUnaryExpression(expression, op, pos, factory());
2318 } else if (Token::IsCountOp(op)) { 2326 } else if (Token::IsCountOp(op)) {
2319 BindingPatternUnexpectedToken(classifier); 2327 BindingPatternUnexpectedToken(classifier);
2320 ArrowFormalParametersUnexpectedToken(classifier); 2328 ArrowFormalParametersUnexpectedToken(classifier);
2321 op = Next(); 2329 op = Next();
2322 int beg_pos = peek_position(); 2330 int beg_pos = peek_position();
2323 ExpressionT expression = this->ParseUnaryExpression(classifier, CHECK_OK); 2331 ExpressionT expression = this->ParseUnaryExpression(classifier, CHECK_OK);
2324 expression = this->CheckAndRewriteReferenceExpression( 2332 expression = this->CheckAndRewriteReferenceExpression(
2325 expression, beg_pos, scanner()->location().end_pos, 2333 expression, beg_pos, scanner()->location().end_pos,
2326 MessageTemplate::kInvalidLhsInPrefixOp, CHECK_OK); 2334 MessageTemplate::kInvalidLhsInPrefixOp, CHECK_OK);
2327 this->MarkExpressionAsAssigned(expression); 2335 this->MarkExpressionAsAssigned(expression);
2328 expression = Traits::RewriteExpression(expression); 2336 expression = Traits::RewriteExpression(expression, classifier, CHECK_OK);
2329 2337
2330 return factory()->NewCountOperation(op, 2338 return factory()->NewCountOperation(op,
2331 true /* prefix */, 2339 true /* prefix */,
2332 expression, 2340 expression,
2333 position()); 2341 position());
2334 2342
2335 } else { 2343 } else {
2336 return this->ParsePostfixExpression(classifier, ok); 2344 return this->ParsePostfixExpression(classifier, ok);
2337 } 2345 }
2338 } 2346 }
(...skipping 11 matching lines...) Expand all
2350 this->ParseLeftHandSideExpression(classifier, CHECK_OK); 2358 this->ParseLeftHandSideExpression(classifier, CHECK_OK);
2351 if (!scanner()->HasAnyLineTerminatorBeforeNext() && 2359 if (!scanner()->HasAnyLineTerminatorBeforeNext() &&
2352 Token::IsCountOp(peek())) { 2360 Token::IsCountOp(peek())) {
2353 BindingPatternUnexpectedToken(classifier); 2361 BindingPatternUnexpectedToken(classifier);
2354 ArrowFormalParametersUnexpectedToken(classifier); 2362 ArrowFormalParametersUnexpectedToken(classifier);
2355 2363
2356 expression = this->CheckAndRewriteReferenceExpression( 2364 expression = this->CheckAndRewriteReferenceExpression(
2357 expression, lhs_beg_pos, scanner()->location().end_pos, 2365 expression, lhs_beg_pos, scanner()->location().end_pos,
2358 MessageTemplate::kInvalidLhsInPostfixOp, CHECK_OK); 2366 MessageTemplate::kInvalidLhsInPostfixOp, CHECK_OK);
2359 expression = this->MarkExpressionAsAssigned(expression); 2367 expression = this->MarkExpressionAsAssigned(expression);
2368 expression = Traits::RewriteExpression(expression, classifier, CHECK_OK);
2360 2369
2361 Token::Value next = Next(); 2370 Token::Value next = Next();
2362 expression = 2371 expression =
2363 factory()->NewCountOperation(next, 2372 factory()->NewCountOperation(next,
2364 false /* postfix */, 2373 false /* postfix */,
2365 expression, 2374 expression,
2366 position()); 2375 position());
2367 } 2376 }
2368 return expression; 2377 return expression;
2369 } 2378 }
(...skipping 10 matching lines...) Expand all
2380 this->ParseMemberWithNewPrefixesExpression(classifier, CHECK_OK); 2389 this->ParseMemberWithNewPrefixesExpression(classifier, CHECK_OK);
2381 2390
2382 while (true) { 2391 while (true) {
2383 switch (peek()) { 2392 switch (peek()) {
2384 case Token::LBRACK: { 2393 case Token::LBRACK: {
2385 BindingPatternUnexpectedToken(classifier); 2394 BindingPatternUnexpectedToken(classifier);
2386 ArrowFormalParametersUnexpectedToken(classifier); 2395 ArrowFormalParametersUnexpectedToken(classifier);
2387 Consume(Token::LBRACK); 2396 Consume(Token::LBRACK);
2388 int pos = position(); 2397 int pos = position();
2389 ExpressionT index = ParseExpression(true, classifier, CHECK_OK); 2398 ExpressionT index = ParseExpression(true, classifier, CHECK_OK);
2390 index = Traits::RewriteExpression(index); 2399 index = Traits::RewriteExpression(index, classifier, CHECK_OK);
2391 result = factory()->NewProperty(result, index, pos); 2400 result = factory()->NewProperty(result, index, pos);
2392 Expect(Token::RBRACK, CHECK_OK); 2401 Expect(Token::RBRACK, CHECK_OK);
2393 break; 2402 break;
2394 } 2403 }
2395 2404
2396 case Token::LPAREN: { 2405 case Token::LPAREN: {
2397 result = Traits::RewriteExpression(result); 2406 result = Traits::RewriteExpression(result, classifier, CHECK_OK);
2398 BindingPatternUnexpectedToken(classifier); 2407 BindingPatternUnexpectedToken(classifier);
2399 ArrowFormalParametersUnexpectedToken(classifier); 2408 ArrowFormalParametersUnexpectedToken(classifier);
2400 2409
2401 if (is_strong(language_mode()) && this->IsIdentifier(result) && 2410 if (is_strong(language_mode()) && this->IsIdentifier(result) &&
2402 this->IsEval(this->AsIdentifier(result))) { 2411 this->IsEval(this->AsIdentifier(result))) {
2403 ReportMessage(MessageTemplate::kStrongDirectEval); 2412 ReportMessage(MessageTemplate::kStrongDirectEval);
2404 *ok = false; 2413 *ok = false;
2405 return this->EmptyExpression(); 2414 return this->EmptyExpression();
2406 } 2415 }
2407 int pos; 2416 int pos;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 int new_pos = position(); 2524 int new_pos = position();
2516 ExpressionT result = this->EmptyExpression(); 2525 ExpressionT result = this->EmptyExpression();
2517 if (peek() == Token::SUPER) { 2526 if (peek() == Token::SUPER) {
2518 const bool is_new = true; 2527 const bool is_new = true;
2519 result = ParseSuperExpression(is_new, classifier, CHECK_OK); 2528 result = ParseSuperExpression(is_new, classifier, CHECK_OK);
2520 } else if (peek() == Token::PERIOD) { 2529 } else if (peek() == Token::PERIOD) {
2521 return ParseNewTargetExpression(CHECK_OK); 2530 return ParseNewTargetExpression(CHECK_OK);
2522 } else { 2531 } else {
2523 result = this->ParseMemberWithNewPrefixesExpression(classifier, CHECK_OK); 2532 result = this->ParseMemberWithNewPrefixesExpression(classifier, CHECK_OK);
2524 } 2533 }
2525 result = Traits::RewriteExpression(result); 2534 result = Traits::RewriteExpression(result, classifier, CHECK_OK);
2526 if (peek() == Token::LPAREN) { 2535 if (peek() == Token::LPAREN) {
2527 // NewExpression with arguments. 2536 // NewExpression with arguments.
2528 Scanner::Location spread_pos; 2537 Scanner::Location spread_pos;
2529 typename Traits::Type::ExpressionList args = 2538 typename Traits::Type::ExpressionList args =
2530 this->ParseArguments(&spread_pos, classifier, CHECK_OK); 2539 this->ParseArguments(&spread_pos, classifier, CHECK_OK);
2531 2540
2532 if (spread_pos.IsValid()) { 2541 if (spread_pos.IsValid()) {
2533 args = Traits::PrepareSpreadArguments(args); 2542 args = Traits::PrepareSpreadArguments(args);
2534 result = Traits::SpreadCallNew(result, args, new_pos); 2543 result = Traits::SpreadCallNew(result, args, new_pos);
2535 } else { 2544 } else {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2615 int pos = position(); 2624 int pos = position();
2616 function_state_->set_this_location(scanner()->location()); 2625 function_state_->set_this_location(scanner()->location());
2617 ExpressionT this_expr = this->ThisExpression(scope_, factory(), pos); 2626 ExpressionT this_expr = this->ThisExpression(scope_, factory(), pos);
2618 2627
2619 ExpressionT left = this->EmptyExpression(); 2628 ExpressionT left = this->EmptyExpression();
2620 switch (peek()) { 2629 switch (peek()) {
2621 case Token::LBRACK: { 2630 case Token::LBRACK: {
2622 Consume(Token::LBRACK); 2631 Consume(Token::LBRACK);
2623 int pos = position(); 2632 int pos = position();
2624 ExpressionT index = this->ParseExpression(true, classifier, CHECK_OK); 2633 ExpressionT index = this->ParseExpression(true, classifier, CHECK_OK);
2625 index = Traits::RewriteExpression(index); 2634 index = Traits::RewriteExpression(index, classifier, CHECK_OK);
2626 left = factory()->NewProperty(this_expr, index, pos); 2635 left = factory()->NewProperty(this_expr, index, pos);
2627 if (fni_ != NULL) { 2636 if (fni_ != NULL) {
2628 this->PushPropertyName(fni_, index); 2637 this->PushPropertyName(fni_, index);
2629 } 2638 }
2630 Expect(Token::RBRACK, CHECK_OK); 2639 Expect(Token::RBRACK, CHECK_OK);
2631 break; 2640 break;
2632 } 2641 }
2633 case Token::PERIOD: { 2642 case Token::PERIOD: {
2634 Consume(Token::PERIOD); 2643 Consume(Token::PERIOD);
2635 int pos = position(); 2644 int pos = position();
(...skipping 15 matching lines...) Expand all
2651 ReportMessageAt(function_state_->this_location(), 2660 ReportMessageAt(function_state_->this_location(),
2652 MessageTemplate::kStrongConstructorThis); 2661 MessageTemplate::kStrongConstructorThis);
2653 *ok = false; 2662 *ok = false;
2654 return this->EmptyExpression(); 2663 return this->EmptyExpression();
2655 } 2664 }
2656 Consume(Token::ASSIGN); 2665 Consume(Token::ASSIGN);
2657 left = this->MarkExpressionAsAssigned(left); 2666 left = this->MarkExpressionAsAssigned(left);
2658 2667
2659 ExpressionT right = 2668 ExpressionT right =
2660 this->ParseAssignmentExpression(true, classifier, CHECK_OK); 2669 this->ParseAssignmentExpression(true, classifier, CHECK_OK);
2661 right = Traits::RewriteExpression(right); 2670 right = Traits::RewriteExpression(right, classifier, CHECK_OK);
2662 this->CheckAssigningFunctionLiteralToProperty(left, right); 2671 this->CheckAssigningFunctionLiteralToProperty(left, right);
2663 function_state_->AddProperty(); 2672 function_state_->AddProperty();
2664 if (fni_ != NULL) { 2673 if (fni_ != NULL) {
2665 // Check if the right hand side is a call to avoid inferring a 2674 // Check if the right hand side is a call to avoid inferring a
2666 // name if we're dealing with "this.a = function(){...}();"-like 2675 // name if we're dealing with "this.a = function(){...}();"-like
2667 // expression. 2676 // expression.
2668 if (!right->IsCall() && !right->IsCallNew()) { 2677 if (!right->IsCall() && !right->IsCallNew()) {
2669 fni_->Infer(); 2678 fni_->Infer();
2670 } else { 2679 } else {
2671 fni_->RemoveLastFunction(); 2680 fni_->RemoveLastFunction();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2808 // ('[' Expression ']' | '.' Identifier | TemplateLiteral)* 2817 // ('[' Expression ']' | '.' Identifier | TemplateLiteral)*
2809 while (true) { 2818 while (true) {
2810 switch (peek()) { 2819 switch (peek()) {
2811 case Token::LBRACK: { 2820 case Token::LBRACK: {
2812 BindingPatternUnexpectedToken(classifier); 2821 BindingPatternUnexpectedToken(classifier);
2813 ArrowFormalParametersUnexpectedToken(classifier); 2822 ArrowFormalParametersUnexpectedToken(classifier);
2814 2823
2815 Consume(Token::LBRACK); 2824 Consume(Token::LBRACK);
2816 int pos = position(); 2825 int pos = position();
2817 ExpressionT index = this->ParseExpression(true, classifier, CHECK_OK); 2826 ExpressionT index = this->ParseExpression(true, classifier, CHECK_OK);
2818 index = Traits::RewriteExpression(index); 2827 index = Traits::RewriteExpression(index, classifier, CHECK_OK);
2819 expression = factory()->NewProperty(expression, index, pos); 2828 expression = factory()->NewProperty(expression, index, pos);
2820 if (fni_ != NULL) { 2829 if (fni_ != NULL) {
2821 this->PushPropertyName(fni_, index); 2830 this->PushPropertyName(fni_, index);
2822 } 2831 }
2823 Expect(Token::RBRACK, CHECK_OK); 2832 Expect(Token::RBRACK, CHECK_OK);
2824 break; 2833 break;
2825 } 2834 }
2826 case Token::PERIOD: { 2835 case Token::PERIOD: {
2827 BindingPatternUnexpectedToken(classifier); 2836 BindingPatternUnexpectedToken(classifier);
2828 ArrowFormalParametersUnexpectedToken(classifier); 2837 ArrowFormalParametersUnexpectedToken(classifier);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2889 ValidateFormalParameterInitializer(classifier, ok); 2898 ValidateFormalParameterInitializer(classifier, ok);
2890 if (!*ok) return; 2899 if (!*ok) return;
2891 classifier->RecordNonSimpleParameter(); 2900 classifier->RecordNonSimpleParameter();
2892 } 2901 }
2893 2902
2894 ExpressionT initializer = Traits::EmptyExpression(); 2903 ExpressionT initializer = Traits::EmptyExpression();
2895 if (!is_rest && allow_harmony_default_parameters() && Check(Token::ASSIGN)) { 2904 if (!is_rest && allow_harmony_default_parameters() && Check(Token::ASSIGN)) {
2896 ExpressionClassifier init_classifier; 2905 ExpressionClassifier init_classifier;
2897 initializer = ParseAssignmentExpression(true, &init_classifier, ok); 2906 initializer = ParseAssignmentExpression(true, &init_classifier, ok);
2898 if (!*ok) return; 2907 if (!*ok) return;
2899 ValidateExpression(&init_classifier, ok); 2908 initializer = Traits::RewriteExpression(initializer, &init_classifier, ok);
2900 ValidateFormalParameterInitializer(&init_classifier, ok); 2909 ValidateFormalParameterInitializer(&init_classifier, ok);
2901 if (!*ok) return; 2910 if (!*ok) return;
2902 initializer = Traits::RewriteExpression(initializer);
2903 parameters->is_simple = false; 2911 parameters->is_simple = false;
2904 classifier->RecordNonSimpleParameter(); 2912 classifier->RecordNonSimpleParameter();
2905 } 2913 }
2906 2914
2907 Traits::AddFormalParameter(parameters, pattern, initializer, 2915 Traits::AddFormalParameter(parameters, pattern, initializer,
2908 scanner()->location().end_pos, is_rest); 2916 scanner()->location().end_pos, is_rest);
2909 } 2917 }
2910 2918
2911 2919
2912 template <class Traits> 2920 template <class Traits>
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
3064 function_state.materialized_literal_count(); 3072 function_state.materialized_literal_count();
3065 expected_property_count = function_state.expected_property_count(); 3073 expected_property_count = function_state.expected_property_count();
3066 } 3074 }
3067 } else { 3075 } else {
3068 // Single-expression body 3076 // Single-expression body
3069 int pos = position(); 3077 int pos = position();
3070 parenthesized_function_ = false; 3078 parenthesized_function_ = false;
3071 ExpressionClassifier classifier; 3079 ExpressionClassifier classifier;
3072 ExpressionT expression = 3080 ExpressionT expression =
3073 ParseAssignmentExpression(accept_IN, &classifier, CHECK_OK); 3081 ParseAssignmentExpression(accept_IN, &classifier, CHECK_OK);
3074 ValidateExpression(&classifier, CHECK_OK); 3082 expression = Traits::RewriteExpression(expression, &classifier, CHECK_OK);
3075 expression = Traits::RewriteExpression(expression);
3076 body = this->NewStatementList(1, zone()); 3083 body = this->NewStatementList(1, zone());
3077 this->AddParameterInitializationBlock(formal_parameters, body, CHECK_OK); 3084 this->AddParameterInitializationBlock(formal_parameters, body, CHECK_OK);
3078 body->Add(factory()->NewReturnStatement(expression, pos), zone()); 3085 body->Add(factory()->NewReturnStatement(expression, pos), zone());
3079 materialized_literal_count = function_state.materialized_literal_count(); 3086 materialized_literal_count = function_state.materialized_literal_count();
3080 expected_property_count = function_state.expected_property_count(); 3087 expected_property_count = function_state.expected_property_count();
3081 } 3088 }
3082 super_loc = function_state.super_location(); 3089 super_loc = function_state.super_location();
3083 3090
3084 formal_parameters.scope->set_end_position(scanner()->location().end_pos); 3091 formal_parameters.scope->set_end_position(scanner()->location().end_pos);
3085 3092
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
3171 } else if (next == Token::ILLEGAL) { 3178 } else if (next == Token::ILLEGAL) {
3172 Traits::ReportMessageAt( 3179 Traits::ReportMessageAt(
3173 Scanner::Location(position() + 1, peek_position()), 3180 Scanner::Location(position() + 1, peek_position()),
3174 MessageTemplate::kUnexpectedToken, "ILLEGAL", kSyntaxError); 3181 MessageTemplate::kUnexpectedToken, "ILLEGAL", kSyntaxError);
3175 *ok = false; 3182 *ok = false;
3176 return Traits::EmptyExpression(); 3183 return Traits::EmptyExpression();
3177 } 3184 }
3178 3185
3179 int expr_pos = peek_position(); 3186 int expr_pos = peek_position();
3180 ExpressionT expression = this->ParseExpression(true, classifier, CHECK_OK); 3187 ExpressionT expression = this->ParseExpression(true, classifier, CHECK_OK);
3181 expression = Traits::RewriteExpression(expression); 3188 expression = Traits::RewriteExpression(expression, classifier, CHECK_OK);
3182 Traits::AddTemplateExpression(&ts, expression); 3189 Traits::AddTemplateExpression(&ts, expression);
3183 3190
3184 if (peek() != Token::RBRACE) { 3191 if (peek() != Token::RBRACE) {
3185 ReportMessageAt(Scanner::Location(expr_pos, peek_position()), 3192 ReportMessageAt(Scanner::Location(expr_pos, peek_position()),
3186 MessageTemplate::kUnterminatedTemplateExpr); 3193 MessageTemplate::kUnterminatedTemplateExpr);
3187 *ok = false; 3194 *ok = false;
3188 return Traits::EmptyExpression(); 3195 return Traits::EmptyExpression();
3189 } 3196 }
3190 3197
3191 // If we didn't die parsing that expression, our next token should be a 3198 // If we didn't die parsing that expression, our next token should be a
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
3354 return; 3361 return;
3355 } 3362 }
3356 has_seen_constructor_ = true; 3363 has_seen_constructor_ = true;
3357 return; 3364 return;
3358 } 3365 }
3359 } 3366 }
3360 } // namespace internal 3367 } // namespace internal
3361 } // namespace v8 3368 } // namespace v8
3362 3369
3363 #endif // V8_PARSING_PARSER_BASE_H 3370 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« src/parsing/parser.h ('K') | « src/parsing/parser.cc ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698