Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/scopes.h" | 5 #include "vm/scopes.h" |
| 6 | 6 |
| 7 #include "vm/object.h" | 7 #include "vm/object.h" |
| 8 #include "vm/stack_frame.h" | 8 #include "vm/stack_frame.h" |
| 9 #include "vm/symbols.h" | 9 #include "vm/symbols.h" |
| 10 | 10 |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 LocalScope* owner_scope = new LocalScope(NULL, 0, 0); | 595 LocalScope* owner_scope = new LocalScope(NULL, 0, 0); |
| 596 owner_scope->set_context_level(context_scope.ContextLevelAt(i)); | 596 owner_scope->set_context_level(context_scope.ContextLevelAt(i)); |
| 597 owner_scope->AddVariable(variable); | 597 owner_scope->AddVariable(variable); |
| 598 outer_scope->AddVariable(variable); // As alias. | 598 outer_scope->AddVariable(variable); // As alias. |
| 599 ASSERT(variable->owner() == owner_scope); | 599 ASSERT(variable->owner() == owner_scope); |
| 600 } | 600 } |
| 601 return outer_scope; | 601 return outer_scope; |
| 602 } | 602 } |
| 603 | 603 |
| 604 | 604 |
| 605 void LocalScope::RecursivelyCaptureAllVariables() { | |
| 606 bool found = false; | |
| 607 for (intptr_t i = 0; i < num_variables(); i++) { | |
| 608 if (VariableAt(i)->name().raw() == Symbols::StackTraceVar().raw() || | |
| 609 VariableAt(i)->name().raw() == Symbols::ExceptionVar().raw()) { | |
|
srdjan
2014/08/20 17:50:06
Please add parentheses.
Michael Lippautz (Google)
2014/08/20 20:56:07
Done.
| |
| 610 // Don't capture those variables as there scope of use can not be | |
|
hausner
2014/08/20 19:47:48
there -> their
I'm not sure what the "scope of us
Michael Lippautz (Google)
2014/08/20 20:56:07
There is no way to interrupt those variable's scop
| |
| 611 // interrupted by await. | |
|
srdjan
2014/08/20 17:50:06
s/there/their/ ?
Michael Lippautz (Google)
2014/08/20 20:56:07
Done.
| |
| 612 continue; | |
| 613 } | |
| 614 found = CaptureVariable(VariableAt(i)->name()); | |
| 615 VariableAt(i)->set_is_captured(); | |
|
hausner
2014/08/20 19:47:48
Why do you need to set the variable as captured ag
Michael Lippautz (Google)
2014/08/20 20:56:07
CaptureVariable() conveniently manages regular cap
hausner
2014/08/20 21:42:52
Maybe a one-liner comment might help a future read
Michael Lippautz (Google)
2014/08/21 16:39:14
Done.
| |
| 616 ASSERT(found); | |
| 617 } | |
| 618 if (sibling() != NULL) { sibling()->RecursivelyCaptureAllVariables(); } | |
| 619 if (child() != NULL) { child()->RecursivelyCaptureAllVariables(); } | |
| 620 } | |
| 621 | |
| 622 | |
| 623 | |
| 605 RawContextScope* LocalScope::CreateImplicitClosureScope(const Function& func) { | 624 RawContextScope* LocalScope::CreateImplicitClosureScope(const Function& func) { |
| 606 static const intptr_t kNumCapturedVars = 1; | 625 static const intptr_t kNumCapturedVars = 1; |
| 607 | 626 |
| 608 // Create a ContextScope with space for kNumCapturedVars descriptors. | 627 // Create a ContextScope with space for kNumCapturedVars descriptors. |
| 609 const ContextScope& context_scope = | 628 const ContextScope& context_scope = |
| 610 ContextScope::Handle(ContextScope::New(kNumCapturedVars)); | 629 ContextScope::Handle(ContextScope::New(kNumCapturedVars)); |
| 611 | 630 |
| 612 // Create a descriptor for 'this' variable. | 631 // Create a descriptor for 'this' variable. |
| 613 context_scope.SetTokenIndexAt(0, func.token_pos()); | 632 context_scope.SetTokenIndexAt(0, func.token_pos()); |
| 614 context_scope.SetNameAt(0, Symbols::This()); | 633 context_scope.SetNameAt(0, Symbols::This()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 648 return fixed_parameter_count - (index() - kParamEndSlotFromFp); | 667 return fixed_parameter_count - (index() - kParamEndSlotFromFp); |
| 649 } else { | 668 } else { |
| 650 // Shift negative indexes so that the lowest one is 0 (they are still | 669 // Shift negative indexes so that the lowest one is 0 (they are still |
| 651 // non-positive). | 670 // non-positive). |
| 652 return fixed_parameter_count - (index() - kFirstLocalSlotFromFp); | 671 return fixed_parameter_count - (index() - kFirstLocalSlotFromFp); |
| 653 } | 672 } |
| 654 } | 673 } |
| 655 | 674 |
| 656 | 675 |
| 657 } // namespace dart | 676 } // namespace dart |
| OLD | NEW |