| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 #include <cmath> | 5 #include <cmath> |
| 6 | 6 |
| 7 #include "src/allocation.h" | 7 #include "src/allocation.h" |
| 8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
| 9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
| 10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 ValidateLetPattern(&pattern_classifier, CHECK_OK); | 584 ValidateLetPattern(&pattern_classifier, CHECK_OK); |
| 585 } | 585 } |
| 586 | 586 |
| 587 if (!allow_harmony_destructuring_bind() && !pattern.IsIdentifier()) { | 587 if (!allow_harmony_destructuring_bind() && !pattern.IsIdentifier()) { |
| 588 ReportUnexpectedToken(next); | 588 ReportUnexpectedToken(next); |
| 589 *ok = false; | 589 *ok = false; |
| 590 return Statement::Default(); | 590 return Statement::Default(); |
| 591 } | 591 } |
| 592 } | 592 } |
| 593 | 593 |
| 594 is_pattern = (pattern.IsObjectLiteral() || pattern.IsArrayLiteral()) && | 594 is_pattern = pattern.IsObjectLiteral() || pattern.IsArrayLiteral(); |
| 595 !pattern.is_parenthesized(); | |
| 596 | |
| 597 bool is_for_iteration_variable = | |
| 598 var_context == kForStatement && | |
| 599 (peek() == Token::IN || PeekContextualKeyword(CStrVector("of"))); | |
| 600 | 595 |
| 601 Scanner::Location variable_loc = scanner()->location(); | 596 Scanner::Location variable_loc = scanner()->location(); |
| 602 nvars++; | 597 nvars++; |
| 603 if (Check(Token::ASSIGN)) { | 598 if (Check(Token::ASSIGN)) { |
| 604 ExpressionClassifier classifier; | 599 ExpressionClassifier classifier; |
| 605 ParseAssignmentExpression(var_context != kForStatement, &classifier, | 600 ParseAssignmentExpression(var_context != kForStatement, &classifier, |
| 606 CHECK_OK); | 601 CHECK_OK); |
| 607 ValidateExpression(&classifier, CHECK_OK); | 602 ValidateExpression(&classifier, CHECK_OK); |
| 608 | 603 |
| 609 variable_loc.end_pos = scanner()->location().end_pos; | 604 variable_loc.end_pos = scanner()->location().end_pos; |
| 610 if (first_initializer_loc && !first_initializer_loc->IsValid()) { | 605 if (first_initializer_loc && !first_initializer_loc->IsValid()) { |
| 611 *first_initializer_loc = variable_loc; | 606 *first_initializer_loc = variable_loc; |
| 612 } | 607 } |
| 613 } else if ((require_initializer || is_pattern) && | 608 } else if ((require_initializer || is_pattern) && |
| 614 !is_for_iteration_variable) { | 609 (var_context != kForStatement || !PeekInOrOf())) { |
| 615 PreParserTraits::ReportMessageAt( | 610 PreParserTraits::ReportMessageAt( |
| 616 Scanner::Location(decl_pos, scanner()->location().end_pos), | 611 Scanner::Location(decl_pos, scanner()->location().end_pos), |
| 617 MessageTemplate::kDeclarationMissingInitializer, | 612 MessageTemplate::kDeclarationMissingInitializer, |
| 618 is_pattern ? "destructuring" : "const"); | 613 is_pattern ? "destructuring" : "const"); |
| 619 *ok = false; | 614 *ok = false; |
| 620 return Statement::Default(); | 615 return Statement::Default(); |
| 621 } | 616 } |
| 622 } while (peek() == Token::COMMA); | 617 } while (peek() == Token::COMMA); |
| 623 | 618 |
| 624 if (bindings_loc) { | 619 if (bindings_loc) { |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 Expect(Token::RBRACE, CHECK_OK); | 1296 Expect(Token::RBRACE, CHECK_OK); |
| 1302 return PreParserExpression::Default(); | 1297 return PreParserExpression::Default(); |
| 1303 } | 1298 } |
| 1304 } | 1299 } |
| 1305 | 1300 |
| 1306 #undef CHECK_OK | 1301 #undef CHECK_OK |
| 1307 | 1302 |
| 1308 | 1303 |
| 1309 } // namespace internal | 1304 } // namespace internal |
| 1310 } // namespace v8 | 1305 } // namespace v8 |
| OLD | NEW |