| 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 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 | 793 |
| 794 Variable* this_function_var() const { | 794 Variable* this_function_var() const { |
| 795 // This is only used in derived constructors atm. | 795 // This is only used in derived constructors atm. |
| 796 DCHECK(this_function_ == nullptr || | 796 DCHECK(this_function_ == nullptr || |
| 797 (is_function_scope() && (IsClassConstructor(function_kind()) || | 797 (is_function_scope() && (IsClassConstructor(function_kind()) || |
| 798 IsConciseMethod(function_kind()) || | 798 IsConciseMethod(function_kind()) || |
| 799 IsAccessorFunction(function_kind())))); | 799 IsAccessorFunction(function_kind())))); |
| 800 return this_function_; | 800 return this_function_; |
| 801 } | 801 } |
| 802 | 802 |
| 803 // Remove a temporary variable. This is for adjusting the scope of | |
| 804 // temporaries used when desugaring parameter initializers. | |
| 805 // Returns the index at which it was found in this scope, or -1 if | |
| 806 // it was not found. | |
| 807 int RemoveTemporary(Variable* var); | |
| 808 | |
| 809 // Adds a temporary variable in this scope's TemporaryScope. This is for | 803 // Adds a temporary variable in this scope's TemporaryScope. This is for |
| 810 // adjusting the scope of temporaries used when desugaring parameter | 804 // adjusting the scope of temporaries used when desugaring parameter |
| 811 // initializers. | 805 // initializers. |
| 812 void AddTemporary(Variable* var) { | 806 void AddTemporary(Variable* var) { |
| 813 DCHECK(!already_resolved()); | 807 DCHECK(!already_resolved()); |
| 814 // Temporaries are only placed in ClosureScopes. | 808 // Temporaries are only placed in ClosureScopes. |
| 815 DCHECK_EQ(GetClosureScope(), this); | 809 DCHECK_EQ(GetClosureScope(), this); |
| 816 temps_.Add(var, zone()); | 810 temps_.Add(var, zone()); |
| 817 } | 811 } |
| 818 | 812 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 | 860 |
| 867 // If the scope is a function scope, this is the function kind. | 861 // If the scope is a function scope, this is the function kind. |
| 868 const FunctionKind function_kind_; | 862 const FunctionKind function_kind_; |
| 869 | 863 |
| 870 bool has_simple_parameters_ : 1; | 864 bool has_simple_parameters_ : 1; |
| 871 | 865 |
| 872 // Info about the parameter list of a function. | 866 // Info about the parameter list of a function. |
| 873 int arity_; | 867 int arity_; |
| 874 int rest_index_; | 868 int rest_index_; |
| 875 Variable* rest_parameter_; | 869 Variable* rest_parameter_; |
| 876 // Compiler-allocated (user-invisible) temporaries. Due to the implementation | 870 // Compiler-allocated (user-invisible) temporaries. |
| 877 // of RemoveTemporary(), may contain nulls, which must be skipped-over during | |
| 878 // allocation and printing. | |
| 879 ZoneList<Variable*> temps_; | 871 ZoneList<Variable*> temps_; |
| 880 // Parameter list in source order. | 872 // Parameter list in source order. |
| 881 ZoneList<Variable*> params_; | 873 ZoneList<Variable*> params_; |
| 882 // Map of function names to lists of functions defined in sloppy blocks | 874 // Map of function names to lists of functions defined in sloppy blocks |
| 883 SloppyBlockFunctionMap sloppy_block_function_map_; | 875 SloppyBlockFunctionMap sloppy_block_function_map_; |
| 884 // Convenience variable. | 876 // Convenience variable. |
| 885 Variable* receiver_; | 877 Variable* receiver_; |
| 886 // Function variable, if any; function scopes only. | 878 // Function variable, if any; function scopes only. |
| 887 Variable* function_; | 879 Variable* function_; |
| 888 // new.target variable, function scopes only. | 880 // new.target variable, function scopes only. |
| 889 Variable* new_target_; | 881 Variable* new_target_; |
| 890 // Convenience variable; function scopes only. | 882 // Convenience variable; function scopes only. |
| 891 Variable* arguments_; | 883 Variable* arguments_; |
| 892 // Convenience variable; Subclass constructor only | 884 // Convenience variable; Subclass constructor only |
| 893 Variable* this_function_; | 885 Variable* this_function_; |
| 894 // Module descriptor; module scopes only. | 886 // Module descriptor; module scopes only. |
| 895 ModuleDescriptor* module_descriptor_; | 887 ModuleDescriptor* module_descriptor_; |
| 896 }; | 888 }; |
| 897 | 889 |
| 898 } // namespace internal | 890 } // namespace internal |
| 899 } // namespace v8 | 891 } // namespace v8 |
| 900 | 892 |
| 901 #endif // V8_AST_SCOPES_H_ | 893 #endif // V8_AST_SCOPES_H_ |
| OLD | NEW |