OLD | NEW |
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/base/hashmap.h" | 10 #include "src/base/hashmap.h" |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 }; | 611 }; |
612 | 612 |
613 DeclarationScope* NewScriptScope() { | 613 DeclarationScope* NewScriptScope() { |
614 return new (zone()) DeclarationScope(zone(), nullptr, SCRIPT_SCOPE); | 614 return new (zone()) DeclarationScope(zone(), nullptr, SCRIPT_SCOPE); |
615 } | 615 } |
616 | 616 |
617 DeclarationScope* NewVarblockScope() { | 617 DeclarationScope* NewVarblockScope() { |
618 return new (zone()) DeclarationScope(zone(), scope(), BLOCK_SCOPE); | 618 return new (zone()) DeclarationScope(zone(), scope(), BLOCK_SCOPE); |
619 } | 619 } |
620 | 620 |
621 DeclarationScope* NewModuleScope(Scope* parent) { | 621 ModuleScope* NewModuleScope(DeclarationScope* parent) { |
622 DeclarationScope* result = | 622 return new (zone()) ModuleScope(zone(), parent, ast_value_factory()); |
623 new (zone()) DeclarationScope(zone(), parent, MODULE_SCOPE); | |
624 // TODO(verwaest): Move into the DeclarationScope constructor. | |
625 result->DeclareThis(ast_value_factory()); | |
626 return result; | |
627 } | 623 } |
628 | 624 |
629 DeclarationScope* NewEvalScope(Scope* parent) { | 625 DeclarationScope* NewEvalScope(Scope* parent) { |
630 return new (zone()) DeclarationScope(zone(), parent, EVAL_SCOPE); | 626 return new (zone()) DeclarationScope(zone(), parent, EVAL_SCOPE); |
631 } | 627 } |
632 | 628 |
633 Scope* NewScope(ScopeType scope_type) { | 629 Scope* NewScope(ScopeType scope_type) { |
634 return NewScopeWithParent(scope(), scope_type); | 630 return NewScopeWithParent(scope(), scope_type); |
635 } | 631 } |
636 | 632 |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 return this->scanner()->LiteralMatches("constructor", 11); | 1223 return this->scanner()->LiteralMatches("constructor", 11); |
1228 } | 1224 } |
1229 bool IsPrototype() { | 1225 bool IsPrototype() { |
1230 return this->scanner()->LiteralMatches("prototype", 9); | 1226 return this->scanner()->LiteralMatches("prototype", 9); |
1231 } | 1227 } |
1232 | 1228 |
1233 bool has_seen_constructor_; | 1229 bool has_seen_constructor_; |
1234 }; | 1230 }; |
1235 | 1231 |
1236 ModuleDescriptor* module() const { | 1232 ModuleDescriptor* module() const { |
1237 return scope()->AsDeclarationScope()->module(); | 1233 return scope()->AsModuleScope()->module(); |
1238 } | 1234 } |
1239 Scope* scope() const { return scope_state_->scope(); } | 1235 Scope* scope() const { return scope_state_->scope(); } |
1240 | 1236 |
1241 ScopeState* scope_state_; // Scope stack. | 1237 ScopeState* scope_state_; // Scope stack. |
1242 FunctionState* function_state_; // Function state stack. | 1238 FunctionState* function_state_; // Function state stack. |
1243 v8::Extension* extension_; | 1239 v8::Extension* extension_; |
1244 FuncNameInferrer* fni_; | 1240 FuncNameInferrer* fni_; |
1245 AstValueFactory* ast_value_factory_; // Not owned. | 1241 AstValueFactory* ast_value_factory_; // Not owned. |
1246 typename Traits::Type::Factory ast_node_factory_; | 1242 typename Traits::Type::Factory ast_node_factory_; |
1247 ParserRecorder* log_; | 1243 ParserRecorder* log_; |
(...skipping 2484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3732 has_seen_constructor_ = true; | 3728 has_seen_constructor_ = true; |
3733 return; | 3729 return; |
3734 } | 3730 } |
3735 } | 3731 } |
3736 | 3732 |
3737 | 3733 |
3738 } // namespace internal | 3734 } // namespace internal |
3739 } // namespace v8 | 3735 } // namespace v8 |
3740 | 3736 |
3741 #endif // V8_PARSING_PARSER_BASE_H | 3737 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |