| 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_AST_VARIABLES_H_ | 5 #ifndef V8_AST_VARIABLES_H_ |
| 6 #define V8_AST_VARIABLES_H_ | 6 #define V8_AST_VARIABLES_H_ |
| 7 | 7 |
| 8 #include "src/ast/ast-value-factory.h" | 8 #include "src/ast/ast-value-factory.h" |
| 9 #include "src/globals.h" | 9 #include "src/globals.h" |
| 10 #include "src/zone/zone.h" | 10 #include "src/zone/zone.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 | 14 |
| 15 // The AST refers to variables via VariableProxies - placeholders for the actual | 15 // The AST refers to variables via VariableProxies - placeholders for the actual |
| 16 // variables. Variables themselves are never directly referred to from the AST, | 16 // variables. Variables themselves are never directly referred to from the AST, |
| 17 // they are maintained by scopes, and referred to from VariableProxies and Slots | 17 // they are maintained by scopes, and referred to from VariableProxies and Slots |
| 18 // after binding and variable allocation. | 18 // after binding and variable allocation. |
| 19 class Variable final : public ZoneObject { | 19 class Variable final : public ZoneObject { |
| 20 public: | 20 public: |
| 21 Variable(Scope* scope, const AstRawString* name, VariableMode mode, | 21 Variable(Scope* scope, const AstRawString* name, VariableMode mode, |
| 22 VariableKind kind, InitializationFlag initialization_flag, | 22 VariableKind kind, InitializationFlag initialization_flag, |
| 23 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned); | 23 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned) |
| 24 : scope_(scope), |
| 25 name_(name), |
| 26 local_if_not_shadowed_(nullptr), |
| 27 next_(nullptr), |
| 28 index_(-1), |
| 29 initializer_position_(kNoSourcePosition), |
| 30 bit_field_(MaybeAssignedFlagField::encode(maybe_assigned_flag) | |
| 31 InitializationFlagField::encode(initialization_flag) | |
| 32 VariableModeField::encode(mode) | |
| 33 IsUsedField::encode(false) | |
| 34 ForceContextAllocationField::encode(false) | |
| 35 ForceHoleInitializationField::encode(false) | |
| 36 LocationField::encode(VariableLocation::UNALLOCATED) | |
| 37 VariableKindField::encode(kind)) { |
| 38 // Var declared variables never need initialization. |
| 39 DCHECK(!(mode == VAR && initialization_flag == kNeedsInitialization)); |
| 40 } |
| 24 | 41 |
| 25 explicit Variable(Variable* other); | 42 explicit Variable(Variable* other); |
| 26 | 43 |
| 27 // The source code for an eval() call may refer to a variable that is | 44 // The source code for an eval() call may refer to a variable that is |
| 28 // in an outer scope about which we don't know anything (it may not | 45 // in an outer scope about which we don't know anything (it may not |
| 29 // be the script scope). scope() is NULL in that case. Currently the | 46 // be the script scope). scope() is NULL in that case. Currently the |
| 30 // scope is only used to follow the context chain length. | 47 // scope is only used to follow the context chain length. |
| 31 Scope* scope() const { return scope_; } | 48 Scope* scope() const { return scope_; } |
| 32 | 49 |
| 33 // This is for adjusting the scope of temporaries used when desugaring | 50 // This is for adjusting the scope of temporaries used when desugaring |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 class MaybeAssignedFlagField | 210 class MaybeAssignedFlagField |
| 194 : public BitField16<MaybeAssignedFlag, | 211 : public BitField16<MaybeAssignedFlag, |
| 195 ForceHoleInitializationField::kNext, 1> {}; | 212 ForceHoleInitializationField::kNext, 1> {}; |
| 196 Variable** next() { return &next_; } | 213 Variable** next() { return &next_; } |
| 197 friend List; | 214 friend List; |
| 198 }; | 215 }; |
| 199 } // namespace internal | 216 } // namespace internal |
| 200 } // namespace v8 | 217 } // namespace v8 |
| 201 | 218 |
| 202 #endif // V8_AST_VARIABLES_H_ | 219 #endif // V8_AST_VARIABLES_H_ |
| OLD | NEW |