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

Side by Side Diff: src/parsing/parser-base.h

Issue 1617713002: Fix bug with spread rewriting (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | test/mjsunit/harmony/regress/regress-4696.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_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 2335 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 ExpressionClassifier* classifier, bool* ok) { 2346 ExpressionClassifier* classifier, bool* ok) {
2347 // LeftHandSideExpression :: 2347 // LeftHandSideExpression ::
2348 // (NewExpression | MemberExpression) ... 2348 // (NewExpression | MemberExpression) ...
2349 2349
2350 ExpressionT result = 2350 ExpressionT result =
2351 this->ParseMemberWithNewPrefixesExpression(classifier, CHECK_OK); 2351 this->ParseMemberWithNewPrefixesExpression(classifier, CHECK_OK);
2352 2352
2353 while (true) { 2353 while (true) {
2354 switch (peek()) { 2354 switch (peek()) {
2355 case Token::LBRACK: { 2355 case Token::LBRACK: {
2356 result = Traits::RewriteNonPattern(result, classifier, CHECK_OK);
2356 BindingPatternUnexpectedToken(classifier); 2357 BindingPatternUnexpectedToken(classifier);
2357 ArrowFormalParametersUnexpectedToken(classifier); 2358 ArrowFormalParametersUnexpectedToken(classifier);
2358 Consume(Token::LBRACK); 2359 Consume(Token::LBRACK);
2359 int pos = position(); 2360 int pos = position();
2360 ExpressionT index = ParseExpression(true, classifier, CHECK_OK); 2361 ExpressionT index = ParseExpression(true, classifier, CHECK_OK);
2361 index = Traits::RewriteNonPattern(index, classifier, CHECK_OK); 2362 index = Traits::RewriteNonPattern(index, classifier, CHECK_OK);
2362 result = factory()->NewProperty(result, index, pos); 2363 result = factory()->NewProperty(result, index, pos);
2363 Expect(Token::RBRACK, CHECK_OK); 2364 Expect(Token::RBRACK, CHECK_OK);
2364 break; 2365 break;
2365 } 2366 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2422 ExpressionT this_expr = this->ThisExpression(scope_, factory(), pos); 2423 ExpressionT this_expr = this->ThisExpression(scope_, factory(), pos);
2423 result = 2424 result =
2424 factory()->NewAssignment(Token::INIT, this_expr, result, pos); 2425 factory()->NewAssignment(Token::INIT, this_expr, result, pos);
2425 } 2426 }
2426 2427
2427 if (fni_ != NULL) fni_->RemoveLastFunction(); 2428 if (fni_ != NULL) fni_->RemoveLastFunction();
2428 break; 2429 break;
2429 } 2430 }
2430 2431
2431 case Token::PERIOD: { 2432 case Token::PERIOD: {
2433 result = Traits::RewriteNonPattern(result, classifier, CHECK_OK);
2432 BindingPatternUnexpectedToken(classifier); 2434 BindingPatternUnexpectedToken(classifier);
2433 ArrowFormalParametersUnexpectedToken(classifier); 2435 ArrowFormalParametersUnexpectedToken(classifier);
2434 Consume(Token::PERIOD); 2436 Consume(Token::PERIOD);
2435 int pos = position(); 2437 int pos = position();
2436 IdentifierT name = ParseIdentifierName(CHECK_OK); 2438 IdentifierT name = ParseIdentifierName(CHECK_OK);
2437 result = factory()->NewProperty( 2439 result = factory()->NewProperty(
2438 result, factory()->NewStringLiteral(name, pos), pos); 2440 result, factory()->NewStringLiteral(name, pos), pos);
2439 if (fni_ != NULL) this->PushLiteralName(fni_, name); 2441 if (fni_ != NULL) this->PushLiteralName(fni_, name);
2440 break; 2442 break;
2441 } 2443 }
2442 2444
2443 case Token::TEMPLATE_SPAN: 2445 case Token::TEMPLATE_SPAN:
2444 case Token::TEMPLATE_TAIL: { 2446 case Token::TEMPLATE_TAIL: {
2447 result = Traits::RewriteNonPattern(result, classifier, CHECK_OK);
2445 BindingPatternUnexpectedToken(classifier); 2448 BindingPatternUnexpectedToken(classifier);
2446 ArrowFormalParametersUnexpectedToken(classifier); 2449 ArrowFormalParametersUnexpectedToken(classifier);
2447 result = ParseTemplateLiteral(result, position(), classifier, CHECK_OK); 2450 result = ParseTemplateLiteral(result, position(), classifier, CHECK_OK);
2448 break; 2451 break;
2449 } 2452 }
2450 2453
2451 default: 2454 default:
2452 return result; 2455 return result;
2453 } 2456 }
2454 } 2457 }
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
2773 2776
2774 template <class Traits> 2777 template <class Traits>
2775 typename ParserBase<Traits>::ExpressionT 2778 typename ParserBase<Traits>::ExpressionT
2776 ParserBase<Traits>::ParseMemberExpressionContinuation( 2779 ParserBase<Traits>::ParseMemberExpressionContinuation(
2777 ExpressionT expression, ExpressionClassifier* classifier, bool* ok) { 2780 ExpressionT expression, ExpressionClassifier* classifier, bool* ok) {
2778 // Parses this part of MemberExpression: 2781 // Parses this part of MemberExpression:
2779 // ('[' Expression ']' | '.' Identifier | TemplateLiteral)* 2782 // ('[' Expression ']' | '.' Identifier | TemplateLiteral)*
2780 while (true) { 2783 while (true) {
2781 switch (peek()) { 2784 switch (peek()) {
2782 case Token::LBRACK: { 2785 case Token::LBRACK: {
2786 expression =
2787 Traits::RewriteNonPattern(expression, classifier, CHECK_OK);
2783 BindingPatternUnexpectedToken(classifier); 2788 BindingPatternUnexpectedToken(classifier);
2784 ArrowFormalParametersUnexpectedToken(classifier); 2789 ArrowFormalParametersUnexpectedToken(classifier);
2785 2790
2786 Consume(Token::LBRACK); 2791 Consume(Token::LBRACK);
2787 int pos = position(); 2792 int pos = position();
2788 ExpressionT index = this->ParseExpression(true, classifier, CHECK_OK); 2793 ExpressionT index = this->ParseExpression(true, classifier, CHECK_OK);
2789 index = Traits::RewriteNonPattern(index, classifier, CHECK_OK); 2794 index = Traits::RewriteNonPattern(index, classifier, CHECK_OK);
2790 expression = factory()->NewProperty(expression, index, pos); 2795 expression = factory()->NewProperty(expression, index, pos);
2791 if (fni_ != NULL) { 2796 if (fni_ != NULL) {
2792 this->PushPropertyName(fni_, index); 2797 this->PushPropertyName(fni_, index);
2793 } 2798 }
2794 Expect(Token::RBRACK, CHECK_OK); 2799 Expect(Token::RBRACK, CHECK_OK);
2795 break; 2800 break;
2796 } 2801 }
2797 case Token::PERIOD: { 2802 case Token::PERIOD: {
2803 expression =
2804 Traits::RewriteNonPattern(expression, classifier, CHECK_OK);
2798 BindingPatternUnexpectedToken(classifier); 2805 BindingPatternUnexpectedToken(classifier);
2799 ArrowFormalParametersUnexpectedToken(classifier); 2806 ArrowFormalParametersUnexpectedToken(classifier);
2800 2807
2801 Consume(Token::PERIOD); 2808 Consume(Token::PERIOD);
2802 int pos = position(); 2809 int pos = position();
2803 IdentifierT name = ParseIdentifierName(CHECK_OK); 2810 IdentifierT name = ParseIdentifierName(CHECK_OK);
2804 expression = factory()->NewProperty( 2811 expression = factory()->NewProperty(
2805 expression, factory()->NewStringLiteral(name, pos), pos); 2812 expression, factory()->NewStringLiteral(name, pos), pos);
2806 if (fni_ != NULL) { 2813 if (fni_ != NULL) {
2807 this->PushLiteralName(fni_, name); 2814 this->PushLiteralName(fni_, name);
2808 } 2815 }
2809 break; 2816 break;
2810 } 2817 }
2811 case Token::TEMPLATE_SPAN: 2818 case Token::TEMPLATE_SPAN:
2812 case Token::TEMPLATE_TAIL: { 2819 case Token::TEMPLATE_TAIL: {
2820 expression =
2821 Traits::RewriteNonPattern(expression, classifier, CHECK_OK);
2813 BindingPatternUnexpectedToken(classifier); 2822 BindingPatternUnexpectedToken(classifier);
2814 ArrowFormalParametersUnexpectedToken(classifier); 2823 ArrowFormalParametersUnexpectedToken(classifier);
2815 int pos; 2824 int pos;
2816 if (scanner()->current_token() == Token::IDENTIFIER) { 2825 if (scanner()->current_token() == Token::IDENTIFIER) {
2817 pos = position(); 2826 pos = position();
2818 } else { 2827 } else {
2819 pos = peek_position(); 2828 pos = peek_position();
2820 if (expression->IsFunctionLiteral() && mode() == PARSE_EAGERLY) { 2829 if (expression->IsFunctionLiteral() && mode() == PARSE_EAGERLY) {
2821 // If the tag function looks like an IIFE, set_parenthesized() to 2830 // If the tag function looks like an IIFE, set_parenthesized() to
2822 // force eager compilation. 2831 // force eager compilation.
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
3328 return; 3337 return;
3329 } 3338 }
3330 has_seen_constructor_ = true; 3339 has_seen_constructor_ = true;
3331 return; 3340 return;
3332 } 3341 }
3333 } 3342 }
3334 } // namespace internal 3343 } // namespace internal
3335 } // namespace v8 3344 } // namespace v8
3336 3345
3337 #endif // V8_PARSING_PARSER_BASE_H 3346 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/harmony/regress/regress-4696.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698