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 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 if (var == next) { | 1090 if (var == next) { |
1091 current->set_next_unresolved(next->next_unresolved()); | 1091 current->set_next_unresolved(next->next_unresolved()); |
1092 var->set_next_unresolved(nullptr); | 1092 var->set_next_unresolved(nullptr); |
1093 return true; | 1093 return true; |
1094 } | 1094 } |
1095 current = next; | 1095 current = next; |
1096 } | 1096 } |
1097 return false; | 1097 return false; |
1098 } | 1098 } |
1099 | 1099 |
1100 bool Scope::RemoveUnresolved(const AstRawString* name) { | |
1101 if (unresolved_ != nullptr && unresolved_->raw_name() == name) { | |
1102 VariableProxy* removed = unresolved_; | |
1103 unresolved_ = unresolved_->next_unresolved(); | |
1104 removed->set_next_unresolved(nullptr); | |
1105 return true; | |
1106 } | |
1107 VariableProxy* current = unresolved_; | |
1108 while (current != nullptr) { | |
1109 VariableProxy* next = current->next_unresolved(); | |
1110 if (next != nullptr && next->raw_name() == name) { | |
1111 current->set_next_unresolved(next->next_unresolved()); | |
1112 next->set_next_unresolved(nullptr); | |
1113 return true; | |
1114 } | |
1115 current = next; | |
1116 } | |
1117 return false; | |
1118 } | |
1119 | |
1120 Variable* Scope::NewTemporary(const AstRawString* name) { | 1100 Variable* Scope::NewTemporary(const AstRawString* name) { |
1121 DeclarationScope* scope = GetClosureScope(); | 1101 DeclarationScope* scope = GetClosureScope(); |
1122 Variable* var = new (zone()) | 1102 Variable* var = new (zone()) |
1123 Variable(scope, name, TEMPORARY, NORMAL_VARIABLE, kCreatedInitialized); | 1103 Variable(scope, name, TEMPORARY, NORMAL_VARIABLE, kCreatedInitialized); |
1124 scope->AddLocal(var); | 1104 scope->AddLocal(var); |
1125 return var; | 1105 return var; |
1126 } | 1106 } |
1127 | 1107 |
1128 Declaration* Scope::CheckConflictingVarDeclarations() { | 1108 Declaration* Scope::CheckConflictingVarDeclarations() { |
1129 for (Declaration* decl : decls_) { | 1109 for (Declaration* decl : decls_) { |
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2121 Variable* function = | 2101 Variable* function = |
2122 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 2102 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
2123 bool is_function_var_in_context = | 2103 bool is_function_var_in_context = |
2124 function != nullptr && function->IsContextSlot(); | 2104 function != nullptr && function->IsContextSlot(); |
2125 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 2105 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
2126 (is_function_var_in_context ? 1 : 0); | 2106 (is_function_var_in_context ? 1 : 0); |
2127 } | 2107 } |
2128 | 2108 |
2129 } // namespace internal | 2109 } // namespace internal |
2130 } // namespace v8 | 2110 } // namespace v8 |
OLD | NEW |