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

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: addressed comments 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 VariableAt(i)->set_is_captured();
618 ASSERT(found);
619 }
620 if (sibling() != NULL) { sibling()->RecursivelyCaptureAllVariables(); }
621 if (child() != NULL) { child()->RecursivelyCaptureAllVariables(); }
622 }
623
624
625
605 RawContextScope* LocalScope::CreateImplicitClosureScope(const Function& func) { 626 RawContextScope* LocalScope::CreateImplicitClosureScope(const Function& func) {
606 static const intptr_t kNumCapturedVars = 1; 627 static const intptr_t kNumCapturedVars = 1;
607 628
608 // Create a ContextScope with space for kNumCapturedVars descriptors. 629 // Create a ContextScope with space for kNumCapturedVars descriptors.
609 const ContextScope& context_scope = 630 const ContextScope& context_scope =
610 ContextScope::Handle(ContextScope::New(kNumCapturedVars)); 631 ContextScope::Handle(ContextScope::New(kNumCapturedVars));
611 632
612 // Create a descriptor for 'this' variable. 633 // Create a descriptor for 'this' variable.
613 context_scope.SetTokenIndexAt(0, func.token_pos()); 634 context_scope.SetTokenIndexAt(0, func.token_pos());
614 context_scope.SetNameAt(0, Symbols::This()); 635 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); 669 return fixed_parameter_count - (index() - kParamEndSlotFromFp);
649 } else { 670 } else {
650 // Shift negative indexes so that the lowest one is 0 (they are still 671 // Shift negative indexes so that the lowest one is 0 (they are still
651 // non-positive). 672 // non-positive).
652 return fixed_parameter_count - (index() - kFirstLocalSlotFromFp); 673 return fixed_parameter_count - (index() - kFirstLocalSlotFromFp);
653 } 674 }
654 } 675 }
655 676
656 677
657 } // namespace dart 678 } // namespace dart
OLDNEW
« runtime/vm/ast_transformer.cc ('K') | « runtime/vm/scopes.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698