| 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/pending-compilation-error-handler.h" | 9 #include "src/pending-compilation-error-handler.h" |
| 10 #include "src/zone.h" | 10 #include "src/zone.h" |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 | 503 |
| 504 // Result of variable allocation. | 504 // Result of variable allocation. |
| 505 int num_stack_slots() const { return num_stack_slots_; } | 505 int num_stack_slots() const { return num_stack_slots_; } |
| 506 int num_heap_slots() const { return num_heap_slots_; } | 506 int num_heap_slots() const { return num_heap_slots_; } |
| 507 int num_global_slots() const { return num_global_slots_; } | 507 int num_global_slots() const { return num_global_slots_; } |
| 508 | 508 |
| 509 int StackLocalCount() const; | 509 int StackLocalCount() const; |
| 510 int ContextLocalCount() const; | 510 int ContextLocalCount() const; |
| 511 int ContextGlobalCount() const; | 511 int ContextGlobalCount() const; |
| 512 | 512 |
| 513 // For script scopes, the number of module literals (including nested ones). | |
| 514 int num_modules() const { return num_modules_; } | |
| 515 | |
| 516 // For module scopes, the host scope's internal variable binding this module. | |
| 517 Variable* module_var() const { return module_var_; } | |
| 518 | |
| 519 // Make sure this scope and all outer scopes are eagerly compiled. | 513 // Make sure this scope and all outer scopes are eagerly compiled. |
| 520 void ForceEagerCompilation() { force_eager_compilation_ = true; } | 514 void ForceEagerCompilation() { force_eager_compilation_ = true; } |
| 521 | 515 |
| 522 // Determine if we can parse a function literal in this scope lazily. | 516 // Determine if we can parse a function literal in this scope lazily. |
| 523 bool AllowsLazyParsing() const; | 517 bool AllowsLazyParsing() const; |
| 524 | 518 |
| 525 // Determine if we can use lazy compilation for this scope. | 519 // Determine if we can use lazy compilation for this scope. |
| 526 bool AllowsLazyCompilation() const; | 520 bool AllowsLazyCompilation() const; |
| 527 | 521 |
| 528 // Determine if we can use lazy compilation for this scope without a context. | 522 // Determine if we can use lazy compilation for this scope without a context. |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 bool is_declaration_scope_; | 679 bool is_declaration_scope_; |
| 686 | 680 |
| 687 // Computed as variables are declared. | 681 // Computed as variables are declared. |
| 688 int num_var_or_const_; | 682 int num_var_or_const_; |
| 689 | 683 |
| 690 // Computed via AllocateVariables; function, block and catch scopes only. | 684 // Computed via AllocateVariables; function, block and catch scopes only. |
| 691 int num_stack_slots_; | 685 int num_stack_slots_; |
| 692 int num_heap_slots_; | 686 int num_heap_slots_; |
| 693 int num_global_slots_; | 687 int num_global_slots_; |
| 694 | 688 |
| 695 // The number of modules (including nested ones). | |
| 696 int num_modules_; | |
| 697 | |
| 698 // For module scopes, the host scope's temporary variable binding this module. | |
| 699 Variable* module_var_; | |
| 700 | |
| 701 // Info about the parameter list of a function. | 689 // Info about the parameter list of a function. |
| 702 int arity_; | 690 int arity_; |
| 703 bool has_simple_parameters_; | 691 bool has_simple_parameters_; |
| 704 Variable* rest_parameter_; | 692 Variable* rest_parameter_; |
| 705 int rest_index_; | 693 int rest_index_; |
| 706 | 694 |
| 707 // Serialized scope info support. | 695 // Serialized scope info support. |
| 708 Handle<ScopeInfo> scope_info_; | 696 Handle<ScopeInfo> scope_info_; |
| 709 bool already_resolved() { return already_resolved_; } | 697 bool already_resolved() { return already_resolved_; } |
| 710 | 698 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 // Variable allocation. | 775 // Variable allocation. |
| 788 void AllocateStackSlot(Variable* var); | 776 void AllocateStackSlot(Variable* var); |
| 789 void AllocateHeapSlot(Variable* var); | 777 void AllocateHeapSlot(Variable* var); |
| 790 void AllocateParameterLocals(Isolate* isolate); | 778 void AllocateParameterLocals(Isolate* isolate); |
| 791 void AllocateNonParameterLocal(Isolate* isolate, Variable* var); | 779 void AllocateNonParameterLocal(Isolate* isolate, Variable* var); |
| 792 void AllocateDeclaredGlobal(Isolate* isolate, Variable* var); | 780 void AllocateDeclaredGlobal(Isolate* isolate, Variable* var); |
| 793 void AllocateNonParameterLocalsAndDeclaredGlobals(Isolate* isolate); | 781 void AllocateNonParameterLocalsAndDeclaredGlobals(Isolate* isolate); |
| 794 void AllocateVariablesRecursively(Isolate* isolate); | 782 void AllocateVariablesRecursively(Isolate* isolate); |
| 795 void AllocateParameter(Variable* var, int index); | 783 void AllocateParameter(Variable* var, int index); |
| 796 void AllocateReceiver(); | 784 void AllocateReceiver(); |
| 797 void AllocateModules(); | |
| 798 | 785 |
| 799 // Resolve and fill in the allocation information for all variables | 786 // Resolve and fill in the allocation information for all variables |
| 800 // in this scopes. Must be called *after* all scopes have been | 787 // in this scopes. Must be called *after* all scopes have been |
| 801 // processed (parsed) to ensure that unresolved variables can be | 788 // processed (parsed) to ensure that unresolved variables can be |
| 802 // resolved properly. | 789 // resolved properly. |
| 803 // | 790 // |
| 804 // In the case of code compiled and run using 'eval', the context | 791 // In the case of code compiled and run using 'eval', the context |
| 805 // parameter is the context in which eval was called. In all other | 792 // parameter is the context in which eval was called. In all other |
| 806 // cases the context parameter is an empty handle. | 793 // cases the context parameter is an empty handle. |
| 807 MUST_USE_RESULT | 794 MUST_USE_RESULT |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 | 830 |
| 844 // For tracking which classes are declared consecutively. Needed for strong | 831 // For tracking which classes are declared consecutively. Needed for strong |
| 845 // mode. | 832 // mode. |
| 846 int class_declaration_group_start_; | 833 int class_declaration_group_start_; |
| 847 }; | 834 }; |
| 848 | 835 |
| 849 } // namespace internal | 836 } // namespace internal |
| 850 } // namespace v8 | 837 } // namespace v8 |
| 851 | 838 |
| 852 #endif // V8_AST_SCOPES_H_ | 839 #endif // V8_AST_SCOPES_H_ |
| OLD | NEW |