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/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 variables_(zone), | 81 variables_(zone), |
82 decls_(4, zone), | 82 decls_(4, zone), |
83 scope_type_(scope_type) { | 83 scope_type_(scope_type) { |
84 SetDefaults(); | 84 SetDefaults(); |
85 if (outer_scope == nullptr) { | 85 if (outer_scope == nullptr) { |
86 // If the outer scope is null, this cannot be a with scope. The outermost | 86 // If the outer scope is null, this cannot be a with scope. The outermost |
87 // scope must be a script scope. | 87 // scope must be a script scope. |
88 DCHECK_EQ(SCRIPT_SCOPE, scope_type); | 88 DCHECK_EQ(SCRIPT_SCOPE, scope_type); |
89 } else { | 89 } else { |
90 asm_function_ = outer_scope_->asm_module_; | 90 asm_function_ = outer_scope_->asm_module_; |
91 language_mode_ = outer_scope->language_mode_; | 91 set_language_mode(outer_scope->language_mode()); |
92 force_context_allocation_ = | 92 force_context_allocation_ = |
93 !is_function_scope() && outer_scope->has_forced_context_allocation(); | 93 !is_function_scope() && outer_scope->has_forced_context_allocation(); |
94 outer_scope_->AddInnerScope(this); | 94 outer_scope_->AddInnerScope(this); |
95 scope_inside_with_ = outer_scope_->scope_inside_with_ || is_with_scope(); | 95 scope_inside_with_ = outer_scope_->scope_inside_with_ || is_with_scope(); |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 Scope::Snapshot::Snapshot(Scope* scope) | 99 Scope::Snapshot::Snapshot(Scope* scope) |
100 : outer_scope_(scope), | 100 : outer_scope_(scope), |
101 top_inner_scope_(scope->inner_scope_), | 101 top_inner_scope_(scope->inner_scope_), |
(...skipping 28 matching lines...) Expand all Loading... |
130 scope_info_(scope_info), | 130 scope_info_(scope_info), |
131 scope_type_(scope_type) { | 131 scope_type_(scope_type) { |
132 SetDefaults(); | 132 SetDefaults(); |
133 #ifdef DEBUG | 133 #ifdef DEBUG |
134 already_resolved_ = true; | 134 already_resolved_ = true; |
135 #endif | 135 #endif |
136 if (scope_type == WITH_SCOPE) { | 136 if (scope_type == WITH_SCOPE) { |
137 DCHECK(scope_info.is_null()); | 137 DCHECK(scope_info.is_null()); |
138 } else { | 138 } else { |
139 scope_calls_eval_ = scope_info->CallsEval(); | 139 scope_calls_eval_ = scope_info->CallsEval(); |
140 language_mode_ = scope_info->language_mode(); | 140 set_language_mode(scope_info->language_mode()); |
141 num_heap_slots_ = scope_info->ContextLength(); | 141 num_heap_slots_ = scope_info->ContextLength(); |
142 } | 142 } |
143 DCHECK_LE(Context::MIN_CONTEXT_SLOTS, num_heap_slots_); | 143 DCHECK_LE(Context::MIN_CONTEXT_SLOTS, num_heap_slots_); |
144 | 144 |
145 if (inner_scope != nullptr) AddInnerScope(inner_scope); | 145 if (inner_scope != nullptr) AddInnerScope(inner_scope); |
146 } | 146 } |
147 | 147 |
148 DeclarationScope::DeclarationScope(Zone* zone, Scope* inner_scope, | 148 DeclarationScope::DeclarationScope(Zone* zone, Scope* inner_scope, |
149 ScopeType scope_type, | 149 ScopeType scope_type, |
150 Handle<ScopeInfo> scope_info) | 150 Handle<ScopeInfo> scope_info) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 unresolved_ = nullptr; | 197 unresolved_ = nullptr; |
198 dynamics_ = nullptr; | 198 dynamics_ = nullptr; |
199 | 199 |
200 start_position_ = kNoSourcePosition; | 200 start_position_ = kNoSourcePosition; |
201 end_position_ = kNoSourcePosition; | 201 end_position_ = kNoSourcePosition; |
202 | 202 |
203 num_stack_slots_ = 0; | 203 num_stack_slots_ = 0; |
204 num_heap_slots_ = Context::MIN_CONTEXT_SLOTS; | 204 num_heap_slots_ = Context::MIN_CONTEXT_SLOTS; |
205 num_global_slots_ = 0; | 205 num_global_slots_ = 0; |
206 | 206 |
207 language_mode_ = SLOPPY; | 207 set_language_mode(SLOPPY); |
208 | 208 |
209 scope_inside_with_ = false; | 209 scope_inside_with_ = false; |
210 scope_calls_eval_ = false; | 210 scope_calls_eval_ = false; |
211 scope_uses_super_property_ = false; | 211 scope_uses_super_property_ = false; |
212 has_arguments_parameter_ = false; | 212 has_arguments_parameter_ = false; |
213 asm_module_ = false; | 213 asm_module_ = false; |
214 asm_function_ = false; | 214 asm_function_ = false; |
215 scope_nonlinear_ = false; | 215 scope_nonlinear_ = false; |
216 is_hidden_ = false; | 216 is_hidden_ = false; |
217 is_debug_evaluate_scope_ = false; | 217 is_debug_evaluate_scope_ = false; |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 | 998 |
999 // Push scope data up to migrate_to. Note that migrate_to and this Scope | 999 // Push scope data up to migrate_to. Note that migrate_to and this Scope |
1000 // describe the same Scope, just in different Zones. | 1000 // describe the same Scope, just in different Zones. |
1001 PropagateUsageFlagsToScope(migrate_to); | 1001 PropagateUsageFlagsToScope(migrate_to); |
1002 if (inner_scope_calls_eval_) { | 1002 if (inner_scope_calls_eval_) { |
1003 migrate_to->inner_scope_calls_eval_ = true; | 1003 migrate_to->inner_scope_calls_eval_ = true; |
1004 } | 1004 } |
1005 DCHECK(!force_eager_compilation_); | 1005 DCHECK(!force_eager_compilation_); |
1006 migrate_to->set_start_position(start_position_); | 1006 migrate_to->set_start_position(start_position_); |
1007 migrate_to->set_end_position(end_position_); | 1007 migrate_to->set_end_position(end_position_); |
1008 migrate_to->language_mode_ = language_mode_; | 1008 migrate_to->set_language_mode(language_mode()); |
1009 migrate_to->arity_ = arity_; | 1009 migrate_to->arity_ = arity_; |
1010 migrate_to->force_context_allocation_ = force_context_allocation_; | 1010 migrate_to->force_context_allocation_ = force_context_allocation_; |
1011 outer_scope_->RemoveInnerScope(this); | 1011 outer_scope_->RemoveInnerScope(this); |
1012 DCHECK_EQ(outer_scope_, migrate_to->outer_scope_); | 1012 DCHECK_EQ(outer_scope_, migrate_to->outer_scope_); |
1013 DCHECK_EQ(outer_scope_->zone(), migrate_to->zone()); | 1013 DCHECK_EQ(outer_scope_->zone(), migrate_to->zone()); |
1014 DCHECK_EQ(NeedsHomeObject(), migrate_to->NeedsHomeObject()); | 1014 DCHECK_EQ(NeedsHomeObject(), migrate_to->NeedsHomeObject()); |
1015 DCHECK_EQ(asm_function_, migrate_to->asm_function_); | 1015 DCHECK_EQ(asm_function_, migrate_to->asm_function_); |
1016 DCHECK_EQ(arguments() != nullptr, migrate_to->arguments() != nullptr); | 1016 DCHECK_EQ(arguments() != nullptr, migrate_to->arguments() != nullptr); |
1017 } | 1017 } |
1018 | 1018 |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1778 function != nullptr && function->IsContextSlot(); | 1778 function != nullptr && function->IsContextSlot(); |
1779 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - | 1779 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - |
1780 (is_function_var_in_context ? 1 : 0); | 1780 (is_function_var_in_context ? 1 : 0); |
1781 } | 1781 } |
1782 | 1782 |
1783 | 1783 |
1784 int Scope::ContextGlobalCount() const { return num_global_slots(); } | 1784 int Scope::ContextGlobalCount() const { return num_global_slots(); } |
1785 | 1785 |
1786 } // namespace internal | 1786 } // namespace internal |
1787 } // namespace v8 | 1787 } // namespace v8 |
OLD | NEW |