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 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 DCHECK_EQ(var->mode(), VAR); | 1227 DCHECK_EQ(var->mode(), VAR); |
1228 var->set_maybe_assigned(); | 1228 var->set_maybe_assigned(); |
1229 } | 1229 } |
1230 var->set_is_used(); | 1230 var->set_is_used(); |
1231 return var; | 1231 return var; |
1232 } else { | 1232 } else { |
1233 return variables_.DeclareName(zone(), name, mode); | 1233 return variables_.DeclareName(zone(), name, mode); |
1234 } | 1234 } |
1235 } | 1235 } |
1236 | 1236 |
1237 VariableProxy* Scope::NewUnresolved(AstNodeFactory* factory, | |
1238 const AstRawString* name, | |
1239 int start_position, VariableKind kind) { | |
1240 // Note that we must not share the unresolved variables with | |
1241 // the same name because they may be removed selectively via | |
1242 // RemoveUnresolved(). | |
1243 DCHECK(!already_resolved_); | |
1244 DCHECK_EQ(factory->zone(), zone()); | |
1245 VariableProxy* proxy = factory->NewVariableProxy(name, kind, start_position); | |
1246 proxy->set_next_unresolved(unresolved_); | |
1247 unresolved_ = proxy; | |
1248 return proxy; | |
1249 } | |
1250 | |
1251 void Scope::AddUnresolved(VariableProxy* proxy) { | 1237 void Scope::AddUnresolved(VariableProxy* proxy) { |
1252 DCHECK(!already_resolved_); | 1238 DCHECK(!already_resolved_); |
1253 DCHECK(!proxy->is_resolved()); | 1239 DCHECK(!proxy->is_resolved()); |
1254 proxy->set_next_unresolved(unresolved_); | 1240 proxy->set_next_unresolved(unresolved_); |
1255 unresolved_ = proxy; | 1241 unresolved_ = proxy; |
1256 } | 1242 } |
1257 | 1243 |
1258 Variable* DeclarationScope::DeclareDynamicGlobal(const AstRawString* name, | 1244 Variable* DeclarationScope::DeclareDynamicGlobal(const AstRawString* name, |
1259 VariableKind kind) { | 1245 VariableKind kind) { |
1260 DCHECK(is_script_scope()); | 1246 DCHECK(is_script_scope()); |
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2368 Variable* function = | 2354 Variable* function = |
2369 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 2355 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
2370 bool is_function_var_in_context = | 2356 bool is_function_var_in_context = |
2371 function != nullptr && function->IsContextSlot(); | 2357 function != nullptr && function->IsContextSlot(); |
2372 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 2358 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
2373 (is_function_var_in_context ? 1 : 0); | 2359 (is_function_var_in_context ? 1 : 0); |
2374 } | 2360 } |
2375 | 2361 |
2376 } // namespace internal | 2362 } // namespace internal |
2377 } // namespace v8 | 2363 } // namespace v8 |
OLD | NEW |