Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Side by Side Diff: runtime/vm/scopes.cc

Issue 484933003: Await it! (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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())) {
610 // Don't capture those variables as their scope of use can not be
611 // interrupted by await. In other words: There is no way to reach an await
612 // in between assigning them a value and reading the value, as these are
613 // just internals to pass along exception states.
614 continue;
615 }
616 found = CaptureVariable(VariableAt(i)->name());
617 // Also manually set the variable as captured as CaptureVariable() does not
618 // handle capturing variables on the same scope level.
619 VariableAt(i)->set_is_captured();
620 ASSERT(found);
621 }
622 if (sibling() != NULL) { sibling()->RecursivelyCaptureAllVariables(); }
623 if (child() != NULL) { child()->RecursivelyCaptureAllVariables(); }
624 }
625
626
627
605 RawContextScope* LocalScope::CreateImplicitClosureScope(const Function& func) { 628 RawContextScope* LocalScope::CreateImplicitClosureScope(const Function& func) {
606 static const intptr_t kNumCapturedVars = 1; 629 static const intptr_t kNumCapturedVars = 1;
607 630
608 // Create a ContextScope with space for kNumCapturedVars descriptors. 631 // Create a ContextScope with space for kNumCapturedVars descriptors.
609 const ContextScope& context_scope = 632 const ContextScope& context_scope =
610 ContextScope::Handle(ContextScope::New(kNumCapturedVars)); 633 ContextScope::Handle(ContextScope::New(kNumCapturedVars));
611 634
612 // Create a descriptor for 'this' variable. 635 // Create a descriptor for 'this' variable.
613 context_scope.SetTokenIndexAt(0, func.token_pos()); 636 context_scope.SetTokenIndexAt(0, func.token_pos());
614 context_scope.SetNameAt(0, Symbols::This()); 637 context_scope.SetNameAt(0, Symbols::This());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 return fixed_parameter_count - (index() - kParamEndSlotFromFp); 671 return fixed_parameter_count - (index() - kParamEndSlotFromFp);
649 } else { 672 } else {
650 // Shift negative indexes so that the lowest one is 0 (they are still 673 // Shift negative indexes so that the lowest one is 0 (they are still
651 // non-positive). 674 // non-positive).
652 return fixed_parameter_count - (index() - kFirstLocalSlotFromFp); 675 return fixed_parameter_count - (index() - kFirstLocalSlotFromFp);
653 } 676 }
654 } 677 }
655 678
656 679
657 } // namespace dart 680 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698