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 "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/ast/scopeinfo.h" | 8 #include "src/ast/scopeinfo.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } | 201 } |
202 } | 202 } |
203 | 203 |
204 | 204 |
205 Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone, | 205 Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone, |
206 Context* context, Scope* script_scope) { | 206 Context* context, Scope* script_scope) { |
207 // Reconstruct the outer scope chain from a closure's context chain. | 207 // Reconstruct the outer scope chain from a closure's context chain. |
208 Scope* current_scope = NULL; | 208 Scope* current_scope = NULL; |
209 Scope* innermost_scope = NULL; | 209 Scope* innermost_scope = NULL; |
210 while (!context->IsNativeContext()) { | 210 while (!context->IsNativeContext()) { |
211 if (context->IsWithContext()) { | 211 if (context->IsWithContext() || context->IsDebugEvaluateContext()) { |
| 212 // For scope analysis, debug-evaluate is equivalent to a with scope. |
212 Scope* with_scope = new (zone) | 213 Scope* with_scope = new (zone) |
213 Scope(zone, current_scope, WITH_SCOPE, Handle<ScopeInfo>::null(), | 214 Scope(zone, current_scope, WITH_SCOPE, Handle<ScopeInfo>::null(), |
214 script_scope->ast_value_factory_); | 215 script_scope->ast_value_factory_); |
215 current_scope = with_scope; | 216 current_scope = with_scope; |
216 // All the inner scopes are inside a with. | 217 // All the inner scopes are inside a with. |
217 for (Scope* s = innermost_scope; s != NULL; s = s->outer_scope()) { | 218 for (Scope* s = innermost_scope; s != NULL; s = s->outer_scope()) { |
218 s->scope_inside_with_ = true; | 219 s->scope_inside_with_ = true; |
219 } | 220 } |
220 } else if (context->IsScriptContext()) { | 221 } else if (context->IsScriptContext()) { |
221 ScopeInfo* scope_info = context->scope_info(); | 222 ScopeInfo* scope_info = context->scope_info(); |
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1500 function_ != NULL && function_->proxy()->var()->IsContextSlot(); | 1501 function_ != NULL && function_->proxy()->var()->IsContextSlot(); |
1501 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - | 1502 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - |
1502 (is_function_var_in_context ? 1 : 0); | 1503 (is_function_var_in_context ? 1 : 0); |
1503 } | 1504 } |
1504 | 1505 |
1505 | 1506 |
1506 int Scope::ContextGlobalCount() const { return num_global_slots(); } | 1507 int Scope::ContextGlobalCount() const { return num_global_slots(); } |
1507 | 1508 |
1508 } // namespace internal | 1509 } // namespace internal |
1509 } // namespace v8 | 1510 } // namespace v8 |
OLD | NEW |