| 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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 return Statement::Default(); | 504 return Statement::Default(); |
| 505 } | 505 } |
| 506 | 506 |
| 507 // The scope of a var/const declared variable anywhere inside a function | 507 // The scope of a var/const declared variable anywhere inside a function |
| 508 // is the entire function (ECMA-262, 3rd, 10.1.3, and 12.2). The scope | 508 // is the entire function (ECMA-262, 3rd, 10.1.3, and 12.2). The scope |
| 509 // of a let declared variable is the scope of the immediately enclosing | 509 // of a let declared variable is the scope of the immediately enclosing |
| 510 // block. | 510 // block. |
| 511 int nvars = 0; // the number of variables declared | 511 int nvars = 0; // the number of variables declared |
| 512 int bindings_start = peek_position(); | 512 int bindings_start = peek_position(); |
| 513 do { | 513 do { |
| 514 // Parse variable name. | 514 // Parse binding pattern. |
| 515 if (nvars > 0) Consume(Token::COMMA); | 515 if (nvars > 0) Consume(Token::COMMA); |
| 516 { | 516 { |
| 517 ExpressionClassifier pattern_classifier; | 517 ExpressionClassifier pattern_classifier; |
| 518 Token::Value next = peek(); | 518 Token::Value next = peek(); |
| 519 PreParserExpression pattern = | 519 PreParserExpression pattern = |
| 520 ParsePrimaryExpression(&pattern_classifier, CHECK_OK); | 520 ParsePrimaryExpression(&pattern_classifier, CHECK_OK); |
| 521 ValidateBindingPattern(&pattern_classifier, CHECK_OK); | 521 ValidateBindingPattern(&pattern_classifier, CHECK_OK); |
| 522 | 522 |
| 523 if (!pattern.IsIdentifier()) { | 523 if (!FLAG_harmony_destructuring && !pattern.IsIdentifier()) { |
| 524 ReportUnexpectedToken(next); | 524 ReportUnexpectedToken(next); |
| 525 *ok = false; | 525 *ok = false; |
| 526 return Statement::Default(); | 526 return Statement::Default(); |
| 527 } | 527 } |
| 528 } | 528 } |
| 529 |
| 529 Scanner::Location variable_loc = scanner()->location(); | 530 Scanner::Location variable_loc = scanner()->location(); |
| 530 nvars++; | 531 nvars++; |
| 531 if (peek() == Token::ASSIGN || require_initializer || | 532 if (peek() == Token::ASSIGN || require_initializer || |
| 532 // require initializers for multiple consts. | 533 // require initializers for multiple consts. |
| 533 (is_strict_const && peek() == Token::COMMA)) { | 534 (is_strict_const && peek() == Token::COMMA)) { |
| 534 Expect(Token::ASSIGN, CHECK_OK); | 535 Expect(Token::ASSIGN, CHECK_OK); |
| 535 ExpressionClassifier classifier; | 536 ExpressionClassifier classifier; |
| 536 ParseAssignmentExpression(var_context != kForStatement, &classifier, | 537 ParseAssignmentExpression(var_context != kForStatement, &classifier, |
| 537 CHECK_OK); | 538 CHECK_OK); |
| 538 ValidateExpression(&classifier, CHECK_OK); | 539 ValidateExpression(&classifier, CHECK_OK); |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 | 1147 |
| 1147 DCHECK(!spread_pos.IsValid()); | 1148 DCHECK(!spread_pos.IsValid()); |
| 1148 | 1149 |
| 1149 return Expression::Default(); | 1150 return Expression::Default(); |
| 1150 } | 1151 } |
| 1151 | 1152 |
| 1152 #undef CHECK_OK | 1153 #undef CHECK_OK |
| 1153 | 1154 |
| 1154 | 1155 |
| 1155 } } // v8::internal | 1156 } } // v8::internal |
| OLD | NEW |