OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/messages.h" | 9 #include "src/messages.h" |
10 #include "src/parser.h" | 10 #include "src/parser.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 AllocateHeapSlot(variable); | 145 AllocateHeapSlot(variable); |
146 } | 146 } |
147 | 147 |
148 | 148 |
149 void Scope::SetDefaults(ScopeType scope_type, Scope* outer_scope, | 149 void Scope::SetDefaults(ScopeType scope_type, Scope* outer_scope, |
150 Handle<ScopeInfo> scope_info, | 150 Handle<ScopeInfo> scope_info, |
151 FunctionKind function_kind) { | 151 FunctionKind function_kind) { |
152 outer_scope_ = outer_scope; | 152 outer_scope_ = outer_scope; |
153 scope_type_ = scope_type; | 153 scope_type_ = scope_type; |
154 function_kind_ = function_kind; | 154 function_kind_ = function_kind; |
155 block_scope_is_class_scope_ = false; | |
156 scope_name_ = ast_value_factory_->empty_string(); | 155 scope_name_ = ast_value_factory_->empty_string(); |
157 dynamics_ = nullptr; | 156 dynamics_ = nullptr; |
158 receiver_ = nullptr; | 157 receiver_ = nullptr; |
159 new_target_ = nullptr; | 158 new_target_ = nullptr; |
160 function_ = nullptr; | 159 function_ = nullptr; |
161 arguments_ = nullptr; | 160 arguments_ = nullptr; |
162 this_function_ = nullptr; | 161 this_function_ = nullptr; |
163 illegal_redecl_ = nullptr; | 162 illegal_redecl_ = nullptr; |
164 scope_inside_with_ = false; | 163 scope_inside_with_ = false; |
165 scope_contains_with_ = false; | 164 scope_contains_with_ = false; |
(...skipping 16 matching lines...) Expand all Loading... |
182 num_modules_ = 0; | 181 num_modules_ = 0; |
183 module_var_ = NULL, | 182 module_var_ = NULL, |
184 rest_parameter_ = NULL; | 183 rest_parameter_ = NULL; |
185 rest_index_ = -1; | 184 rest_index_ = -1; |
186 scope_info_ = scope_info; | 185 scope_info_ = scope_info; |
187 start_position_ = RelocInfo::kNoPosition; | 186 start_position_ = RelocInfo::kNoPosition; |
188 end_position_ = RelocInfo::kNoPosition; | 187 end_position_ = RelocInfo::kNoPosition; |
189 if (!scope_info.is_null()) { | 188 if (!scope_info.is_null()) { |
190 scope_calls_eval_ = scope_info->CallsEval(); | 189 scope_calls_eval_ = scope_info->CallsEval(); |
191 language_mode_ = scope_info->language_mode(); | 190 language_mode_ = scope_info->language_mode(); |
192 block_scope_is_class_scope_ = scope_info->block_scope_is_class_scope(); | |
193 function_kind_ = scope_info->function_kind(); | 191 function_kind_ = scope_info->function_kind(); |
194 } | 192 } |
195 } | 193 } |
196 | 194 |
197 | 195 |
198 Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone, | 196 Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone, |
199 Context* context, Scope* script_scope) { | 197 Context* context, Scope* script_scope) { |
200 // Reconstruct the outer scope chain from a closure's context chain. | 198 // Reconstruct the outer scope chain from a closure's context chain. |
201 Scope* current_scope = NULL; | 199 Scope* current_scope = NULL; |
202 Scope* innermost_scope = NULL; | 200 Scope* innermost_scope = NULL; |
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1225 // cases: | 1223 // cases: |
1226 // let A = class { ... } | 1224 // let A = class { ... } |
1227 // It needs to be investigated whether this causes any practical problems. | 1225 // It needs to be investigated whether this causes any practical problems. |
1228 if (!is_function_scope()) return nullptr; | 1226 if (!is_function_scope()) return nullptr; |
1229 if (IsInObjectLiteral(function_kind_)) return nullptr; | 1227 if (IsInObjectLiteral(function_kind_)) return nullptr; |
1230 if (!IsConciseMethod(function_kind_) && !IsConstructor(function_kind_) && | 1228 if (!IsConciseMethod(function_kind_) && !IsConstructor(function_kind_) && |
1231 !IsAccessorFunction(function_kind_)) { | 1229 !IsAccessorFunction(function_kind_)) { |
1232 return nullptr; | 1230 return nullptr; |
1233 } | 1231 } |
1234 DCHECK_NOT_NULL(outer_scope_); | 1232 DCHECK_NOT_NULL(outer_scope_); |
1235 DCHECK(outer_scope_->is_class_scope()); | |
1236 // The class scope contains at most one variable, the class name. | 1233 // The class scope contains at most one variable, the class name. |
1237 DCHECK(outer_scope_->variables_.occupancy() <= 1); | 1234 DCHECK(outer_scope_->variables_.occupancy() <= 1); |
1238 if (outer_scope_->variables_.occupancy() == 0) return nullptr; | 1235 if (outer_scope_->variables_.occupancy() == 0) return nullptr; |
1239 VariableMap::Entry* p = outer_scope_->variables_.Start(); | 1236 VariableMap::Entry* p = outer_scope_->variables_.Start(); |
1240 Variable* var = reinterpret_cast<Variable*>(p->value); | 1237 Variable* var = reinterpret_cast<Variable*>(p->value); |
1241 if (!var->is_class()) return nullptr; | 1238 if (!var->is_class()) return nullptr; |
1242 return var->AsClassVariable(); | 1239 return var->AsClassVariable(); |
1243 } | 1240 } |
1244 | 1241 |
1245 | 1242 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 } | 1557 } |
1561 | 1558 |
1562 | 1559 |
1563 int Scope::ContextLocalCount() const { | 1560 int Scope::ContextLocalCount() const { |
1564 if (num_heap_slots() == 0) return 0; | 1561 if (num_heap_slots() == 0) return 0; |
1565 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1562 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
1566 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); | 1563 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); |
1567 } | 1564 } |
1568 } // namespace internal | 1565 } // namespace internal |
1569 } // namespace v8 | 1566 } // namespace v8 |
OLD | NEW |