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 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 ResolveVariablesRecursively(info); | 1039 ResolveVariablesRecursively(info); |
1040 AllocateVariablesRecursively(); | 1040 AllocateVariablesRecursively(); |
1041 | 1041 |
1042 MaybeHandle<ScopeInfo> outer_scope; | 1042 MaybeHandle<ScopeInfo> outer_scope; |
1043 for (const Scope* s = outer_scope_; s != nullptr; s = s->outer_scope_) { | 1043 for (const Scope* s = outer_scope_; s != nullptr; s = s->outer_scope_) { |
1044 if (s->scope_info_.is_null()) continue; | 1044 if (s->scope_info_.is_null()) continue; |
1045 outer_scope = s->scope_info_; | 1045 outer_scope = s->scope_info_; |
1046 break; | 1046 break; |
1047 } | 1047 } |
1048 AllocateScopeInfosRecursively(info->isolate(), mode, outer_scope); | 1048 AllocateScopeInfosRecursively(info->isolate(), mode, outer_scope); |
| 1049 // The debugger expects all shared function infos to contain a scope info. |
| 1050 // Since the top-most scope will end up in a shared function info, make sure |
| 1051 // it has one, even if it doesn't need a scope info. |
| 1052 // TODO(jochen|yangguo): Remove this requirement. |
| 1053 if (scope_info_.is_null()) { |
| 1054 scope_info_ = ScopeInfo::Create(info->isolate(), zone(), this, outer_scope); |
| 1055 } |
1049 } | 1056 } |
1050 | 1057 |
1051 bool Scope::AllowsLazyParsing() const { | 1058 bool Scope::AllowsLazyParsing() const { |
1052 // If we are inside a block scope, we must parse eagerly to find out how | 1059 // If we are inside a block scope, we must parse eagerly to find out how |
1053 // to allocate variables on the block scope. At this point, declarations may | 1060 // to allocate variables on the block scope. At this point, declarations may |
1054 // not have yet been parsed. | 1061 // not have yet been parsed. |
1055 for (const Scope* s = this; s != nullptr; s = s->outer_scope_) { | 1062 for (const Scope* s = this; s != nullptr; s = s->outer_scope_) { |
1056 if (s->is_block_scope()) return false; | 1063 if (s->is_block_scope()) return false; |
1057 } | 1064 } |
1058 return true; | 1065 return true; |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 Variable* function = | 1813 Variable* function = |
1807 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 1814 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
1808 bool is_function_var_in_context = | 1815 bool is_function_var_in_context = |
1809 function != nullptr && function->IsContextSlot(); | 1816 function != nullptr && function->IsContextSlot(); |
1810 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1817 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
1811 (is_function_var_in_context ? 1 : 0); | 1818 (is_function_var_in_context ? 1 : 0); |
1812 } | 1819 } |
1813 | 1820 |
1814 } // namespace internal | 1821 } // namespace internal |
1815 } // namespace v8 | 1822 } // namespace v8 |
OLD | NEW |