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 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 | 1038 |
1039 MaybeHandle<ScopeInfo> outer_scope; | 1039 MaybeHandle<ScopeInfo> outer_scope; |
1040 for (const Scope* s = outer_scope_; s != nullptr; s = s->outer_scope_) { | 1040 for (const Scope* s = outer_scope_; s != nullptr; s = s->outer_scope_) { |
1041 if (s->scope_info_.is_null()) continue; | 1041 if (s->scope_info_.is_null()) continue; |
1042 outer_scope = s->scope_info_; | 1042 outer_scope = s->scope_info_; |
1043 break; | 1043 break; |
1044 } | 1044 } |
1045 AllocateScopeInfosRecursively(info->isolate(), mode, outer_scope); | 1045 AllocateScopeInfosRecursively(info->isolate(), mode, outer_scope); |
1046 } | 1046 } |
1047 | 1047 |
1048 bool Scope::AllowsLazyParsingWithoutUnresolvedVariables() const { | 1048 bool Scope::AllowsLazyParsing() const { |
1049 // If we are inside a block scope, we must find unresolved variables in the | 1049 // If we are inside a block scope, we must parse eagerly to find out how |
1050 // inner scopes to find out how to allocate variables on the block scope. At | 1050 // to allocate variables on the block scope. At this point, declarations may |
1051 // this point, declarations may not have yet been parsed. | 1051 // not have yet been parsed. |
1052 for (const Scope* s = this; s != nullptr; s = s->outer_scope_) { | 1052 for (const Scope* s = this; s != nullptr; s = s->outer_scope_) { |
1053 if (s->is_block_scope()) return false; | 1053 if (s->is_block_scope()) return false; |
1054 // TODO(marja): Refactor parsing modes: also add s->is_function_scope() | |
1055 // here. | |
1056 } | 1054 } |
1057 return true; | 1055 return true; |
1058 } | 1056 } |
1059 | 1057 |
1060 bool DeclarationScope::AllowsLazyCompilation() const { | 1058 bool DeclarationScope::AllowsLazyCompilation() const { |
1061 return !force_eager_compilation_; | 1059 return !force_eager_compilation_; |
1062 } | 1060 } |
1063 | 1061 |
1064 bool DeclarationScope::AllowsLazyCompilationWithoutContext() const { | 1062 bool DeclarationScope::AllowsLazyCompilationWithoutContext() const { |
1065 if (force_eager_compilation_) return false; | 1063 if (force_eager_compilation_) return false; |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 Variable* function = | 1811 Variable* function = |
1814 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 1812 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
1815 bool is_function_var_in_context = | 1813 bool is_function_var_in_context = |
1816 function != nullptr && function->IsContextSlot(); | 1814 function != nullptr && function->IsContextSlot(); |
1817 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1815 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
1818 (is_function_var_in_context ? 1 : 0); | 1816 (is_function_var_in_context ? 1 : 0); |
1819 } | 1817 } |
1820 | 1818 |
1821 } // namespace internal | 1819 } // namespace internal |
1822 } // namespace v8 | 1820 } // namespace v8 |
OLD | NEW |