OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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_VARIABLES_H_ | 5 #ifndef V8_VARIABLES_H_ |
6 #define V8_VARIABLES_H_ | 6 #define V8_VARIABLES_H_ |
7 | 7 |
8 #include "src/ast-value-factory.h" | 8 #include "src/ast-value-factory.h" |
9 #include "src/zone.h" | 9 #include "src/zone.h" |
10 | 10 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 bool is_const_mode() const { return IsImmutableVariableMode(mode_); } | 98 bool is_const_mode() const { return IsImmutableVariableMode(mode_); } |
99 bool binding_needs_init() const { | 99 bool binding_needs_init() const { |
100 return initialization_flag_ == kNeedsInitialization; | 100 return initialization_flag_ == kNeedsInitialization; |
101 } | 101 } |
102 | 102 |
103 bool is_function() const { return kind_ == FUNCTION; } | 103 bool is_function() const { return kind_ == FUNCTION; } |
104 bool is_class() const { return kind_ == CLASS; } | 104 bool is_class() const { return kind_ == CLASS; } |
105 bool is_this() const { return kind_ == THIS; } | 105 bool is_this() const { return kind_ == THIS; } |
106 bool is_arguments() const { return kind_ == ARGUMENTS; } | 106 bool is_arguments() const { return kind_ == ARGUMENTS; } |
107 | 107 |
108 // For script scopes, the "this" binding is provided by a ScriptContext added | |
109 // to the global's ScriptContextTable. This binding might not statically | |
110 // resolve to a Variable::THIS binding, instead being DYNAMIC_LOCAL. However | |
111 // any variable named "this" does indeed refer to a Variable::THIS binding; | |
112 // the grammar ensures this to be the case. So wherever a "this" binding | |
113 // might be provided by the global, use HasThisName instead of is_this(). | |
114 bool HasThisName(Isolate* isolate) const { | |
115 return is_this() || *name() == *isolate->factory()->this_string(); | |
116 } | |
117 | |
118 ClassVariable* AsClassVariable() { | 108 ClassVariable* AsClassVariable() { |
119 DCHECK(is_class()); | 109 DCHECK(is_class()); |
120 return reinterpret_cast<ClassVariable*>(this); | 110 return reinterpret_cast<ClassVariable*>(this); |
121 } | 111 } |
122 | 112 |
123 // True if the variable is named eval and not known to be shadowed. | 113 // True if the variable is named eval and not known to be shadowed. |
124 bool is_possibly_eval(Isolate* isolate) const { | 114 bool is_possibly_eval(Isolate* isolate) const { |
125 return IsVariable(isolate->factory()->eval_string()); | 115 return IsVariable(isolate->factory()->eval_string()); |
126 } | 116 } |
127 | 117 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 200 |
211 private: | 201 private: |
212 // For classes we keep track of consecutive groups of delcarations. They are | 202 // For classes we keep track of consecutive groups of delcarations. They are |
213 // needed for strong mode scoping checks. TODO(marja, rossberg): Implement | 203 // needed for strong mode scoping checks. TODO(marja, rossberg): Implement |
214 // checks for functions too. | 204 // checks for functions too. |
215 int declaration_group_start_; | 205 int declaration_group_start_; |
216 }; | 206 }; |
217 } } // namespace v8::internal | 207 } } // namespace v8::internal |
218 | 208 |
219 #endif // V8_VARIABLES_H_ | 209 #endif // V8_VARIABLES_H_ |
OLD | NEW |