OLD | NEW |
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 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 return factory()->NewSpread(expr, ellipsis_pos); | 1358 return factory()->NewSpread(expr, ellipsis_pos); |
1359 } | 1359 } |
1360 // Heuristically try to detect immediately called functions before | 1360 // Heuristically try to detect immediately called functions before |
1361 // seeing the call parentheses. | 1361 // seeing the call parentheses. |
1362 parenthesized_function_ = (peek() == Token::FUNCTION); | 1362 parenthesized_function_ = (peek() == Token::FUNCTION); |
1363 ExpressionT expr = this->ParseExpression(true, kIsPossibleArrowFormals, | 1363 ExpressionT expr = this->ParseExpression(true, kIsPossibleArrowFormals, |
1364 classifier, CHECK_OK); | 1364 classifier, CHECK_OK); |
1365 Expect(Token::RPAREN, CHECK_OK); | 1365 Expect(Token::RPAREN, CHECK_OK); |
1366 if (peek() != Token::ARROW) { | 1366 if (peek() != Token::ARROW) { |
1367 ValidateExpression(classifier, CHECK_OK); | 1367 ValidateExpression(classifier, CHECK_OK); |
| 1368 expr->set_is_parenthesized(); |
1368 } | 1369 } |
1369 return expr; | 1370 return expr; |
1370 } | 1371 } |
1371 | 1372 |
1372 case Token::CLASS: { | 1373 case Token::CLASS: { |
1373 BindingPatternUnexpectedToken(classifier); | 1374 BindingPatternUnexpectedToken(classifier); |
1374 Consume(Token::CLASS); | 1375 Consume(Token::CLASS); |
1375 if (!allow_harmony_sloppy() && is_sloppy(language_mode())) { | 1376 if (!allow_harmony_sloppy() && is_sloppy(language_mode())) { |
1376 ReportMessage(MessageTemplate::kSloppyLexical); | 1377 ReportMessage(MessageTemplate::kSloppyLexical); |
1377 *ok = false; | 1378 *ok = false; |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2034 | 2035 |
2035 // "expression" was not itself an arrow function parameter list, but it might | 2036 // "expression" was not itself an arrow function parameter list, but it might |
2036 // form part of one. Propagate speculative formal parameter error locations. | 2037 // form part of one. Propagate speculative formal parameter error locations. |
2037 classifier->Accumulate( | 2038 classifier->Accumulate( |
2038 arrow_formals_classifier, | 2039 arrow_formals_classifier, |
2039 ExpressionClassifier::StandardProductions | | 2040 ExpressionClassifier::StandardProductions | |
2040 ExpressionClassifier::FormalParametersProductions | | 2041 ExpressionClassifier::FormalParametersProductions | |
2041 ExpressionClassifier::CoverInitializedNameProduction); | 2042 ExpressionClassifier::CoverInitializedNameProduction); |
2042 | 2043 |
2043 bool maybe_pattern = | 2044 bool maybe_pattern = |
2044 expression->IsObjectLiteral() || expression->IsArrayLiteral(); | 2045 (expression->IsObjectLiteral() || expression->IsArrayLiteral()) && |
| 2046 !expression->is_parenthesized(); |
2045 | 2047 |
2046 if (!Token::IsAssignmentOp(peek())) { | 2048 if (!Token::IsAssignmentOp(peek())) { |
2047 // Parsed conditional expression only (no assignment). | 2049 // Parsed conditional expression only (no assignment). |
2048 if (is_pattern_element) { | 2050 if (is_pattern_element) { |
2049 CheckDestructuringElement(expression, classifier, lhs_beg_pos, | 2051 CheckDestructuringElement(expression, classifier, lhs_beg_pos, |
2050 scanner()->location().end_pos); | 2052 scanner()->location().end_pos); |
2051 } else if (is_rhs && maybe_pattern) { | 2053 } else if (is_rhs && maybe_pattern) { |
2052 ValidateExpression(classifier, CHECK_OK); | 2054 ValidateExpression(classifier, CHECK_OK); |
2053 } | 2055 } |
2054 | 2056 |
(...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3339 return; | 3341 return; |
3340 } | 3342 } |
3341 has_seen_constructor_ = true; | 3343 has_seen_constructor_ = true; |
3342 return; | 3344 return; |
3343 } | 3345 } |
3344 } | 3346 } |
3345 } // namespace internal | 3347 } // namespace internal |
3346 } // namespace v8 | 3348 } // namespace v8 |
3347 | 3349 |
3348 #endif // V8_PARSING_PARSER_BASE_H | 3350 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |