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