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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 | 330 |
331 const AstRawString* catch_variable_name() const { | 331 const AstRawString* catch_variable_name() const { |
332 DCHECK(is_catch_scope()); | 332 DCHECK(is_catch_scope()); |
333 DCHECK_EQ(1, num_var()); | 333 DCHECK_EQ(1, num_var()); |
334 return static_cast<AstRawString*>(variables_.Start()->key); | 334 return static_cast<AstRawString*>(variables_.Start()->key); |
335 } | 335 } |
336 | 336 |
337 // --------------------------------------------------------------------------- | 337 // --------------------------------------------------------------------------- |
338 // Variable allocation. | 338 // Variable allocation. |
339 | 339 |
340 // Collect stack and context allocated local variables in this scope. Note | 340 // Collect variables in this scope. Note that the function variable - if |
341 // that the function variable - if present - is not collected and should be | 341 // present - is not collected and should be handled separately. |
342 // handled separately. | 342 void CollectVariables(ZoneList<Variable*>* stack_locals, |
343 void CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals, | 343 ZoneList<Variable*>* context_locals, |
344 ZoneList<Variable*>* context_locals, | 344 ZoneList<Variable*>* context_globals); |
345 ZoneList<Variable*>* context_globals); | |
346 | 345 |
347 // Result of variable allocation. | 346 // Result of variable allocation. |
348 int num_stack_slots() const { return num_stack_slots_; } | 347 int num_stack_slots() const { return num_stack_slots_; } |
349 int num_heap_slots() const { return num_heap_slots_; } | 348 int num_heap_slots() const { return num_heap_slots_; } |
350 int num_global_slots() const { return num_global_slots_; } | 349 int num_global_slots() const { return num_global_slots_; } |
351 | 350 |
352 int StackLocalCount() const; | 351 int StackLocalCount() const; |
353 int ContextLocalCount() const; | 352 int ContextLocalCount() const; |
354 int ContextGlobalCount() const; | 353 int ContextGlobalCount() const; |
355 | 354 |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 // new.target variable, function scopes only. | 829 // new.target variable, function scopes only. |
831 Variable* new_target_; | 830 Variable* new_target_; |
832 // Convenience variable; function scopes only. | 831 // Convenience variable; function scopes only. |
833 Variable* arguments_; | 832 Variable* arguments_; |
834 // Convenience variable; Subclass constructor only | 833 // Convenience variable; Subclass constructor only |
835 Variable* this_function_; | 834 Variable* this_function_; |
836 }; | 835 }; |
837 | 836 |
838 class ModuleScope final : public DeclarationScope { | 837 class ModuleScope final : public DeclarationScope { |
839 public: | 838 public: |
840 ModuleScope(Zone* zone, DeclarationScope* script_scope, | 839 ModuleScope(DeclarationScope* script_scope, |
841 AstValueFactory* ast_value_factory); | 840 AstValueFactory* ast_value_factory); |
842 | 841 |
843 ModuleDescriptor* module() const { | 842 ModuleDescriptor* module() const { |
844 DCHECK_NOT_NULL(module_descriptor_); | 843 DCHECK_NOT_NULL(module_descriptor_); |
845 return module_descriptor_; | 844 return module_descriptor_; |
846 } | 845 } |
847 | 846 |
848 // Set MODULE as VariableLocation for all variables that will live in some | 847 // Set MODULE as VariableLocation for all variables that will live in some |
849 // module's export table. | 848 // module's export table. |
850 void AllocateModuleVariables(); | 849 void AllocateModuleVariables(); |
851 | 850 |
852 private: | 851 private: |
853 ModuleDescriptor* module_descriptor_; | 852 ModuleDescriptor* module_descriptor_; |
854 }; | 853 }; |
855 | 854 |
856 } // namespace internal | 855 } // namespace internal |
857 } // namespace v8 | 856 } // namespace v8 |
858 | 857 |
859 #endif // V8_AST_SCOPES_H_ | 858 #endif // V8_AST_SCOPES_H_ |
OLD | NEW |