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_SCOPES_H_ | 5 #ifndef V8_SCOPES_H_ |
6 #define V8_SCOPES_H_ | 6 #define V8_SCOPES_H_ |
7 | 7 |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/pending-compilation-error-handler.h" | 9 #include "src/pending-compilation-error-handler.h" |
10 #include "src/zone.h" | 10 #include "src/zone.h" |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 | 572 |
573 // --------------------------------------------------------------------------- | 573 // --------------------------------------------------------------------------- |
574 // Debugging. | 574 // Debugging. |
575 | 575 |
576 #ifdef DEBUG | 576 #ifdef DEBUG |
577 void Print(int n = 0); // n = indentation; n < 0 => don't print recursively | 577 void Print(int n = 0); // n = indentation; n < 0 => don't print recursively |
578 #endif | 578 #endif |
579 | 579 |
580 // --------------------------------------------------------------------------- | 580 // --------------------------------------------------------------------------- |
581 // Implementation. | 581 // Implementation. |
582 protected: | 582 private: |
583 friend class ParserFactory; | |
584 | |
585 // Scope tree. | 583 // Scope tree. |
586 Scope* outer_scope_; // the immediately enclosing outer scope, or NULL | 584 Scope* outer_scope_; // the immediately enclosing outer scope, or NULL |
587 ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes | 585 ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes |
588 | 586 |
589 // The scope type. | 587 // The scope type. |
590 ScopeType scope_type_; | 588 ScopeType scope_type_; |
591 // If the scope is a function scope, this is the function kind. | 589 // If the scope is a function scope, this is the function kind. |
592 FunctionKind function_kind_; | 590 FunctionKind function_kind_; |
593 | 591 |
594 // Debugging support. | 592 // Debugging support. |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 // in this scopes. Must be called *after* all scopes have been | 782 // in this scopes. Must be called *after* all scopes have been |
785 // processed (parsed) to ensure that unresolved variables can be | 783 // processed (parsed) to ensure that unresolved variables can be |
786 // resolved properly. | 784 // resolved properly. |
787 // | 785 // |
788 // In the case of code compiled and run using 'eval', the context | 786 // In the case of code compiled and run using 'eval', the context |
789 // parameter is the context in which eval was called. In all other | 787 // parameter is the context in which eval was called. In all other |
790 // cases the context parameter is an empty handle. | 788 // cases the context parameter is an empty handle. |
791 MUST_USE_RESULT | 789 MUST_USE_RESULT |
792 bool AllocateVariables(ParseInfo* info, AstNodeFactory* factory); | 790 bool AllocateVariables(ParseInfo* info, AstNodeFactory* factory); |
793 | 791 |
794 private: | |
795 // Construct a scope based on the scope info. | 792 // Construct a scope based on the scope info. |
796 Scope(Zone* zone, Scope* inner_scope, ScopeType type, | 793 Scope(Zone* zone, Scope* inner_scope, ScopeType type, |
797 Handle<ScopeInfo> scope_info, AstValueFactory* value_factory); | 794 Handle<ScopeInfo> scope_info, AstValueFactory* value_factory); |
798 | 795 |
799 // Construct a catch scope with a binding for the name. | 796 // Construct a catch scope with a binding for the name. |
800 Scope(Zone* zone, Scope* inner_scope, const AstRawString* catch_variable_name, | 797 Scope(Zone* zone, Scope* inner_scope, const AstRawString* catch_variable_name, |
801 AstValueFactory* value_factory); | 798 AstValueFactory* value_factory); |
802 | 799 |
803 void AddInnerScope(Scope* inner_scope) { | 800 void AddInnerScope(Scope* inner_scope) { |
804 if (inner_scope != NULL) { | 801 if (inner_scope != NULL) { |
(...skipping 13 matching lines...) Expand all Loading... |
818 | 815 |
819 // For tracking which classes are declared consecutively. Needed for strong | 816 // For tracking which classes are declared consecutively. Needed for strong |
820 // mode. | 817 // mode. |
821 int class_declaration_group_start_; | 818 int class_declaration_group_start_; |
822 }; | 819 }; |
823 | 820 |
824 } // namespace internal | 821 } // namespace internal |
825 } // namespace v8 | 822 } // namespace v8 |
826 | 823 |
827 #endif // V8_SCOPES_H_ | 824 #endif // V8_SCOPES_H_ |
OLD | NEW |