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 "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/ast/scopeinfo.h" | 8 #include "src/ast/scopeinfo.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 unresolved_ = nullptr; | 173 unresolved_ = nullptr; |
174 scope_name_ = nullptr; | 174 scope_name_ = nullptr; |
175 dynamics_ = nullptr; | 175 dynamics_ = nullptr; |
176 receiver_ = nullptr; | 176 receiver_ = nullptr; |
177 new_target_ = nullptr; | 177 new_target_ = nullptr; |
178 function_ = nullptr; | 178 function_ = nullptr; |
179 arguments_ = nullptr; | 179 arguments_ = nullptr; |
180 this_function_ = nullptr; | 180 this_function_ = nullptr; |
181 scope_inside_with_ = false; | 181 scope_inside_with_ = false; |
182 scope_calls_eval_ = false; | 182 scope_calls_eval_ = false; |
183 scope_uses_arguments_ = false; | |
184 has_arguments_parameter_ = false; | 183 has_arguments_parameter_ = false; |
185 scope_uses_super_property_ = false; | 184 scope_uses_super_property_ = false; |
186 asm_module_ = false; | 185 asm_module_ = false; |
187 asm_function_ = false; | 186 asm_function_ = false; |
188 language_mode_ = is_module_scope() ? STRICT : SLOPPY; | 187 language_mode_ = is_module_scope() ? STRICT : SLOPPY; |
189 outer_scope_calls_sloppy_eval_ = false; | 188 outer_scope_calls_sloppy_eval_ = false; |
190 inner_scope_calls_eval_ = false; | 189 inner_scope_calls_eval_ = false; |
191 scope_nonlinear_ = false; | 190 scope_nonlinear_ = false; |
192 force_eager_compilation_ = false; | 191 force_eager_compilation_ = false; |
193 force_context_allocation_ = false; | 192 force_context_allocation_ = false; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 outer_scope_->RemoveInnerScope(this); | 376 outer_scope_->RemoveInnerScope(this); |
378 outer->AddInnerScope(this); | 377 outer->AddInnerScope(this); |
379 outer_scope_ = outer; | 378 outer_scope_ = outer; |
380 } | 379 } |
381 | 380 |
382 | 381 |
383 void Scope::PropagateUsageFlagsToScope(Scope* other) { | 382 void Scope::PropagateUsageFlagsToScope(Scope* other) { |
384 DCHECK_NOT_NULL(other); | 383 DCHECK_NOT_NULL(other); |
385 DCHECK(!already_resolved()); | 384 DCHECK(!already_resolved()); |
386 DCHECK(!other->already_resolved()); | 385 DCHECK(!other->already_resolved()); |
387 if (uses_arguments()) other->RecordArgumentsUsage(); | |
388 if (uses_super_property()) other->RecordSuperPropertyUsage(); | 386 if (uses_super_property()) other->RecordSuperPropertyUsage(); |
389 if (calls_eval()) other->RecordEvalCall(); | 387 if (calls_eval()) other->RecordEvalCall(); |
390 } | 388 } |
391 | 389 |
392 | 390 |
393 Variable* Scope::LookupLocal(const AstRawString* name) { | 391 Variable* Scope::LookupLocal(const AstRawString* name) { |
394 Variable* result = variables_.Lookup(name); | 392 Variable* result = variables_.Lookup(name); |
395 if (result != NULL || scope_info_.is_null()) { | 393 if (result != NULL || scope_info_.is_null()) { |
396 return result; | 394 return result; |
397 } | 395 } |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 if (HasTrivialOuterContext()) { | 976 if (HasTrivialOuterContext()) { |
979 Indent(n1, "// scope has trivial outer context\n"); | 977 Indent(n1, "// scope has trivial outer context\n"); |
980 } | 978 } |
981 if (is_strict(language_mode())) { | 979 if (is_strict(language_mode())) { |
982 Indent(n1, "// strict mode scope\n"); | 980 Indent(n1, "// strict mode scope\n"); |
983 } | 981 } |
984 if (asm_module_) Indent(n1, "// scope is an asm module\n"); | 982 if (asm_module_) Indent(n1, "// scope is an asm module\n"); |
985 if (asm_function_) Indent(n1, "// scope is an asm function\n"); | 983 if (asm_function_) Indent(n1, "// scope is an asm function\n"); |
986 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); | 984 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); |
987 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); | 985 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); |
988 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n"); | |
989 if (scope_uses_super_property_) | 986 if (scope_uses_super_property_) |
990 Indent(n1, "// scope uses 'super' property\n"); | 987 Indent(n1, "// scope uses 'super' property\n"); |
991 if (outer_scope_calls_sloppy_eval_) { | 988 if (outer_scope_calls_sloppy_eval_) { |
992 Indent(n1, "// outer scope calls 'eval' in sloppy context\n"); | 989 Indent(n1, "// outer scope calls 'eval' in sloppy context\n"); |
993 } | 990 } |
994 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); | 991 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); |
995 if (num_stack_slots_ > 0) { | 992 if (num_stack_slots_ > 0) { |
996 Indent(n1, "// "); | 993 Indent(n1, "// "); |
997 PrintF("%d stack slots\n", num_stack_slots_); | 994 PrintF("%d stack slots\n", num_stack_slots_); |
998 } | 995 } |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1535 function_ != NULL && function_->proxy()->var()->IsContextSlot(); | 1532 function_ != NULL && function_->proxy()->var()->IsContextSlot(); |
1536 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - | 1533 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - |
1537 (is_function_var_in_context ? 1 : 0); | 1534 (is_function_var_in_context ? 1 : 0); |
1538 } | 1535 } |
1539 | 1536 |
1540 | 1537 |
1541 int Scope::ContextGlobalCount() const { return num_global_slots(); } | 1538 int Scope::ContextGlobalCount() const { return num_global_slots(); } |
1542 | 1539 |
1543 } // namespace internal | 1540 } // namespace internal |
1544 } // namespace v8 | 1541 } // namespace v8 |
OLD | NEW |