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

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

Issue 2478883002: Remove always-true --harmony-restrictive-declarations flag (Closed)
Patch Set: Formatting Created 4 years, 1 month 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/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 parsing_module_(false), 204 parsing_module_(false),
205 stack_limit_(stack_limit), 205 stack_limit_(stack_limit),
206 zone_(zone), 206 zone_(zone),
207 classifier_(nullptr), 207 classifier_(nullptr),
208 scanner_(scanner), 208 scanner_(scanner),
209 stack_overflow_(false), 209 stack_overflow_(false),
210 default_eager_compile_hint_(FunctionLiteral::kShouldLazyCompile), 210 default_eager_compile_hint_(FunctionLiteral::kShouldLazyCompile),
211 allow_lazy_(false), 211 allow_lazy_(false),
212 allow_natives_(false), 212 allow_natives_(false),
213 allow_tailcalls_(false), 213 allow_tailcalls_(false),
214 allow_harmony_restrictive_declarations_(false),
215 allow_harmony_do_expressions_(false), 214 allow_harmony_do_expressions_(false),
216 allow_harmony_function_sent_(false), 215 allow_harmony_function_sent_(false),
217 allow_harmony_async_await_(false), 216 allow_harmony_async_await_(false),
218 allow_harmony_restrictive_generators_(false), 217 allow_harmony_restrictive_generators_(false),
219 allow_harmony_trailing_commas_(false), 218 allow_harmony_trailing_commas_(false),
220 allow_harmony_class_fields_(false) {} 219 allow_harmony_class_fields_(false) {}
221 220
222 #define ALLOW_ACCESSORS(name) \ 221 #define ALLOW_ACCESSORS(name) \
223 bool allow_##name() const { return allow_##name##_; } \ 222 bool allow_##name() const { return allow_##name##_; } \
224 void set_allow_##name(bool allow) { allow_##name##_ = allow; } 223 void set_allow_##name(bool allow) { allow_##name##_ = allow; }
225 224
226 ALLOW_ACCESSORS(lazy); 225 ALLOW_ACCESSORS(lazy);
227 ALLOW_ACCESSORS(natives); 226 ALLOW_ACCESSORS(natives);
228 ALLOW_ACCESSORS(tailcalls); 227 ALLOW_ACCESSORS(tailcalls);
229 ALLOW_ACCESSORS(harmony_restrictive_declarations);
230 ALLOW_ACCESSORS(harmony_do_expressions); 228 ALLOW_ACCESSORS(harmony_do_expressions);
231 ALLOW_ACCESSORS(harmony_function_sent); 229 ALLOW_ACCESSORS(harmony_function_sent);
232 ALLOW_ACCESSORS(harmony_async_await); 230 ALLOW_ACCESSORS(harmony_async_await);
233 ALLOW_ACCESSORS(harmony_restrictive_generators); 231 ALLOW_ACCESSORS(harmony_restrictive_generators);
234 ALLOW_ACCESSORS(harmony_trailing_commas); 232 ALLOW_ACCESSORS(harmony_trailing_commas);
235 ALLOW_ACCESSORS(harmony_class_fields); 233 ALLOW_ACCESSORS(harmony_class_fields);
236 234
237 #undef ALLOW_ACCESSORS 235 #undef ALLOW_ACCESSORS
238 236
239 uintptr_t stack_limit() const { return stack_limit_; } 237 uintptr_t stack_limit() const { return stack_limit_; }
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 ExpressionClassifier* classifier_; 1454 ExpressionClassifier* classifier_;
1457 1455
1458 Scanner* scanner_; 1456 Scanner* scanner_;
1459 bool stack_overflow_; 1457 bool stack_overflow_;
1460 1458
1461 FunctionLiteral::EagerCompileHint default_eager_compile_hint_; 1459 FunctionLiteral::EagerCompileHint default_eager_compile_hint_;
1462 1460
1463 bool allow_lazy_; 1461 bool allow_lazy_;
1464 bool allow_natives_; 1462 bool allow_natives_;
1465 bool allow_tailcalls_; 1463 bool allow_tailcalls_;
1466 bool allow_harmony_restrictive_declarations_;
1467 bool allow_harmony_do_expressions_; 1464 bool allow_harmony_do_expressions_;
1468 bool allow_harmony_function_sent_; 1465 bool allow_harmony_function_sent_;
1469 bool allow_harmony_async_await_; 1466 bool allow_harmony_async_await_;
1470 bool allow_harmony_restrictive_generators_; 1467 bool allow_harmony_restrictive_generators_;
1471 bool allow_harmony_trailing_commas_; 1468 bool allow_harmony_trailing_commas_;
1472 bool allow_harmony_class_fields_; 1469 bool allow_harmony_class_fields_;
1473 1470
1474 friend class DiscardableZoneScope; 1471 friend class DiscardableZoneScope;
1475 }; 1472 };
1476 1473
(...skipping 2199 matching lines...) Expand 10 before | Expand all | Expand 10 after
3676 return init_block; 3673 return init_block;
3677 } 3674 }
3678 3675
3679 template <typename Impl> 3676 template <typename Impl>
3680 typename ParserBase<Impl>::StatementT 3677 typename ParserBase<Impl>::StatementT
3681 ParserBase<Impl>::ParseFunctionDeclaration(bool* ok) { 3678 ParserBase<Impl>::ParseFunctionDeclaration(bool* ok) {
3682 Consume(Token::FUNCTION); 3679 Consume(Token::FUNCTION);
3683 int pos = position(); 3680 int pos = position();
3684 ParseFunctionFlags flags = ParseFunctionFlags::kIsNormal; 3681 ParseFunctionFlags flags = ParseFunctionFlags::kIsNormal;
3685 if (Check(Token::MUL)) { 3682 if (Check(Token::MUL)) {
3686 flags |= ParseFunctionFlags::kIsGenerator; 3683 impl()->ReportMessageAt(scanner()->location(),
3687 if (allow_harmony_restrictive_declarations()) { 3684 MessageTemplate::kGeneratorInLegacyContext);
3688 impl()->ReportMessageAt(scanner()->location(), 3685 *ok = false;
3689 MessageTemplate::kGeneratorInLegacyContext); 3686 return impl()->NullStatement();
3690 *ok = false;
3691 return impl()->NullStatement();
3692 }
3693 } 3687 }
3694 return ParseHoistableDeclaration(pos, flags, nullptr, false, ok); 3688 return ParseHoistableDeclaration(pos, flags, nullptr, false, ok);
3695 } 3689 }
3696 3690
3697 template <typename Impl> 3691 template <typename Impl>
3698 typename ParserBase<Impl>::StatementT 3692 typename ParserBase<Impl>::StatementT
3699 ParserBase<Impl>::ParseHoistableDeclaration( 3693 ParserBase<Impl>::ParseHoistableDeclaration(
3700 ZoneList<const AstRawString*>* names, bool default_export, bool* ok) { 3694 ZoneList<const AstRawString*>* names, bool default_export, bool* ok) {
3701 Expect(Token::FUNCTION, CHECK_OK_CUSTOM(NullStatement)); 3695 Expect(Token::FUNCTION, CHECK_OK_CUSTOM(NullStatement));
3702 int pos = position(); 3696 int pos = position();
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
4627 Expect(Token::RBRACE, CHECK_OK_CUSTOM(NullBlock)); 4621 Expect(Token::RBRACE, CHECK_OK_CUSTOM(NullBlock));
4628 block_state.set_end_position(scanner()->location().end_pos); 4622 block_state.set_end_position(scanner()->location().end_pos);
4629 body->set_scope(block_state.FinalizedBlockScope()); 4623 body->set_scope(block_state.FinalizedBlockScope());
4630 } 4624 }
4631 return body; 4625 return body;
4632 } 4626 }
4633 4627
4634 template <typename Impl> 4628 template <typename Impl>
4635 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseScopedStatement( 4629 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseScopedStatement(
4636 ZoneList<const AstRawString*>* labels, bool legacy, bool* ok) { 4630 ZoneList<const AstRawString*>* labels, bool legacy, bool* ok) {
4637 if (is_strict(language_mode()) || peek() != Token::FUNCTION || 4631 if (is_strict(language_mode()) || peek() != Token::FUNCTION || legacy) {
4638 (legacy && allow_harmony_restrictive_declarations())) {
4639 return ParseStatement(labels, kDisallowLabelledFunctionStatement, ok); 4632 return ParseStatement(labels, kDisallowLabelledFunctionStatement, ok);
4640 } else { 4633 } else {
4641 if (legacy) { 4634 if (legacy) {
4642 impl()->CountUsage(v8::Isolate::kLegacyFunctionDeclaration); 4635 impl()->CountUsage(v8::Isolate::kLegacyFunctionDeclaration);
4643 } 4636 }
4644 // Make a block around the statement for a lexical binding 4637 // Make a block around the statement for a lexical binding
4645 // is introduced by a FunctionDeclaration. 4638 // is introduced by a FunctionDeclaration.
4646 BlockState block_state(zone(), &scope_state_); 4639 BlockState block_state(zone(), &scope_state_);
4647 block_state.set_start_position(scanner()->location().beg_pos); 4640 block_state.set_start_position(scanner()->location().beg_pos);
4648 BlockT block = factory()->NewBlock(NULL, 1, false, kNoSourcePosition); 4641 BlockT block = factory()->NewBlock(NULL, 1, false, kNoSourcePosition);
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
5461 has_seen_constructor_ = true; 5454 has_seen_constructor_ = true;
5462 return; 5455 return;
5463 } 5456 }
5464 } 5457 }
5465 5458
5466 5459
5467 } // namespace internal 5460 } // namespace internal
5468 } // namespace v8 5461 } // namespace v8
5469 5462
5470 #endif // V8_PARSING_PARSER_BASE_H 5463 #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