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