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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 | 612 |
613 private: | 613 private: |
614 ParserBase* parser_; | 614 ParserBase* parser_; |
615 Mode old_mode_; | 615 Mode old_mode_; |
616 }; | 616 }; |
617 | 617 |
618 Scope* NewScriptScope() { | 618 Scope* NewScriptScope() { |
619 return new (zone()) Scope(zone(), nullptr, SCRIPT_SCOPE, kNormalFunction); | 619 return new (zone()) Scope(zone(), nullptr, SCRIPT_SCOPE, kNormalFunction); |
620 } | 620 } |
621 | 621 |
622 Scope* NewScope(Scope* parent, ScopeType scope_type) { | 622 Scope* NewScope(ScopeType scope_type) { |
| 623 return NewScopeWithParent(scope(), scope_type); |
| 624 } |
| 625 |
| 626 // This constructor should only be used when absolutely necessary. Most scopes |
| 627 // should automatically use scope() as parent, and be fine with |
| 628 // NewScope(ScopeType) above. |
| 629 Scope* NewScopeWithParent(Scope* parent, ScopeType scope_type) { |
623 // Must always use the specific constructors for the blacklisted scope | 630 // Must always use the specific constructors for the blacklisted scope |
624 // types. | 631 // types. |
625 DCHECK_NE(FUNCTION_SCOPE, scope_type); | 632 DCHECK_NE(FUNCTION_SCOPE, scope_type); |
626 DCHECK_NE(SCRIPT_SCOPE, scope_type); | 633 DCHECK_NE(SCRIPT_SCOPE, scope_type); |
627 DCHECK_NOT_NULL(parent); | 634 DCHECK_NOT_NULL(parent); |
628 Scope* result = | 635 Scope* result = |
629 new (zone()) Scope(zone(), parent, scope_type, kNormalFunction); | 636 new (zone()) Scope(zone(), parent, scope_type, kNormalFunction); |
630 if (scope_type == MODULE_SCOPE) result->DeclareThis(ast_value_factory()); | 637 if (scope_type == MODULE_SCOPE) result->DeclareThis(ast_value_factory()); |
631 return result; | 638 return result; |
632 } | 639 } |
(...skipping 3056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3689 has_seen_constructor_ = true; | 3696 has_seen_constructor_ = true; |
3690 return; | 3697 return; |
3691 } | 3698 } |
3692 } | 3699 } |
3693 | 3700 |
3694 | 3701 |
3695 } // namespace internal | 3702 } // namespace internal |
3696 } // namespace v8 | 3703 } // namespace v8 |
3697 | 3704 |
3698 #endif // V8_PARSING_PARSER_BASE_H | 3705 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |