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/zone.h" | 9 #include "src/zone.h" |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 int index() const { return index_; } | 112 int index() const { return index_; } |
113 InitializationFlag initialization_flag() const { | 113 InitializationFlag initialization_flag() const { |
114 return initialization_flag_; | 114 return initialization_flag_; |
115 } | 115 } |
116 | 116 |
117 void AllocateTo(VariableLocation location, int index) { | 117 void AllocateTo(VariableLocation location, int index) { |
118 location_ = location; | 118 location_ = location; |
119 index_ = index; | 119 index_ = index; |
120 } | 120 } |
121 | 121 |
122 void SetFromEval() { is_from_eval_ = true; } | |
123 | |
124 static int CompareIndex(Variable* const* v, Variable* const* w); | 122 static int CompareIndex(Variable* const* v, Variable* const* w); |
125 | 123 |
126 PropertyAttributes DeclarationPropertyAttributes() const { | |
127 int property_attributes = NONE; | |
128 if (IsImmutableVariableMode(mode_)) { | |
129 property_attributes |= READ_ONLY; | |
130 } | |
131 if (is_from_eval_) { | |
132 property_attributes |= EVAL_DECLARED; | |
133 } | |
134 return static_cast<PropertyAttributes>(property_attributes); | |
135 } | |
136 | |
137 private: | 124 private: |
138 Scope* scope_; | 125 Scope* scope_; |
139 const AstRawString* name_; | 126 const AstRawString* name_; |
140 VariableMode mode_; | 127 VariableMode mode_; |
141 Kind kind_; | 128 Kind kind_; |
142 VariableLocation location_; | 129 VariableLocation location_; |
143 int index_; | 130 int index_; |
144 int initializer_position_; | 131 int initializer_position_; |
145 | 132 |
146 // If this field is set, this variable references the stored locally bound | 133 // If this field is set, this variable references the stored locally bound |
147 // variable, but it might be shadowed by variable bindings introduced by | 134 // variable, but it might be shadowed by variable bindings introduced by |
148 // sloppy 'eval' calls between the reference scope (inclusive) and the | 135 // sloppy 'eval' calls between the reference scope (inclusive) and the |
149 // binding scope (exclusive). | 136 // binding scope (exclusive). |
150 Variable* local_if_not_shadowed_; | 137 Variable* local_if_not_shadowed_; |
151 | 138 |
152 // True if this variable is introduced by a sloppy eval | |
153 bool is_from_eval_; | |
154 | |
155 // Usage info. | 139 // Usage info. |
156 bool force_context_allocation_; // set by variable resolver | 140 bool force_context_allocation_; // set by variable resolver |
157 bool is_used_; | 141 bool is_used_; |
158 InitializationFlag initialization_flag_; | 142 InitializationFlag initialization_flag_; |
159 MaybeAssignedFlag maybe_assigned_; | 143 MaybeAssignedFlag maybe_assigned_; |
160 }; | 144 }; |
161 } // namespace internal | 145 } // namespace internal |
162 } // namespace v8 | 146 } // namespace v8 |
163 | 147 |
164 #endif // V8_AST_VARIABLES_H_ | 148 #endif // V8_AST_VARIABLES_H_ |
OLD | NEW |