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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 } | 356 } |
357 } else if (scope_info->scope_type() == SCRIPT_SCOPE) { | 357 } else if (scope_info->scope_type() == SCRIPT_SCOPE) { |
358 // If we reach a script scope, it's the outermost scope. Install the | 358 // If we reach a script scope, it's the outermost scope. Install the |
359 // scope info of this script context onto the existing script scope to | 359 // scope info of this script context onto the existing script scope to |
360 // avoid nesting script scopes. | 360 // avoid nesting script scopes. |
361 if (deserialization_mode == DeserializationMode::kIncludingVariables) { | 361 if (deserialization_mode == DeserializationMode::kIncludingVariables) { |
362 script_scope->SetScriptScopeInfo(handle(scope_info)); | 362 script_scope->SetScriptScopeInfo(handle(scope_info)); |
363 } | 363 } |
364 DCHECK(!scope_info->HasOuterScopeInfo()); | 364 DCHECK(!scope_info->HasOuterScopeInfo()); |
365 break; | 365 break; |
366 } else if (scope_info->scope_type() == FUNCTION_SCOPE || | 366 } else if (scope_info->scope_type() == FUNCTION_SCOPE) { |
367 scope_info->scope_type() == EVAL_SCOPE) { | |
368 // TODO(neis): For an eval scope, we currently create an ordinary function | |
369 // context. This is wrong and needs to be fixed. | |
370 // https://bugs.chromium.org/p/v8/issues/detail?id=5295 | |
371 outer_scope = | 367 outer_scope = |
372 new (zone) DeclarationScope(zone, FUNCTION_SCOPE, handle(scope_info)); | 368 new (zone) DeclarationScope(zone, FUNCTION_SCOPE, handle(scope_info)); |
373 if (scope_info->IsAsmFunction()) | 369 if (scope_info->IsAsmFunction()) |
374 outer_scope->AsDeclarationScope()->set_asm_function(); | 370 outer_scope->AsDeclarationScope()->set_asm_function(); |
375 if (scope_info->IsAsmModule()) | 371 if (scope_info->IsAsmModule()) |
376 outer_scope->AsDeclarationScope()->set_asm_module(); | 372 outer_scope->AsDeclarationScope()->set_asm_module(); |
| 373 } else if (scope_info->scope_type() == EVAL_SCOPE) { |
| 374 outer_scope = |
| 375 new (zone) DeclarationScope(zone, EVAL_SCOPE, handle(scope_info)); |
377 } else if (scope_info->scope_type() == BLOCK_SCOPE) { | 376 } else if (scope_info->scope_type() == BLOCK_SCOPE) { |
378 if (scope_info->is_declaration_scope()) { | 377 if (scope_info->is_declaration_scope()) { |
379 outer_scope = | 378 outer_scope = |
380 new (zone) DeclarationScope(zone, BLOCK_SCOPE, handle(scope_info)); | 379 new (zone) DeclarationScope(zone, BLOCK_SCOPE, handle(scope_info)); |
381 } else { | 380 } else { |
382 outer_scope = new (zone) Scope(zone, BLOCK_SCOPE, handle(scope_info)); | 381 outer_scope = new (zone) Scope(zone, BLOCK_SCOPE, handle(scope_info)); |
383 } | 382 } |
384 } else if (scope_info->scope_type() == MODULE_SCOPE) { | 383 } else if (scope_info->scope_type() == MODULE_SCOPE) { |
385 outer_scope = new (zone) | 384 outer_scope = new (zone) |
386 ModuleScope(isolate, handle(scope_info), ast_value_factory); | 385 ModuleScope(isolate, handle(scope_info), ast_value_factory); |
(...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1972 Variable* function = | 1971 Variable* function = |
1973 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 1972 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
1974 bool is_function_var_in_context = | 1973 bool is_function_var_in_context = |
1975 function != nullptr && function->IsContextSlot(); | 1974 function != nullptr && function->IsContextSlot(); |
1976 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1975 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
1977 (is_function_var_in_context ? 1 : 0); | 1976 (is_function_var_in_context ? 1 : 0); |
1978 } | 1977 } |
1979 | 1978 |
1980 } // namespace internal | 1979 } // namespace internal |
1981 } // namespace v8 | 1980 } // namespace v8 |
OLD | NEW |