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 29 matching lines...) Expand all Loading... |
40 // the context object on the heap, starting at 0. scope() is the | 40 // the context object on the heap, starting at 0. scope() is the |
41 // corresponding scope. | 41 // corresponding scope. |
42 CONTEXT, | 42 CONTEXT, |
43 | 43 |
44 // A named slot in a heap context. name() is the variable name in the | 44 // A named slot in a heap context. name() is the variable name in the |
45 // context object on the heap, with lookup starting at the current | 45 // context object on the heap, with lookup starting at the current |
46 // context. index() is invalid. | 46 // context. index() is invalid. |
47 LOOKUP | 47 LOOKUP |
48 }; | 48 }; |
49 | 49 |
50 Variable(Scope* scope, const AstRawString* name, VariableMode mode, | 50 Variable(Scope* scope, const AstRawString* name, VariableMode mode, Kind kind, |
51 bool is_valid_ref, Kind kind, InitializationFlag initialization_flag, | 51 InitializationFlag initialization_flag, |
52 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned); | 52 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned); |
53 | 53 |
54 // Printing support | 54 // Printing support |
55 static const char* Mode2String(VariableMode mode); | 55 static const char* Mode2String(VariableMode mode); |
56 | 56 |
57 bool IsValidReference() { return is_valid_ref_; } | |
58 | |
59 // The source code for an eval() call may refer to a variable that is | 57 // The source code for an eval() call may refer to a variable that is |
60 // in an outer scope about which we don't know anything (it may not | 58 // in an outer scope about which we don't know anything (it may not |
61 // be the script scope). scope() is NULL in that case. Currently the | 59 // be the script scope). scope() is NULL in that case. Currently the |
62 // scope is only used to follow the context chain length. | 60 // scope is only used to follow the context chain length. |
63 Scope* scope() const { return scope_; } | 61 Scope* scope() const { return scope_; } |
64 | 62 |
65 Handle<String> name() const { return name_->string(); } | 63 Handle<String> name() const { return name_->string(); } |
66 const AstRawString* raw_name() const { return name_; } | 64 const AstRawString* raw_name() const { return name_; } |
67 VariableMode mode() const { return mode_; } | 65 VariableMode mode() const { return mode_; } |
68 bool has_forced_context_allocation() const { | 66 bool has_forced_context_allocation() const { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 Location location_; | 136 Location location_; |
139 int index_; | 137 int index_; |
140 int initializer_position_; | 138 int initializer_position_; |
141 | 139 |
142 // If this field is set, this variable references the stored locally bound | 140 // If this field is set, this variable references the stored locally bound |
143 // variable, but it might be shadowed by variable bindings introduced by | 141 // variable, but it might be shadowed by variable bindings introduced by |
144 // sloppy 'eval' calls between the reference scope (inclusive) and the | 142 // sloppy 'eval' calls between the reference scope (inclusive) and the |
145 // binding scope (exclusive). | 143 // binding scope (exclusive). |
146 Variable* local_if_not_shadowed_; | 144 Variable* local_if_not_shadowed_; |
147 | 145 |
148 // Valid as a reference? (const and this are not valid, for example) | |
149 bool is_valid_ref_; | |
150 | |
151 // Usage info. | 146 // Usage info. |
152 bool force_context_allocation_; // set by variable resolver | 147 bool force_context_allocation_; // set by variable resolver |
153 bool is_used_; | 148 bool is_used_; |
154 InitializationFlag initialization_flag_; | 149 InitializationFlag initialization_flag_; |
155 MaybeAssignedFlag maybe_assigned_; | 150 MaybeAssignedFlag maybe_assigned_; |
156 }; | 151 }; |
157 | 152 |
158 | 153 |
159 } } // namespace v8::internal | 154 } } // namespace v8::internal |
160 | 155 |
161 #endif // V8_VARIABLES_H_ | 156 #endif // V8_VARIABLES_H_ |
OLD | NEW |