| 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 void set_local_if_not_shadowed(Variable* local) { | 123 void set_local_if_not_shadowed(Variable* local) { |
| 124 local_if_not_shadowed_ = local; | 124 local_if_not_shadowed_ = local; |
| 125 } | 125 } |
| 126 | 126 |
| 127 Location location() const { return location_; } | 127 Location location() const { return location_; } |
| 128 int index() const { return index_; } | 128 int index() const { return index_; } |
| 129 InitializationFlag initialization_flag() const { | 129 InitializationFlag initialization_flag() const { |
| 130 return initialization_flag_; | 130 return initialization_flag_; |
| 131 } | 131 } |
| 132 | 132 |
| 133 Handle<Type> type() const { return type_; } |
| 134 void set_type(Handle<Type> type) { type_ = type; } |
| 135 |
| 133 void AllocateTo(Location location, int index) { | 136 void AllocateTo(Location location, int index) { |
| 134 location_ = location; | 137 location_ = location; |
| 135 index_ = index; | 138 index_ = index; |
| 136 } | 139 } |
| 137 | 140 |
| 138 static int CompareIndex(Variable* const* v, Variable* const* w); | 141 static int CompareIndex(Variable* const* v, Variable* const* w); |
| 139 | 142 |
| 140 void RecordStrongModeReference(int start_position, int end_position) { | 143 void RecordStrongModeReference(int start_position, int end_position) { |
| 141 // Record the earliest reference to the variable. Used in error messages for | 144 // Record the earliest reference to the variable. Used in error messages for |
| 142 // strong mode references to undeclared variables. | 145 // strong mode references to undeclared variables. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 172 | 175 |
| 173 // If this field is set, this variable references the stored locally bound | 176 // If this field is set, this variable references the stored locally bound |
| 174 // variable, but it might be shadowed by variable bindings introduced by | 177 // variable, but it might be shadowed by variable bindings introduced by |
| 175 // sloppy 'eval' calls between the reference scope (inclusive) and the | 178 // sloppy 'eval' calls between the reference scope (inclusive) and the |
| 176 // binding scope (exclusive). | 179 // binding scope (exclusive). |
| 177 Variable* local_if_not_shadowed_; | 180 Variable* local_if_not_shadowed_; |
| 178 | 181 |
| 179 // Usage info. | 182 // Usage info. |
| 180 bool force_context_allocation_; // set by variable resolver | 183 bool force_context_allocation_; // set by variable resolver |
| 181 bool is_used_; | 184 bool is_used_; |
| 185 Handle<Type> type_; |
| 182 InitializationFlag initialization_flag_; | 186 InitializationFlag initialization_flag_; |
| 183 MaybeAssignedFlag maybe_assigned_; | 187 MaybeAssignedFlag maybe_assigned_; |
| 184 }; | 188 }; |
| 185 | 189 |
| 186 class ClassVariable : public Variable { | 190 class ClassVariable : public Variable { |
| 187 public: | 191 public: |
| 188 ClassVariable(Scope* scope, const AstRawString* name, VariableMode mode, | 192 ClassVariable(Scope* scope, const AstRawString* name, VariableMode mode, |
| 189 InitializationFlag initialization_flag, | 193 InitializationFlag initialization_flag, |
| 190 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned, | 194 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned, |
| 191 int declaration_group_start = -1) | 195 int declaration_group_start = -1) |
| 192 : Variable(scope, name, mode, Variable::CLASS, initialization_flag, | 196 : Variable(scope, name, mode, Variable::CLASS, initialization_flag, |
| 193 maybe_assigned_flag), | 197 maybe_assigned_flag), |
| 194 declaration_group_start_(declaration_group_start) {} | 198 declaration_group_start_(declaration_group_start) {} |
| 195 | 199 |
| 196 int declaration_group_start() const { return declaration_group_start_; } | 200 int declaration_group_start() const { return declaration_group_start_; } |
| 197 void set_declaration_group_start(int declaration_group_start) { | 201 void set_declaration_group_start(int declaration_group_start) { |
| 198 declaration_group_start_ = declaration_group_start; | 202 declaration_group_start_ = declaration_group_start; |
| 199 } | 203 } |
| 200 | 204 |
| 201 private: | 205 private: |
| 202 // For classes we keep track of consecutive groups of delcarations. They are | 206 // For classes we keep track of consecutive groups of delcarations. They are |
| 203 // needed for strong mode scoping checks. TODO(marja, rossberg): Implement | 207 // needed for strong mode scoping checks. TODO(marja, rossberg): Implement |
| 204 // checks for functions too. | 208 // checks for functions too. |
| 205 int declaration_group_start_; | 209 int declaration_group_start_; |
| 206 }; | 210 }; |
| 207 } } // namespace v8::internal | 211 } } // namespace v8::internal |
| 208 | 212 |
| 209 #endif // V8_VARIABLES_H_ | 213 #endif // V8_VARIABLES_H_ |
| OLD | NEW |