| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 return initialization_flag_; | 123 return initialization_flag_; |
| 124 } | 124 } |
| 125 | 125 |
| 126 void AllocateTo(Location location, int index) { | 126 void AllocateTo(Location location, int index) { |
| 127 location_ = location; | 127 location_ = location; |
| 128 index_ = index; | 128 index_ = index; |
| 129 } | 129 } |
| 130 | 130 |
| 131 static int CompareIndex(Variable* const* v, Variable* const* w); | 131 static int CompareIndex(Variable* const* v, Variable* const* w); |
| 132 | 132 |
| 133 void RecordStrongModeReference(int start_position, int end_position) { |
| 134 // Record the earliest reference to the variable. Used in error messages for |
| 135 // strong mode references to undeclared variables. |
| 136 if (has_strong_mode_reference_ && |
| 137 strong_mode_reference_start_position_ < start_position) |
| 138 return; |
| 139 has_strong_mode_reference_ = true; |
| 140 strong_mode_reference_start_position_ = start_position; |
| 141 strong_mode_reference_end_position_ = end_position; |
| 142 } |
| 143 |
| 144 bool has_strong_mode_reference() const { return has_strong_mode_reference_; } |
| 145 int strong_mode_reference_start_position() const { |
| 146 return strong_mode_reference_start_position_; |
| 147 } |
| 148 int strong_mode_reference_end_position() const { |
| 149 return strong_mode_reference_end_position_; |
| 150 } |
| 151 |
| 133 private: | 152 private: |
| 134 Scope* scope_; | 153 Scope* scope_; |
| 135 const AstRawString* name_; | 154 const AstRawString* name_; |
| 136 VariableMode mode_; | 155 VariableMode mode_; |
| 137 Kind kind_; | 156 Kind kind_; |
| 138 Location location_; | 157 Location location_; |
| 139 int index_; | 158 int index_; |
| 140 int initializer_position_; | 159 int initializer_position_; |
| 160 // Tracks whether the variable is bound to a VariableProxy which is in strong |
| 161 // mode, and if yes, the source location of the reference. |
| 162 bool has_strong_mode_reference_; |
| 163 int strong_mode_reference_start_position_; |
| 164 int strong_mode_reference_end_position_; |
| 141 | 165 |
| 142 // If this field is set, this variable references the stored locally bound | 166 // If this field is set, this variable references the stored locally bound |
| 143 // variable, but it might be shadowed by variable bindings introduced by | 167 // variable, but it might be shadowed by variable bindings introduced by |
| 144 // sloppy 'eval' calls between the reference scope (inclusive) and the | 168 // sloppy 'eval' calls between the reference scope (inclusive) and the |
| 145 // binding scope (exclusive). | 169 // binding scope (exclusive). |
| 146 Variable* local_if_not_shadowed_; | 170 Variable* local_if_not_shadowed_; |
| 147 | 171 |
| 148 // Valid as a reference? (const and this are not valid, for example) | 172 // Valid as a reference? (const and this are not valid, for example) |
| 149 bool is_valid_ref_; | 173 bool is_valid_ref_; |
| 150 | 174 |
| 151 // Usage info. | 175 // Usage info. |
| 152 bool force_context_allocation_; // set by variable resolver | 176 bool force_context_allocation_; // set by variable resolver |
| 153 bool is_used_; | 177 bool is_used_; |
| 154 InitializationFlag initialization_flag_; | 178 InitializationFlag initialization_flag_; |
| 155 MaybeAssignedFlag maybe_assigned_; | 179 MaybeAssignedFlag maybe_assigned_; |
| 156 }; | 180 }; |
| 157 | 181 |
| 158 | 182 |
| 159 } } // namespace v8::internal | 183 } } // namespace v8::internal |
| 160 | 184 |
| 161 #endif // V8_VARIABLES_H_ | 185 #endif // V8_VARIABLES_H_ |
| OLD | NEW |