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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 } | 116 } |
117 | 117 |
118 Scope::Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type) | 118 Scope::Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type) |
119 : zone_(zone), | 119 : zone_(zone), |
120 outer_scope_(outer_scope), | 120 outer_scope_(outer_scope), |
121 variables_(zone), | 121 variables_(zone), |
122 scope_type_(scope_type) { | 122 scope_type_(scope_type) { |
123 DCHECK_NE(SCRIPT_SCOPE, scope_type); | 123 DCHECK_NE(SCRIPT_SCOPE, scope_type); |
124 SetDefaults(); | 124 SetDefaults(); |
125 set_language_mode(outer_scope->language_mode()); | 125 set_language_mode(outer_scope->language_mode()); |
126 force_context_allocation_ = | 126 force_context_allocation_ = |
adamk
2016/12/14 08:00:14
Another option would be to add an
if (is_eval_sco
| |
127 !is_function_scope() && outer_scope->has_forced_context_allocation(); | 127 (!is_function_scope() && outer_scope->has_forced_context_allocation()) || |
128 is_eval_scope(); | |
128 outer_scope_->AddInnerScope(this); | 129 outer_scope_->AddInnerScope(this); |
129 } | 130 } |
130 | 131 |
131 Scope::Snapshot::Snapshot(Scope* scope) | 132 Scope::Snapshot::Snapshot(Scope* scope) |
132 : outer_scope_(scope), | 133 : outer_scope_(scope), |
133 top_inner_scope_(scope->inner_scope_), | 134 top_inner_scope_(scope->inner_scope_), |
134 top_unresolved_(scope->unresolved_), | 135 top_unresolved_(scope->unresolved_), |
135 top_local_(scope->GetClosureScope()->locals_.end()), | 136 top_local_(scope->GetClosureScope()->locals_.end()), |
136 top_decl_(scope->GetClosureScope()->decls_.end()) {} | 137 top_decl_(scope->GetClosureScope()->decls_.end()) {} |
137 | 138 |
(...skipping 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2103 Variable* function = | 2104 Variable* function = |
2104 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 2105 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
2105 bool is_function_var_in_context = | 2106 bool is_function_var_in_context = |
2106 function != nullptr && function->IsContextSlot(); | 2107 function != nullptr && function->IsContextSlot(); |
2107 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 2108 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
2108 (is_function_var_in_context ? 1 : 0); | 2109 (is_function_var_in_context ? 1 : 0); |
2109 } | 2110 } |
2110 | 2111 |
2111 } // namespace internal | 2112 } // namespace internal |
2112 } // namespace v8 | 2113 } // namespace v8 |
OLD | NEW |