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

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

Issue 1532873004: [es6] enable destructuring rest parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update test262 expectations 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 | « src/parsing/parser.cc ('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 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 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 Token::String(Token::RPAREN)); 1329 Token::String(Token::RPAREN));
1330 return factory()->NewEmptyParentheses(beg_pos); 1330 return factory()->NewEmptyParentheses(beg_pos);
1331 } else if (Check(Token::ELLIPSIS)) { 1331 } else if (Check(Token::ELLIPSIS)) {
1332 // (...x)=>x. The continuation that looks for the => is in 1332 // (...x)=>x. The continuation that looks for the => is in
1333 // ParseAssignmentExpression. 1333 // ParseAssignmentExpression.
1334 int ellipsis_pos = position(); 1334 int ellipsis_pos = position();
1335 classifier->RecordExpressionError(scanner()->location(), 1335 classifier->RecordExpressionError(scanner()->location(),
1336 MessageTemplate::kUnexpectedToken, 1336 MessageTemplate::kUnexpectedToken,
1337 Token::String(Token::ELLIPSIS)); 1337 Token::String(Token::ELLIPSIS));
1338 classifier->RecordNonSimpleParameter(); 1338 classifier->RecordNonSimpleParameter();
1339 Scanner::Location expr_loc = scanner()->peek_location();
1340 Token::Value tok = peek();
1341 ExpressionT expr = 1339 ExpressionT expr =
1342 this->ParseAssignmentExpression(true, classifier, CHECK_OK); 1340 this->ParseAssignmentExpression(true, classifier, CHECK_OK);
1343 // Patterns are not allowed as rest parameters. There is no way we can
1344 // succeed so go ahead and use the convenient ReportUnexpectedToken
1345 // interface.
1346 if (!Traits::IsIdentifier(expr)) {
1347 ReportUnexpectedTokenAt(expr_loc, tok);
1348 *ok = false;
1349 return this->EmptyExpression();
1350 }
1351 if (peek() == Token::COMMA) { 1341 if (peek() == Token::COMMA) {
1352 ReportMessageAt(scanner()->peek_location(), 1342 ReportMessageAt(scanner()->peek_location(),
1353 MessageTemplate::kParamAfterRest); 1343 MessageTemplate::kParamAfterRest);
1354 *ok = false; 1344 *ok = false;
1355 return this->EmptyExpression(); 1345 return this->EmptyExpression();
1356 } 1346 }
1357 Expect(Token::RPAREN, CHECK_OK); 1347 Expect(Token::RPAREN, CHECK_OK);
1358 return factory()->NewSpread(expr, ellipsis_pos); 1348 return factory()->NewSpread(expr, ellipsis_pos);
1359 } 1349 }
1360 // Heuristically try to detect immediately called functions before 1350 // Heuristically try to detect immediately called functions before
(...skipping 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after
2862 bool is_rest = parameters->has_rest; 2852 bool is_rest = parameters->has_rest;
2863 2853
2864 Token::Value next = peek(); 2854 Token::Value next = peek();
2865 ExpressionT pattern = ParsePrimaryExpression(classifier, ok); 2855 ExpressionT pattern = ParsePrimaryExpression(classifier, ok);
2866 if (!*ok) return; 2856 if (!*ok) return;
2867 2857
2868 ValidateBindingPattern(classifier, ok); 2858 ValidateBindingPattern(classifier, ok);
2869 if (!*ok) return; 2859 if (!*ok) return;
2870 2860
2871 if (!Traits::IsIdentifier(pattern)) { 2861 if (!Traits::IsIdentifier(pattern)) {
2872 if (is_rest || !allow_harmony_destructuring_bind()) { 2862 if (!allow_harmony_destructuring_bind()) {
2873 ReportUnexpectedToken(next); 2863 ReportUnexpectedToken(next);
2874 *ok = false; 2864 *ok = false;
2875 return; 2865 return;
2876 } 2866 }
2877 parameters->is_simple = false; 2867 parameters->is_simple = false;
2878 ValidateFormalParameterInitializer(classifier, ok); 2868 ValidateFormalParameterInitializer(classifier, ok);
2879 if (!*ok) return; 2869 if (!*ok) return;
2880 classifier->RecordNonSimpleParameter(); 2870 classifier->RecordNonSimpleParameter();
2881 } 2871 }
2882 2872
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
3341 return; 3331 return;
3342 } 3332 }
3343 has_seen_constructor_ = true; 3333 has_seen_constructor_ = true;
3344 return; 3334 return;
3345 } 3335 }
3346 } 3336 }
3347 } // namespace internal 3337 } // namespace internal
3348 } // namespace v8 3338 } // namespace v8
3349 3339
3350 #endif // V8_PARSING_PARSER_BASE_H 3340 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698