| 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 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1322 return factory()->NewEmptyParentheses(beg_pos); | 1322 return factory()->NewEmptyParentheses(beg_pos); |
| 1323 } else if (Check(Token::ELLIPSIS)) { | 1323 } else if (Check(Token::ELLIPSIS)) { |
| 1324 // (...x)=>x. The continuation that looks for the => is in | 1324 // (...x)=>x. The continuation that looks for the => is in |
| 1325 // ParseAssignmentExpression. | 1325 // ParseAssignmentExpression. |
| 1326 int ellipsis_pos = position(); | 1326 int ellipsis_pos = position(); |
| 1327 int expr_pos = peek_position(); | 1327 int expr_pos = peek_position(); |
| 1328 classifier->RecordExpressionError(scanner()->location(), | 1328 classifier->RecordExpressionError(scanner()->location(), |
| 1329 MessageTemplate::kUnexpectedToken, | 1329 MessageTemplate::kUnexpectedToken, |
| 1330 Token::String(Token::ELLIPSIS)); | 1330 Token::String(Token::ELLIPSIS)); |
| 1331 classifier->RecordNonSimpleParameter(); | 1331 classifier->RecordNonSimpleParameter(); |
| 1332 ExpressionT expr = | 1332 ExpressionT expr = this->ParseAssignmentExpression( |
| 1333 this->ParseAssignmentExpression(true, classifier, CHECK_OK); | 1333 true, kIsPossibleArrowFormals, classifier, CHECK_OK); |
| 1334 if (!this->IsIdentifier(expr) && !expr->IsObjectLiteral() && |
| 1335 !expr->IsArrayLiteral()) { |
| 1336 classifier->RecordArrowFormalParametersError( |
| 1337 Scanner::Location(ellipsis_pos, scanner()->location().end_pos), |
| 1338 MessageTemplate::kInvalidRestParameter); |
| 1339 } |
| 1334 if (peek() == Token::COMMA) { | 1340 if (peek() == Token::COMMA) { |
| 1335 ReportMessageAt(scanner()->peek_location(), | 1341 ReportMessageAt(scanner()->peek_location(), |
| 1336 MessageTemplate::kParamAfterRest); | 1342 MessageTemplate::kParamAfterRest); |
| 1337 *ok = false; | 1343 *ok = false; |
| 1338 return this->EmptyExpression(); | 1344 return this->EmptyExpression(); |
| 1339 } | 1345 } |
| 1340 Expect(Token::RPAREN, CHECK_OK); | 1346 Expect(Token::RPAREN, CHECK_OK); |
| 1341 return factory()->NewSpread(expr, ellipsis_pos, expr_pos); | 1347 return factory()->NewSpread(expr, ellipsis_pos, expr_pos); |
| 1342 } | 1348 } |
| 1343 // Heuristically try to detect immediately called functions before | 1349 // Heuristically try to detect immediately called functions before |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 // as the formal parameters of'(x, y, ...z) => foo', and is not itself a | 1457 // as the formal parameters of'(x, y, ...z) => foo', and is not itself a |
| 1452 // valid expression or binding pattern. | 1458 // valid expression or binding pattern. |
| 1453 ExpressionUnexpectedToken(classifier); | 1459 ExpressionUnexpectedToken(classifier); |
| 1454 BindingPatternUnexpectedToken(classifier); | 1460 BindingPatternUnexpectedToken(classifier); |
| 1455 Consume(Token::ELLIPSIS); | 1461 Consume(Token::ELLIPSIS); |
| 1456 seen_rest = is_rest = true; | 1462 seen_rest = is_rest = true; |
| 1457 } | 1463 } |
| 1458 int pos = position(), expr_pos = peek_position(); | 1464 int pos = position(), expr_pos = peek_position(); |
| 1459 ExpressionT right = this->ParseAssignmentExpression( | 1465 ExpressionT right = this->ParseAssignmentExpression( |
| 1460 accept_IN, flags, &binding_classifier, CHECK_OK); | 1466 accept_IN, flags, &binding_classifier, CHECK_OK); |
| 1461 if (is_rest) right = factory()->NewSpread(right, pos, expr_pos); | 1467 if (is_rest) { |
| 1468 if (!this->IsIdentifier(right) && !right->IsObjectLiteral() && |
| 1469 !right->IsArrayLiteral()) { |
| 1470 classifier->RecordArrowFormalParametersError( |
| 1471 Scanner::Location(pos, scanner()->location().end_pos), |
| 1472 MessageTemplate::kInvalidRestParameter); |
| 1473 } |
| 1474 right = factory()->NewSpread(right, pos, expr_pos); |
| 1475 } |
| 1462 is_simple_parameter_list = | 1476 is_simple_parameter_list = |
| 1463 is_simple_parameter_list && this->IsIdentifier(right); | 1477 is_simple_parameter_list && this->IsIdentifier(right); |
| 1464 classifier->Accumulate(binding_classifier, | 1478 classifier->Accumulate(binding_classifier, |
| 1465 ExpressionClassifier::AllProductions); | 1479 ExpressionClassifier::AllProductions); |
| 1466 result = factory()->NewBinaryOperation(Token::COMMA, result, right, pos); | 1480 result = factory()->NewBinaryOperation(Token::COMMA, result, right, pos); |
| 1467 } | 1481 } |
| 1468 if (!is_simple_parameter_list || seen_rest) { | 1482 if (!is_simple_parameter_list || seen_rest) { |
| 1469 classifier->RecordNonSimpleParameter(); | 1483 classifier->RecordNonSimpleParameter(); |
| 1470 } | 1484 } |
| 1471 | 1485 |
| (...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3364 return; | 3378 return; |
| 3365 } | 3379 } |
| 3366 has_seen_constructor_ = true; | 3380 has_seen_constructor_ = true; |
| 3367 return; | 3381 return; |
| 3368 } | 3382 } |
| 3369 } | 3383 } |
| 3370 } // namespace internal | 3384 } // namespace internal |
| 3371 } // namespace v8 | 3385 } // namespace v8 |
| 3372 | 3386 |
| 3373 #endif // V8_PARSING_PARSER_BASE_H | 3387 #endif // V8_PARSING_PARSER_BASE_H |
| OLD | NEW |