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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 } | 369 } |
370 } else if (scope_info->scope_type() == SCRIPT_SCOPE) { | 370 } else if (scope_info->scope_type() == SCRIPT_SCOPE) { |
371 // If we reach a script scope, it's the outermost scope. Install the | 371 // If we reach a script scope, it's the outermost scope. Install the |
372 // scope info of this script context onto the existing script scope to | 372 // scope info of this script context onto the existing script scope to |
373 // avoid nesting script scopes. | 373 // avoid nesting script scopes. |
374 if (deserialization_mode == DeserializationMode::kIncludingVariables) { | 374 if (deserialization_mode == DeserializationMode::kIncludingVariables) { |
375 script_scope->SetScriptScopeInfo(handle(scope_info)); | 375 script_scope->SetScriptScopeInfo(handle(scope_info)); |
376 } | 376 } |
377 DCHECK(!scope_info->HasOuterScopeInfo()); | 377 DCHECK(!scope_info->HasOuterScopeInfo()); |
378 break; | 378 break; |
379 } else if (scope_info->scope_type() == FUNCTION_SCOPE || | 379 } else if (scope_info->scope_type() == FUNCTION_SCOPE) { |
380 scope_info->scope_type() == EVAL_SCOPE) { | |
381 // TODO(neis): For an eval scope, we currently create an ordinary function | |
382 // context. This is wrong and needs to be fixed. | |
383 // https://bugs.chromium.org/p/v8/issues/detail?id=5295 | |
384 outer_scope = | 380 outer_scope = |
385 new (zone) DeclarationScope(zone, FUNCTION_SCOPE, handle(scope_info)); | 381 new (zone) DeclarationScope(zone, FUNCTION_SCOPE, handle(scope_info)); |
386 if (scope_info->IsAsmFunction()) | 382 if (scope_info->IsAsmFunction()) |
387 outer_scope->AsDeclarationScope()->set_asm_function(); | 383 outer_scope->AsDeclarationScope()->set_asm_function(); |
388 if (scope_info->IsAsmModule()) | 384 if (scope_info->IsAsmModule()) |
389 outer_scope->AsDeclarationScope()->set_asm_module(); | 385 outer_scope->AsDeclarationScope()->set_asm_module(); |
| 386 } else if (scope_info->scope_type() == EVAL_SCOPE) { |
| 387 outer_scope = |
| 388 new (zone) DeclarationScope(zone, EVAL_SCOPE, handle(scope_info)); |
390 } else if (scope_info->scope_type() == BLOCK_SCOPE) { | 389 } else if (scope_info->scope_type() == BLOCK_SCOPE) { |
391 if (scope_info->is_declaration_scope()) { | 390 if (scope_info->is_declaration_scope()) { |
392 outer_scope = | 391 outer_scope = |
393 new (zone) DeclarationScope(zone, BLOCK_SCOPE, handle(scope_info)); | 392 new (zone) DeclarationScope(zone, BLOCK_SCOPE, handle(scope_info)); |
394 } else { | 393 } else { |
395 outer_scope = new (zone) Scope(zone, BLOCK_SCOPE, handle(scope_info)); | 394 outer_scope = new (zone) Scope(zone, BLOCK_SCOPE, handle(scope_info)); |
396 } | 395 } |
397 } else if (scope_info->scope_type() == MODULE_SCOPE) { | 396 } else if (scope_info->scope_type() == MODULE_SCOPE) { |
398 outer_scope = new (zone) | 397 outer_scope = new (zone) |
399 ModuleScope(isolate, handle(scope_info), ast_value_factory); | 398 ModuleScope(isolate, handle(scope_info), ast_value_factory); |
(...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2123 Variable* function = | 2122 Variable* function = |
2124 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 2123 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
2125 bool is_function_var_in_context = | 2124 bool is_function_var_in_context = |
2126 function != nullptr && function->IsContextSlot(); | 2125 function != nullptr && function->IsContextSlot(); |
2127 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 2126 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
2128 (is_function_var_in_context ? 1 : 0); | 2127 (is_function_var_in_context ? 1 : 0); |
2129 } | 2128 } |
2130 | 2129 |
2131 } // namespace internal | 2130 } // namespace internal |
2132 } // namespace v8 | 2131 } // namespace v8 |
OLD | NEW |