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

Unified Diff: runtime/vm/scopes.cc

Issue 1241673003: Async-step, first cut. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/service_event.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/scopes.cc
diff --git a/runtime/vm/scopes.cc b/runtime/vm/scopes.cc
index 49601a19b984b12f71e18d88ad169e8193f31042..0d4233a5b907652fdd9ae7cb611d545512301f7b 100644
--- a/runtime/vm/scopes.cc
+++ b/runtime/vm/scopes.cc
@@ -249,6 +249,13 @@ int LocalScope::AllocateVariables(int first_parameter_index,
}
+// The parser creates internal variables that start with ":"
+static bool IsInternalIdentifier(const String& str) {
+ ASSERT(str.Length() > 0);
+ return str.CharAt(0) == ':';
+}
+
+
RawLocalVarDescriptors* LocalScope::GetVarDescriptors(const Function& func) {
GrowableArray<VarDesc> vars(8);
// First enter all variables from scopes of outer functions.
@@ -257,9 +264,19 @@ RawLocalVarDescriptors* LocalScope::GetVarDescriptors(const Function& func) {
if (!context_scope.IsNull()) {
ASSERT(func.IsLocalFunction());
for (int i = 0; i < context_scope.num_variables(); i++) {
+ String& name = String::Handle(context_scope.NameAt(i));
+ RawLocalVarDescriptors::VarInfoKind kind;
+ if (!IsInternalIdentifier(name)) {
+ kind = RawLocalVarDescriptors::kContextVar;
+ } else if (name.raw() == Symbols::AsyncOperation().raw()) {
+ kind = RawLocalVarDescriptors::kAsyncOperation;
+ } else {
+ continue;
+ }
+
VarDesc desc;
- desc.name = &String::Handle(context_scope.NameAt(i));
- desc.info.set_kind(RawLocalVarDescriptors::kContextVar);
+ desc.name = &name;
+ desc.info.set_kind(kind);
desc.info.scope_id = context_scope.ContextLevelAt(i);
desc.info.begin_pos = begin_token_pos();
desc.info.end_pos = end_token_pos();
@@ -284,13 +301,6 @@ RawLocalVarDescriptors* LocalScope::GetVarDescriptors(const Function& func) {
}
-// The parser creates internal variables that start with ":"
-static bool IsInternalIdentifier(const String& str) {
- ASSERT(str.Length() > 0);
- return str.CharAt(0) == ':';
-}
-
-
// Add visible variables that are declared in this scope to vars, then
// collect visible variables of children, followed by siblings.
void LocalScope::CollectLocalVariables(GrowableArray<VarDesc>* vars,
@@ -337,6 +347,23 @@ void LocalScope::CollectLocalVariables(GrowableArray<VarDesc>* vars,
desc.info.end_pos = 0;
desc.info.set_index(var->index());
vars->Add(desc);
+ } else if (var->name().raw() == Symbols::AsyncOperation().raw()) {
+ // The async continuation.
+ ASSERT(var->is_captured());
+ VarDesc desc;
+ desc.name = &var->name();
+ desc.info.set_kind(RawLocalVarDescriptors::kAsyncOperation);
+ if (var->is_captured()) {
+ ASSERT(var->owner() != NULL);
+ ASSERT(var->owner()->context_level() >= 0);
+ desc.info.scope_id = var->owner()->context_level();
+ } else {
+ desc.info.scope_id = *scope_id;
+ }
+ desc.info.begin_pos = 0;
+ desc.info.end_pos = 0;
+ desc.info.set_index(var->index());
+ vars->Add(desc);
}
}
}
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/service_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698