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/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 if (context->IsDebugEvaluateContext()) { | 247 if (context->IsDebugEvaluateContext()) { |
248 with_scope->set_is_debug_evaluate_scope(); | 248 with_scope->set_is_debug_evaluate_scope(); |
249 } | 249 } |
250 current_scope = with_scope; | 250 current_scope = with_scope; |
251 // All the inner scopes are inside a with. | 251 // All the inner scopes are inside a with. |
252 for (Scope* s = innermost_scope; s != nullptr; s = s->outer_scope()) { | 252 for (Scope* s = innermost_scope; s != nullptr; s = s->outer_scope()) { |
253 s->scope_inside_with_ = true; | 253 s->scope_inside_with_ = true; |
254 } | 254 } |
255 } else if (context->IsScriptContext()) { | 255 } else if (context->IsScriptContext()) { |
256 Handle<ScopeInfo> scope_info(context->scope_info(), isolate); | 256 Handle<ScopeInfo> scope_info(context->scope_info(), isolate); |
257 DCHECK(scope_info->scope_type() == SCRIPT_SCOPE); | |
Toon Verwaest
2016/08/19 12:48:52
DCHECK_EQ
| |
257 current_scope = new (zone) | 258 current_scope = new (zone) |
258 DeclarationScope(zone, current_scope, SCRIPT_SCOPE, scope_info); | 259 DeclarationScope(zone, current_scope, SCRIPT_SCOPE, scope_info); |
259 } else if (context->IsFunctionContext()) { | 260 } else if (context->IsFunctionContext()) { |
260 Handle<ScopeInfo> scope_info(context->closure()->shared()->scope_info(), | 261 Handle<ScopeInfo> scope_info(context->closure()->shared()->scope_info(), |
261 isolate); | 262 isolate); |
263 // TODO(neis): For an eval scope, we currently create an ordinary function | |
264 // context. This is wrong and needs to be fixed. | |
265 // https://bugs.chromium.org/p/v8/issues/detail?id=5295 | |
266 DCHECK(scope_info->scope_type() == FUNCTION_SCOPE || | |
267 scope_info->scope_type() == EVAL_SCOPE); | |
262 current_scope = new (zone) | 268 current_scope = new (zone) |
263 DeclarationScope(zone, current_scope, FUNCTION_SCOPE, scope_info); | 269 DeclarationScope(zone, current_scope, FUNCTION_SCOPE, scope_info); |
264 if (scope_info->IsAsmFunction()) current_scope->asm_function_ = true; | 270 if (scope_info->IsAsmFunction()) current_scope->asm_function_ = true; |
265 if (scope_info->IsAsmModule()) current_scope->asm_module_ = true; | 271 if (scope_info->IsAsmModule()) current_scope->asm_module_ = true; |
266 } else if (context->IsBlockContext()) { | 272 } else if (context->IsBlockContext()) { |
267 Handle<ScopeInfo> scope_info(context->scope_info(), isolate); | 273 Handle<ScopeInfo> scope_info(context->scope_info(), isolate); |
274 DCHECK(scope_info->scope_type() == BLOCK_SCOPE); | |
Toon Verwaest
2016/08/19 12:48:52
DCHECK_EQ
| |
268 if (scope_info->is_declaration_scope()) { | 275 if (scope_info->is_declaration_scope()) { |
269 current_scope = new (zone) | 276 current_scope = new (zone) |
270 DeclarationScope(zone, current_scope, BLOCK_SCOPE, scope_info); | 277 DeclarationScope(zone, current_scope, BLOCK_SCOPE, scope_info); |
271 } else { | 278 } else { |
272 current_scope = | 279 current_scope = |
273 new (zone) Scope(zone, current_scope, BLOCK_SCOPE, scope_info); | 280 new (zone) Scope(zone, current_scope, BLOCK_SCOPE, scope_info); |
274 } | 281 } |
275 } else { | 282 } else { |
276 DCHECK(context->IsCatchContext()); | 283 DCHECK(context->IsCatchContext()); |
277 String* name = context->catch_name(); | 284 String* name = context->catch_name(); |
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1778 function != nullptr && function->IsContextSlot(); | 1785 function != nullptr && function->IsContextSlot(); |
1779 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - | 1786 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - |
1780 (is_function_var_in_context ? 1 : 0); | 1787 (is_function_var_in_context ? 1 : 0); |
1781 } | 1788 } |
1782 | 1789 |
1783 | 1790 |
1784 int Scope::ContextGlobalCount() const { return num_global_slots(); } | 1791 int Scope::ContextGlobalCount() const { return num_global_slots(); } |
1785 | 1792 |
1786 } // namespace internal | 1793 } // namespace internal |
1787 } // namespace v8 | 1794 } // namespace v8 |
OLD | NEW |