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_AST_SCOPES_H_ | 5 #ifndef V8_AST_SCOPES_H_ |
6 #define V8_AST_SCOPES_H_ | 6 #define V8_AST_SCOPES_H_ |
7 | 7 |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/base/hashmap.h" | 9 #include "src/base/hashmap.h" |
10 #include "src/globals.h" | 10 #include "src/globals.h" |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 bool NeedsHomeObject() const { | 686 bool NeedsHomeObject() const { |
687 return scope_uses_super_property_ || | 687 return scope_uses_super_property_ || |
688 ((scope_calls_eval_ || inner_scope_calls_eval_) && | 688 ((scope_calls_eval_ || inner_scope_calls_eval_) && |
689 (IsConciseMethod(function_kind()) || | 689 (IsConciseMethod(function_kind()) || |
690 IsAccessorFunction(function_kind()) || | 690 IsAccessorFunction(function_kind()) || |
691 IsClassConstructor(function_kind()))); | 691 IsClassConstructor(function_kind()))); |
692 } | 692 } |
693 | 693 |
694 // The ModuleDescriptor for this scope; only for module scopes. | 694 // The ModuleDescriptor for this scope; only for module scopes. |
695 // TODO(verwaest): Move to ModuleScope? | 695 // TODO(verwaest): Move to ModuleScope? |
696 ModuleDescriptor* module() const { return module_descriptor_; } | 696 ModuleDescriptor* module() const { |
| 697 DCHECK(is_module_scope()); |
| 698 DCHECK_NOT_NULL(module_descriptor_); |
| 699 return module_descriptor_; |
| 700 } |
697 | 701 |
698 void DeclareThis(AstValueFactory* ast_value_factory); | 702 void DeclareThis(AstValueFactory* ast_value_factory); |
699 void DeclareDefaultFunctionVariables(AstValueFactory* ast_value_factory); | 703 void DeclareDefaultFunctionVariables(AstValueFactory* ast_value_factory); |
700 | 704 |
701 // This lookup corresponds to a lookup in the "intermediate" scope sitting | 705 // This lookup corresponds to a lookup in the "intermediate" scope sitting |
702 // between this scope and the outer scope. (ECMA-262, 3rd., requires that | 706 // between this scope and the outer scope. (ECMA-262, 3rd., requires that |
703 // the name of named function literal is kept in an intermediate scope | 707 // the name of named function literal is kept in an intermediate scope |
704 // in between this scope and the next outer scope.) | 708 // in between this scope and the next outer scope.) |
705 Variable* LookupFunctionVar(const AstRawString* name, | 709 Variable* LookupFunctionVar(const AstRawString* name, |
706 AstNodeFactory* factory); | 710 AstNodeFactory* factory); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 void AnalyzePartially(DeclarationScope* migrate_to, | 861 void AnalyzePartially(DeclarationScope* migrate_to, |
858 AstNodeFactory* ast_node_factory); | 862 AstNodeFactory* ast_node_factory); |
859 | 863 |
860 #ifdef DEBUG | 864 #ifdef DEBUG |
861 void PrintParameters(); | 865 void PrintParameters(); |
862 #endif | 866 #endif |
863 | 867 |
864 void AllocateLocals(AstValueFactory* ast_value_factory); | 868 void AllocateLocals(AstValueFactory* ast_value_factory); |
865 void AllocateParameterLocals(); | 869 void AllocateParameterLocals(); |
866 void AllocateReceiver(); | 870 void AllocateReceiver(); |
| 871 // Set MODULE as VariableLocation for all variables that will live in some |
| 872 // module's export table. |
| 873 void AllocateModuleVariables(); |
867 | 874 |
868 private: | 875 private: |
869 void AllocateParameter(Variable* var, int index); | 876 void AllocateParameter(Variable* var, int index); |
870 | 877 |
871 void SetDefaults(); | 878 void SetDefaults(); |
872 | 879 |
873 // If the scope is a function scope, this is the function kind. | 880 // If the scope is a function scope, this is the function kind. |
874 const FunctionKind function_kind_; | 881 const FunctionKind function_kind_; |
875 | 882 |
876 bool has_simple_parameters_ : 1; | 883 bool has_simple_parameters_ : 1; |
(...skipping 21 matching lines...) Expand all Loading... |
898 // Convenience variable; Subclass constructor only | 905 // Convenience variable; Subclass constructor only |
899 Variable* this_function_; | 906 Variable* this_function_; |
900 // Module descriptor; module scopes only. | 907 // Module descriptor; module scopes only. |
901 ModuleDescriptor* module_descriptor_; | 908 ModuleDescriptor* module_descriptor_; |
902 }; | 909 }; |
903 | 910 |
904 } // namespace internal | 911 } // namespace internal |
905 } // namespace v8 | 912 } // namespace v8 |
906 | 913 |
907 #endif // V8_AST_SCOPES_H_ | 914 #endif // V8_AST_SCOPES_H_ |
OLD | NEW |