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

Side by Side Diff: src/preparser.h

Issue 1276273002: [es6] Fix parsing of expressions in parameter lists (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Whoops Created 5 years, 4 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/expression-classifier.h ('k') | test/mjsunit/harmony/destructuring.js » ('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 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_PREPARSER_H 5 #ifndef V8_PREPARSER_H
6 #define V8_PREPARSER_H 6 #define V8_PREPARSER_H
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 2488 matching lines...) Expand 10 before | Expand all | Expand 10 after
2499 Consume(Token::NUMBER); 2499 Consume(Token::NUMBER);
2500 *name = this->GetNumberAsSymbol(scanner()); 2500 *name = this->GetNumberAsSymbol(scanner());
2501 break; 2501 break;
2502 2502
2503 case Token::LBRACK: { 2503 case Token::LBRACK: {
2504 *is_computed_name = true; 2504 *is_computed_name = true;
2505 Consume(Token::LBRACK); 2505 Consume(Token::LBRACK);
2506 ExpressionClassifier computed_name_classifier; 2506 ExpressionClassifier computed_name_classifier;
2507 ExpressionT expression = 2507 ExpressionT expression =
2508 ParseAssignmentExpression(true, &computed_name_classifier, CHECK_OK); 2508 ParseAssignmentExpression(true, &computed_name_classifier, CHECK_OK);
2509 classifier->AccumulateReclassifyingAsPattern(computed_name_classifier); 2509 classifier->Accumulate(computed_name_classifier,
2510 ExpressionClassifier::ExpressionProduction);
2510 Expect(Token::RBRACK, CHECK_OK); 2511 Expect(Token::RBRACK, CHECK_OK);
2511 return expression; 2512 return expression;
2512 } 2513 }
2513 2514
2514 case Token::STATIC: 2515 case Token::STATIC:
2515 *is_static = true; 2516 *is_static = true;
2516 2517
2517 // Fall through. 2518 // Fall through.
2518 default: 2519 default:
2519 *name = ParseIdentifierNameOrGetOrSet(is_get, is_set, CHECK_OK); 2520 *name = ParseIdentifierNameOrGetOrSet(is_get, is_set, CHECK_OK);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2644 } 2645 }
2645 2646
2646 ExpressionT lhs = this->ExpressionFromIdentifier( 2647 ExpressionT lhs = this->ExpressionFromIdentifier(
2647 name, next_beg_pos, next_end_pos, scope_, factory()); 2648 name, next_beg_pos, next_end_pos, scope_, factory());
2648 if (peek() == Token::ASSIGN) { 2649 if (peek() == Token::ASSIGN) {
2649 this->ExpressionUnexpectedToken(classifier); 2650 this->ExpressionUnexpectedToken(classifier);
2650 Consume(Token::ASSIGN); 2651 Consume(Token::ASSIGN);
2651 ExpressionClassifier rhs_classifier; 2652 ExpressionClassifier rhs_classifier;
2652 ExpressionT rhs = this->ParseAssignmentExpression( 2653 ExpressionT rhs = this->ParseAssignmentExpression(
2653 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2654 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
2654 classifier->AccumulateReclassifyingAsPattern(rhs_classifier); 2655 classifier->Accumulate(rhs_classifier,
2656 ExpressionClassifier::ExpressionProduction);
2655 value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs, 2657 value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs,
2656 RelocInfo::kNoPosition); 2658 RelocInfo::kNoPosition);
2657 } else { 2659 } else {
2658 value = lhs; 2660 value = lhs;
2659 } 2661 }
2660 return factory()->NewObjectLiteralProperty( 2662 return factory()->NewObjectLiteralProperty(
2661 name_expression, value, ObjectLiteralProperty::COMPUTED, false, false); 2663 name_expression, value, ObjectLiteralProperty::COMPUTED, false, false);
2662 2664
2663 } else { 2665 } else {
2664 Token::Value next = Next(); 2666 Token::Value next = Next();
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2882 if (op != Token::ASSIGN) { 2884 if (op != Token::ASSIGN) {
2883 classifier->RecordBindingPatternError(scanner()->location(), 2885 classifier->RecordBindingPatternError(scanner()->location(),
2884 MessageTemplate::kUnexpectedToken, 2886 MessageTemplate::kUnexpectedToken,
2885 Token::String(op)); 2887 Token::String(op));
2886 } 2888 }
2887 int pos = position(); 2889 int pos = position();
2888 2890
2889 ExpressionClassifier rhs_classifier; 2891 ExpressionClassifier rhs_classifier;
2890 ExpressionT right = 2892 ExpressionT right =
2891 this->ParseAssignmentExpression(accept_IN, &rhs_classifier, CHECK_OK); 2893 this->ParseAssignmentExpression(accept_IN, &rhs_classifier, CHECK_OK);
2892 classifier->AccumulateReclassifyingAsPattern(rhs_classifier); 2894 classifier->Accumulate(rhs_classifier,
2895 ExpressionClassifier::ExpressionProduction);
2893 2896
2894 // TODO(1231235): We try to estimate the set of properties set by 2897 // TODO(1231235): We try to estimate the set of properties set by
2895 // constructors. We define a new property whenever there is an 2898 // constructors. We define a new property whenever there is an
2896 // assignment to a property of 'this'. We should probably only add 2899 // assignment to a property of 'this'. We should probably only add
2897 // properties if we haven't seen them before. Otherwise we'll 2900 // properties if we haven't seen them before. Otherwise we'll
2898 // probably overestimate the number of properties. 2901 // probably overestimate the number of properties.
2899 if (op == Token::ASSIGN && this->IsThisProperty(expression)) { 2902 if (op == Token::ASSIGN && this->IsThisProperty(expression)) {
2900 function_state_->AddProperty(); 2903 function_state_->AddProperty();
2901 } 2904 }
2902 2905
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
4019 *ok = false; 4022 *ok = false;
4020 return; 4023 return;
4021 } 4024 }
4022 has_seen_constructor_ = true; 4025 has_seen_constructor_ = true;
4023 return; 4026 return;
4024 } 4027 }
4025 } 4028 }
4026 } } // v8::internal 4029 } } // v8::internal
4027 4030
4028 #endif // V8_PREPARSER_H 4031 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « src/expression-classifier.h ('k') | test/mjsunit/harmony/destructuring.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698