| 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" | 
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 93   VariableLocation location() const { | 93   VariableLocation location() const { | 
| 94     return LocationField::decode(bit_field_); | 94     return LocationField::decode(bit_field_); | 
| 95   } | 95   } | 
| 96   VariableKind kind() const { return VariableKindField::decode(bit_field_); } | 96   VariableKind kind() const { return VariableKindField::decode(bit_field_); } | 
| 97   InitializationFlag initialization_flag() const { | 97   InitializationFlag initialization_flag() const { | 
| 98     return InitializationFlagField::decode(bit_field_); | 98     return InitializationFlagField::decode(bit_field_); | 
| 99   } | 99   } | 
| 100 | 100 | 
| 101   int index() const { return index_; } | 101   int index() const { return index_; } | 
| 102 | 102 | 
| 103   // Sentinel index values for module exports and imports. |  | 
| 104   enum { kModuleExportIndex, kModuleImportIndex }; |  | 
| 105 |  | 
| 106   bool IsExport() const { | 103   bool IsExport() const { | 
| 107     DCHECK(location() == VariableLocation::MODULE); | 104     DCHECK_EQ(location(), VariableLocation::MODULE); | 
| 108     return index() == kModuleExportIndex; | 105     DCHECK_NE(index(), 0); | 
|  | 106     return index() > 0; | 
| 109   } | 107   } | 
| 110 | 108 | 
| 111   void AllocateTo(VariableLocation location, int index) { | 109   void AllocateTo(VariableLocation location, int index) { | 
| 112     DCHECK(IsUnallocated() || | 110     DCHECK(IsUnallocated() || | 
| 113            (this->location() == location && this->index() == index)); | 111            (this->location() == location && this->index() == index)); | 
| 114     DCHECK_IMPLIES(location == VariableLocation::MODULE, | 112     DCHECK_IMPLIES(location == VariableLocation::MODULE, index != 0); | 
| 115                    index == kModuleExportIndex || index == kModuleImportIndex); |  | 
| 116     bit_field_ = LocationField::update(bit_field_, location); | 113     bit_field_ = LocationField::update(bit_field_, location); | 
| 117     DCHECK_EQ(location, this->location()); | 114     DCHECK_EQ(location, this->location()); | 
| 118     index_ = index; | 115     index_ = index; | 
| 119   } | 116   } | 
| 120 | 117 | 
| 121   static InitializationFlag DefaultInitializationFlag(VariableMode mode) { | 118   static InitializationFlag DefaultInitializationFlag(VariableMode mode) { | 
| 122     DCHECK(IsDeclaredVariableMode(mode)); | 119     DCHECK(IsDeclaredVariableMode(mode)); | 
| 123     return mode == VAR ? kCreatedInitialized : kNeedsInitialization; | 120     return mode == VAR ? kCreatedInitialized : kNeedsInitialization; | 
| 124   } | 121   } | 
| 125 | 122 | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 156   Variable** next() { return &next_; } | 153   Variable** next() { return &next_; } | 
| 157   friend List; | 154   friend List; | 
| 158   // To reset next to nullptr upon resetting after preparsing. | 155   // To reset next to nullptr upon resetting after preparsing. | 
| 159   // TODO(verwaest): Remove once we properly preparse parameters. | 156   // TODO(verwaest): Remove once we properly preparse parameters. | 
| 160   friend class DeclarationScope; | 157   friend class DeclarationScope; | 
| 161 }; | 158 }; | 
| 162 }  // namespace internal | 159 }  // namespace internal | 
| 163 }  // namespace v8 | 160 }  // namespace v8 | 
| 164 | 161 | 
| 165 #endif  // V8_AST_VARIABLES_H_ | 162 #endif  // V8_AST_VARIABLES_H_ | 
| OLD | NEW | 
|---|