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

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

Issue 1519073004: Remove always-on --harmony-rest-parameters flag (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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/compiler/test-run-jsobjects.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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. 104 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly.
105 stack_limit_(stack_limit), 105 stack_limit_(stack_limit),
106 zone_(zone), 106 zone_(zone),
107 scanner_(scanner), 107 scanner_(scanner),
108 stack_overflow_(false), 108 stack_overflow_(false),
109 allow_lazy_(false), 109 allow_lazy_(false),
110 allow_natives_(false), 110 allow_natives_(false),
111 allow_harmony_sloppy_(false), 111 allow_harmony_sloppy_(false),
112 allow_harmony_sloppy_function_(false), 112 allow_harmony_sloppy_function_(false),
113 allow_harmony_sloppy_let_(false), 113 allow_harmony_sloppy_let_(false),
114 allow_harmony_rest_parameters_(false),
115 allow_harmony_default_parameters_(false), 114 allow_harmony_default_parameters_(false),
116 allow_harmony_destructuring_bind_(false), 115 allow_harmony_destructuring_bind_(false),
117 allow_harmony_destructuring_assignment_(false), 116 allow_harmony_destructuring_assignment_(false),
118 allow_strong_mode_(false), 117 allow_strong_mode_(false),
119 allow_legacy_const_(true), 118 allow_legacy_const_(true),
120 allow_harmony_do_expressions_(false) {} 119 allow_harmony_do_expressions_(false) {}
121 120
122 #define ALLOW_ACCESSORS(name) \ 121 #define ALLOW_ACCESSORS(name) \
123 bool allow_##name() const { return allow_##name##_; } \ 122 bool allow_##name() const { return allow_##name##_; } \
124 void set_allow_##name(bool allow) { allow_##name##_ = allow; } 123 void set_allow_##name(bool allow) { allow_##name##_ = allow; }
125 124
126 ALLOW_ACCESSORS(lazy); 125 ALLOW_ACCESSORS(lazy);
127 ALLOW_ACCESSORS(natives); 126 ALLOW_ACCESSORS(natives);
128 ALLOW_ACCESSORS(harmony_sloppy); 127 ALLOW_ACCESSORS(harmony_sloppy);
129 ALLOW_ACCESSORS(harmony_sloppy_function); 128 ALLOW_ACCESSORS(harmony_sloppy_function);
130 ALLOW_ACCESSORS(harmony_sloppy_let); 129 ALLOW_ACCESSORS(harmony_sloppy_let);
131 ALLOW_ACCESSORS(harmony_rest_parameters);
132 ALLOW_ACCESSORS(harmony_default_parameters); 130 ALLOW_ACCESSORS(harmony_default_parameters);
133 ALLOW_ACCESSORS(harmony_destructuring_bind); 131 ALLOW_ACCESSORS(harmony_destructuring_bind);
134 ALLOW_ACCESSORS(harmony_destructuring_assignment); 132 ALLOW_ACCESSORS(harmony_destructuring_assignment);
135 ALLOW_ACCESSORS(strong_mode); 133 ALLOW_ACCESSORS(strong_mode);
136 ALLOW_ACCESSORS(legacy_const); 134 ALLOW_ACCESSORS(legacy_const);
137 ALLOW_ACCESSORS(harmony_do_expressions); 135 ALLOW_ACCESSORS(harmony_do_expressions);
138 #undef ALLOW_ACCESSORS 136 #undef ALLOW_ACCESSORS
139 137
140 uintptr_t stack_limit() const { return stack_limit_; } 138 uintptr_t stack_limit() const { return stack_limit_; }
141 139
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 Zone* zone_; 907 Zone* zone_;
910 908
911 Scanner* scanner_; 909 Scanner* scanner_;
912 bool stack_overflow_; 910 bool stack_overflow_;
913 911
914 bool allow_lazy_; 912 bool allow_lazy_;
915 bool allow_natives_; 913 bool allow_natives_;
916 bool allow_harmony_sloppy_; 914 bool allow_harmony_sloppy_;
917 bool allow_harmony_sloppy_function_; 915 bool allow_harmony_sloppy_function_;
918 bool allow_harmony_sloppy_let_; 916 bool allow_harmony_sloppy_let_;
919 bool allow_harmony_rest_parameters_;
920 bool allow_harmony_default_parameters_; 917 bool allow_harmony_default_parameters_;
921 bool allow_harmony_destructuring_bind_; 918 bool allow_harmony_destructuring_bind_;
922 bool allow_harmony_destructuring_assignment_; 919 bool allow_harmony_destructuring_assignment_;
923 bool allow_strong_mode_; 920 bool allow_strong_mode_;
924 bool allow_legacy_const_; 921 bool allow_legacy_const_;
925 bool allow_harmony_do_expressions_; 922 bool allow_harmony_do_expressions_;
926 }; 923 };
927 924
928 925
929 template <class Traits> 926 template <class Traits>
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 if (Check(Token::RPAREN)) { 1319 if (Check(Token::RPAREN)) {
1323 // ()=>x. The continuation that looks for the => is in 1320 // ()=>x. The continuation that looks for the => is in
1324 // ParseAssignmentExpression. 1321 // ParseAssignmentExpression.
1325 classifier->RecordExpressionError(scanner()->location(), 1322 classifier->RecordExpressionError(scanner()->location(),
1326 MessageTemplate::kUnexpectedToken, 1323 MessageTemplate::kUnexpectedToken,
1327 Token::String(Token::RPAREN)); 1324 Token::String(Token::RPAREN));
1328 classifier->RecordBindingPatternError(scanner()->location(), 1325 classifier->RecordBindingPatternError(scanner()->location(),
1329 MessageTemplate::kUnexpectedToken, 1326 MessageTemplate::kUnexpectedToken,
1330 Token::String(Token::RPAREN)); 1327 Token::String(Token::RPAREN));
1331 return factory()->NewEmptyParentheses(beg_pos); 1328 return factory()->NewEmptyParentheses(beg_pos);
1332 } else if (allow_harmony_rest_parameters() && Check(Token::ELLIPSIS)) { 1329 } else if (Check(Token::ELLIPSIS)) {
1333 // (...x)=>x. The continuation that looks for the => is in 1330 // (...x)=>x. The continuation that looks for the => is in
1334 // ParseAssignmentExpression. 1331 // ParseAssignmentExpression.
1335 int ellipsis_pos = position(); 1332 int ellipsis_pos = position();
1336 classifier->RecordExpressionError(scanner()->location(), 1333 classifier->RecordExpressionError(scanner()->location(),
1337 MessageTemplate::kUnexpectedToken, 1334 MessageTemplate::kUnexpectedToken,
1338 Token::String(Token::ELLIPSIS)); 1335 Token::String(Token::ELLIPSIS));
1339 classifier->RecordNonSimpleParameter(); 1336 classifier->RecordNonSimpleParameter();
1340 Scanner::Location expr_loc = scanner()->peek_location(); 1337 Scanner::Location expr_loc = scanner()->peek_location();
1341 Token::Value tok = peek(); 1338 Token::Value tok = peek();
1342 ExpressionT expr = 1339 ExpressionT expr =
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 bool seen_rest = false; 1454 bool seen_rest = false;
1458 while (peek() == Token::COMMA) { 1455 while (peek() == Token::COMMA) {
1459 if (seen_rest) { 1456 if (seen_rest) {
1460 // At this point the production can't possibly be valid, but we don't know 1457 // At this point the production can't possibly be valid, but we don't know
1461 // which error to signal. 1458 // which error to signal.
1462 classifier->RecordArrowFormalParametersError( 1459 classifier->RecordArrowFormalParametersError(
1463 scanner()->peek_location(), MessageTemplate::kParamAfterRest); 1460 scanner()->peek_location(), MessageTemplate::kParamAfterRest);
1464 } 1461 }
1465 Consume(Token::COMMA); 1462 Consume(Token::COMMA);
1466 bool is_rest = false; 1463 bool is_rest = false;
1467 if (allow_harmony_rest_parameters() && peek() == Token::ELLIPSIS) { 1464 if (peek() == Token::ELLIPSIS) {
1468 // 'x, y, ...z' in CoverParenthesizedExpressionAndArrowParameterList only 1465 // 'x, y, ...z' in CoverParenthesizedExpressionAndArrowParameterList only
1469 // as the formal parameters of'(x, y, ...z) => foo', and is not itself a 1466 // as the formal parameters of'(x, y, ...z) => foo', and is not itself a
1470 // valid expression or binding pattern. 1467 // valid expression or binding pattern.
1471 ExpressionUnexpectedToken(classifier); 1468 ExpressionUnexpectedToken(classifier);
1472 BindingPatternUnexpectedToken(classifier); 1469 BindingPatternUnexpectedToken(classifier);
1473 Consume(Token::ELLIPSIS); 1470 Consume(Token::ELLIPSIS);
1474 seen_rest = is_rest = true; 1471 seen_rest = is_rest = true;
1475 } 1472 }
1476 int pos = position(); 1473 int pos = position();
1477 ExpressionT right = this->ParseAssignmentExpression( 1474 ExpressionT right = this->ParseAssignmentExpression(
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after
2923 2920
2924 DCHECK_EQ(0, parameters->Arity()); 2921 DCHECK_EQ(0, parameters->Arity());
2925 2922
2926 if (peek() != Token::RPAREN) { 2923 if (peek() != Token::RPAREN) {
2927 do { 2924 do {
2928 if (parameters->Arity() > Code::kMaxArguments) { 2925 if (parameters->Arity() > Code::kMaxArguments) {
2929 ReportMessage(MessageTemplate::kTooManyParameters); 2926 ReportMessage(MessageTemplate::kTooManyParameters);
2930 *ok = false; 2927 *ok = false;
2931 return; 2928 return;
2932 } 2929 }
2933 parameters->has_rest = 2930 parameters->has_rest = Check(Token::ELLIPSIS);
2934 allow_harmony_rest_parameters() && Check(Token::ELLIPSIS);
2935 ParseFormalParameter(parameters, classifier, ok); 2931 ParseFormalParameter(parameters, classifier, ok);
2936 if (!*ok) return; 2932 if (!*ok) return;
2937 } while (!parameters->has_rest && Check(Token::COMMA)); 2933 } while (!parameters->has_rest && Check(Token::COMMA));
2938 2934
2939 if (parameters->has_rest) { 2935 if (parameters->has_rest) {
2940 parameters->is_simple = false; 2936 parameters->is_simple = false;
2941 classifier->RecordNonSimpleParameter(); 2937 classifier->RecordNonSimpleParameter();
2942 if (peek() == Token::COMMA) { 2938 if (peek() == Token::COMMA) {
2943 ReportMessageAt(scanner()->peek_location(), 2939 ReportMessageAt(scanner()->peek_location(),
2944 MessageTemplate::kParamAfterRest); 2940 MessageTemplate::kParamAfterRest);
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
3349 return; 3345 return;
3350 } 3346 }
3351 has_seen_constructor_ = true; 3347 has_seen_constructor_ = true;
3352 return; 3348 return;
3353 } 3349 }
3354 } 3350 }
3355 } // namespace internal 3351 } // namespace internal
3356 } // namespace v8 3352 } // namespace v8
3357 3353
3358 #endif // V8_PARSING_PARSER_BASE_H 3354 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | test/cctest/compiler/test-run-jsobjects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698