| 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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 // same variable if it is declared several times. This is not a | 949 // same variable if it is declared several times. This is not a |
| 950 // semantic issue, but it may be a performance issue since it may | 950 // semantic issue, but it may be a performance issue since it may |
| 951 // lead to repeated DeclareEvalVar or DeclareEvalFunction calls. | 951 // lead to repeated DeclareEvalVar or DeclareEvalFunction calls. |
| 952 decls_.Add(declaration, zone()); | 952 decls_.Add(declaration, zone()); |
| 953 proxy->BindTo(var); | 953 proxy->BindTo(var); |
| 954 return var; | 954 return var; |
| 955 } | 955 } |
| 956 | 956 |
| 957 VariableProxy* Scope::NewUnresolved(AstNodeFactory* factory, | 957 VariableProxy* Scope::NewUnresolved(AstNodeFactory* factory, |
| 958 const AstRawString* name, | 958 const AstRawString* name, |
| 959 int start_position, int end_position, | 959 int start_position, VariableKind kind) { |
| 960 VariableKind kind) { | |
| 961 // Note that we must not share the unresolved variables with | 960 // Note that we must not share the unresolved variables with |
| 962 // the same name because they may be removed selectively via | 961 // the same name because they may be removed selectively via |
| 963 // RemoveUnresolved(). | 962 // RemoveUnresolved(). |
| 964 DCHECK(!already_resolved_); | 963 DCHECK(!already_resolved_); |
| 965 DCHECK_EQ(!needs_migration_, factory->zone() == zone()); | 964 DCHECK_EQ(!needs_migration_, factory->zone() == zone()); |
| 966 VariableProxy* proxy = | 965 VariableProxy* proxy = factory->NewVariableProxy(name, kind, start_position); |
| 967 factory->NewVariableProxy(name, kind, start_position, end_position); | |
| 968 proxy->set_next_unresolved(unresolved_); | 966 proxy->set_next_unresolved(unresolved_); |
| 969 unresolved_ = proxy; | 967 unresolved_ = proxy; |
| 970 return proxy; | 968 return proxy; |
| 971 } | 969 } |
| 972 | 970 |
| 973 void Scope::AddUnresolved(VariableProxy* proxy) { | 971 void Scope::AddUnresolved(VariableProxy* proxy) { |
| 974 DCHECK(!already_resolved_); | 972 DCHECK(!already_resolved_); |
| 975 DCHECK(!proxy->is_resolved()); | 973 DCHECK(!proxy->is_resolved()); |
| 976 proxy->set_next_unresolved(unresolved_); | 974 proxy->set_next_unresolved(unresolved_); |
| 977 unresolved_ = proxy; | 975 unresolved_ = proxy; |
| (...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2020 Variable* function = | 2018 Variable* function = |
| 2021 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 2019 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
| 2022 bool is_function_var_in_context = | 2020 bool is_function_var_in_context = |
| 2023 function != nullptr && function->IsContextSlot(); | 2021 function != nullptr && function->IsContextSlot(); |
| 2024 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 2022 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
| 2025 (is_function_var_in_context ? 1 : 0); | 2023 (is_function_var_in_context ? 1 : 0); |
| 2026 } | 2024 } |
| 2027 | 2025 |
| 2028 } // namespace internal | 2026 } // namespace internal |
| 2029 } // namespace v8 | 2027 } // namespace v8 |
| OLD | NEW |