| 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/ast/scopes.h" | 5 #include "src/ast/scopes.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
| 10 #include "src/ast/ast.h" | 10 #include "src/ast/ast.h" |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 variables_.Add(zone(), function_); | 701 variables_.Add(zone(), function_); |
| 702 } | 702 } |
| 703 return function_; | 703 return function_; |
| 704 } | 704 } |
| 705 | 705 |
| 706 Variable* DeclarationScope::DeclareGeneratorObjectVar( | 706 Variable* DeclarationScope::DeclareGeneratorObjectVar( |
| 707 const AstRawString* name) { | 707 const AstRawString* name) { |
| 708 DCHECK(is_function_scope() || is_module_scope()); | 708 DCHECK(is_function_scope() || is_module_scope()); |
| 709 DCHECK_NULL(generator_object_var()); | 709 DCHECK_NULL(generator_object_var()); |
| 710 | 710 |
| 711 Variable* result = EnsureRareData()->generator_object = NewTemporary(name); | 711 Variable* result = EnsureRareData()->generator_object = |
| 712 NewTemporary(name, kNotAssigned); |
| 712 result->set_is_used(); | 713 result->set_is_used(); |
| 713 return result; | 714 return result; |
| 714 } | 715 } |
| 715 | 716 |
| 716 Variable* DeclarationScope::DeclarePromiseVar(const AstRawString* name) { | 717 Variable* DeclarationScope::DeclarePromiseVar(const AstRawString* name) { |
| 717 DCHECK(is_function_scope()); | 718 DCHECK(is_function_scope()); |
| 718 DCHECK_NULL(promise_var()); | 719 DCHECK_NULL(promise_var()); |
| 719 Variable* result = EnsureRareData()->promise = NewTemporary(name); | 720 Variable* result = EnsureRareData()->promise = NewTemporary(name); |
| 720 result->set_is_used(); | 721 result->set_is_used(); |
| 721 return result; | 722 return result; |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 if (var == next) { | 1198 if (var == next) { |
| 1198 current->set_next_unresolved(next->next_unresolved()); | 1199 current->set_next_unresolved(next->next_unresolved()); |
| 1199 var->set_next_unresolved(nullptr); | 1200 var->set_next_unresolved(nullptr); |
| 1200 return true; | 1201 return true; |
| 1201 } | 1202 } |
| 1202 current = next; | 1203 current = next; |
| 1203 } | 1204 } |
| 1204 return false; | 1205 return false; |
| 1205 } | 1206 } |
| 1206 | 1207 |
| 1207 Variable* Scope::NewTemporary(const AstRawString* name) { | 1208 Variable* Scope::NewTemporary(const AstRawString* name, |
| 1209 MaybeAssignedFlag maybe_assigned) { |
| 1208 DeclarationScope* scope = GetClosureScope(); | 1210 DeclarationScope* scope = GetClosureScope(); |
| 1209 Variable* var = new (zone()) | 1211 Variable* var = new (zone()) |
| 1210 Variable(scope, name, TEMPORARY, NORMAL_VARIABLE, kCreatedInitialized); | 1212 Variable(scope, name, TEMPORARY, NORMAL_VARIABLE, kCreatedInitialized); |
| 1211 scope->AddLocal(var); | 1213 scope->AddLocal(var); |
| 1214 if (maybe_assigned == kMaybeAssigned) var->set_maybe_assigned(); |
| 1212 return var; | 1215 return var; |
| 1213 } | 1216 } |
| 1214 | 1217 |
| 1215 Declaration* Scope::CheckConflictingVarDeclarations() { | 1218 Declaration* Scope::CheckConflictingVarDeclarations() { |
| 1216 for (Declaration* decl : decls_) { | 1219 for (Declaration* decl : decls_) { |
| 1217 VariableMode mode = decl->proxy()->var()->mode(); | 1220 VariableMode mode = decl->proxy()->var()->mode(); |
| 1218 if (IsLexicalVariableMode(mode) && !is_block_scope()) continue; | 1221 if (IsLexicalVariableMode(mode) && !is_block_scope()) continue; |
| 1219 | 1222 |
| 1220 // Iterate through all scopes until and including the declaration scope. | 1223 // Iterate through all scopes until and including the declaration scope. |
| 1221 Scope* previous = NULL; | 1224 Scope* previous = NULL; |
| (...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2282 Variable* function = | 2285 Variable* function = |
| 2283 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 2286 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
| 2284 bool is_function_var_in_context = | 2287 bool is_function_var_in_context = |
| 2285 function != nullptr && function->IsContextSlot(); | 2288 function != nullptr && function->IsContextSlot(); |
| 2286 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 2289 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
| 2287 (is_function_var_in_context ? 1 : 0); | 2290 (is_function_var_in_context ? 1 : 0); |
| 2288 } | 2291 } |
| 2289 | 2292 |
| 2290 } // namespace internal | 2293 } // namespace internal |
| 2291 } // namespace v8 | 2294 } // namespace v8 |
| OLD | NEW |