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

Side by Side Diff: src/parsing/preparser.cc

Issue 1776683003: Remove destructuring and default arguments runtime flags (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 4 years, 9 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
« no previous file with comments | « src/parsing/parser-base.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 // block. 514 // block.
515 int nvars = 0; // the number of variables declared 515 int nvars = 0; // the number of variables declared
516 int bindings_start = peek_position(); 516 int bindings_start = peek_position();
517 do { 517 do {
518 // Parse binding pattern. 518 // Parse binding pattern.
519 if (nvars > 0) Consume(Token::COMMA); 519 if (nvars > 0) Consume(Token::COMMA);
520 int decl_pos = peek_position(); 520 int decl_pos = peek_position();
521 PreParserExpression pattern = PreParserExpression::Default(); 521 PreParserExpression pattern = PreParserExpression::Default();
522 { 522 {
523 ExpressionClassifier pattern_classifier(this); 523 ExpressionClassifier pattern_classifier(this);
524 Token::Value next = peek();
525 pattern = ParsePrimaryExpression(&pattern_classifier, CHECK_OK); 524 pattern = ParsePrimaryExpression(&pattern_classifier, CHECK_OK);
526 525
527 ValidateBindingPattern(&pattern_classifier, CHECK_OK); 526 ValidateBindingPattern(&pattern_classifier, CHECK_OK);
528 if (lexical) { 527 if (lexical) {
529 ValidateLetPattern(&pattern_classifier, CHECK_OK); 528 ValidateLetPattern(&pattern_classifier, CHECK_OK);
530 } 529 }
531
532 if (!allow_harmony_destructuring_bind() && !pattern.IsIdentifier()) {
533 ReportUnexpectedToken(next);
534 *ok = false;
535 return Statement::Default();
536 }
537 } 530 }
538 531
539 is_pattern = pattern.IsObjectLiteral() || pattern.IsArrayLiteral(); 532 is_pattern = pattern.IsObjectLiteral() || pattern.IsArrayLiteral();
540 533
541 Scanner::Location variable_loc = scanner()->location(); 534 Scanner::Location variable_loc = scanner()->location();
542 nvars++; 535 nvars++;
543 if (Check(Token::ASSIGN)) { 536 if (Check(Token::ASSIGN)) {
544 ExpressionClassifier classifier(this); 537 ExpressionClassifier classifier(this);
545 ParseAssignmentExpression(var_context != kForStatement, &classifier, 538 ParseAssignmentExpression(var_context != kForStatement, &classifier,
546 CHECK_OK); 539 CHECK_OK);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 } else { 841 } else {
849 int lhs_beg_pos = peek_position(); 842 int lhs_beg_pos = peek_position();
850 ExpressionClassifier classifier(this); 843 ExpressionClassifier classifier(this);
851 Expression lhs = ParseExpression(false, &classifier, CHECK_OK); 844 Expression lhs = ParseExpression(false, &classifier, CHECK_OK);
852 int lhs_end_pos = scanner()->location().end_pos; 845 int lhs_end_pos = scanner()->location().end_pos;
853 is_let_identifier_expression = 846 is_let_identifier_expression =
854 lhs.IsIdentifier() && lhs.AsIdentifier().IsLet(); 847 lhs.IsIdentifier() && lhs.AsIdentifier().IsLet();
855 bool is_for_each = CheckInOrOf(&mode, ok); 848 bool is_for_each = CheckInOrOf(&mode, ok);
856 if (!*ok) return Statement::Default(); 849 if (!*ok) return Statement::Default();
857 bool is_destructuring = is_for_each && 850 bool is_destructuring = is_for_each &&
858 allow_harmony_destructuring_assignment() &&
859 (lhs->IsArrayLiteral() || lhs->IsObjectLiteral()); 851 (lhs->IsArrayLiteral() || lhs->IsObjectLiteral());
860 852
861 if (is_destructuring) { 853 if (is_destructuring) {
862 ValidateAssignmentPattern(&classifier, CHECK_OK); 854 ValidateAssignmentPattern(&classifier, CHECK_OK);
863 } else { 855 } else {
864 ValidateExpression(&classifier, CHECK_OK); 856 ValidateExpression(&classifier, CHECK_OK);
865 } 857 }
866 858
867 if (is_for_each) { 859 if (is_for_each) {
868 if (!is_destructuring) { 860 if (!is_destructuring) {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 Expect(Token::RBRACE, CHECK_OK); 1156 Expect(Token::RBRACE, CHECK_OK);
1165 return PreParserExpression::Default(); 1157 return PreParserExpression::Default();
1166 } 1158 }
1167 } 1159 }
1168 1160
1169 #undef CHECK_OK 1161 #undef CHECK_OK
1170 1162
1171 1163
1172 } // namespace internal 1164 } // namespace internal
1173 } // namespace v8 1165 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser-base.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698