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. | |
Toon Verwaest
2016/09/20 11:05:00
Add TODO(yangguo/jochen) to remove this requiremen
jochen (gone - plz use gerrit)
2016/09/20 11:13:17
done (also added to NeedsScopeInfo())
| |
1052 if (scope_info_.is_null()) { | |
1053 scope_info_ = ScopeInfo::Create(info->isolate(), zone(), this, outer_scope); | |
1054 } | |
1049 } | 1055 } |
1050 | 1056 |
1051 bool Scope::AllowsLazyParsing() const { | 1057 bool Scope::AllowsLazyParsing() const { |
1052 // If we are inside a block scope, we must parse eagerly to find out how | 1058 // 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 | 1059 // to allocate variables on the block scope. At this point, declarations may |
1054 // not have yet been parsed. | 1060 // not have yet been parsed. |
1055 for (const Scope* s = this; s != nullptr; s = s->outer_scope_) { | 1061 for (const Scope* s = this; s != nullptr; s = s->outer_scope_) { |
1056 if (s->is_block_scope()) return false; | 1062 if (s->is_block_scope()) return false; |
1057 } | 1063 } |
1058 return true; | 1064 return true; |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1806 Variable* function = | 1812 Variable* function = |
1807 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 1813 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
1808 bool is_function_var_in_context = | 1814 bool is_function_var_in_context = |
1809 function != nullptr && function->IsContextSlot(); | 1815 function != nullptr && function->IsContextSlot(); |
1810 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1816 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
1811 (is_function_var_in_context ? 1 : 0); | 1817 (is_function_var_in_context ? 1 : 0); |
1812 } | 1818 } |
1813 | 1819 |
1814 } // namespace internal | 1820 } // namespace internal |
1815 } // namespace v8 | 1821 } // namespace v8 |
OLD | NEW |