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

Unified Diff: runtime/vm/scopes.cc

Issue 22415002: Fix access to type variables in initializer expressions (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/scopes.h ('k') | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/scopes.cc
===================================================================
--- runtime/vm/scopes.cc (revision 25809)
+++ runtime/vm/scopes.cc (working copy)
@@ -309,7 +309,7 @@
for (intptr_t i = 0; i < variables_.length(); i++) {
LocalVariable* var = variables_[i];
ASSERT(var->name().IsSymbol());
- if ((var->name().raw() == name.raw()) && !var->is_invisible_) {
+ if (var->name().raw() == name.raw()) {
return var;
}
}
@@ -321,7 +321,7 @@
LocalScope* current_scope = this;
while (current_scope != NULL) {
LocalVariable* var = current_scope->LocalLookupVariable(name);
- if (var != NULL) {
+ if ((var != NULL) && !var->is_invisible_) {
regis 2013/08/07 18:28:26 As far as I understand, if a variable is marked in
hausner 2013/08/08 09:26:06 That may be a shortcut that works now, since we us
if (!test_only) {
if (var->owner()->function_level() != function_level()) {
var->set_is_captured();
@@ -342,6 +342,29 @@
}
+void LocalScope::CaptureVariable(const String& name) {
regis 2013/08/07 18:28:26 I would still return the captured variable or a bo
hausner 2013/08/08 09:26:06 Ok, good point. will do in a follow-on CL.
+ ASSERT(name.IsSymbol());
+ LocalScope* current_scope = this;
+ while (current_scope != NULL) {
+ LocalVariable* var = current_scope->LocalLookupVariable(name);
+ if (var != NULL) {
+ if (var->owner()->function_level() != function_level()) {
+ var->set_is_captured();
+ }
+ // Insert aliases of the variable in intermediate scopes.
+ LocalScope* intermediate_scope = this;
+ while (intermediate_scope != current_scope) {
+ intermediate_scope->variables_.Add(var);
+ ASSERT(var->owner() != intermediate_scope); // Item is an alias.
+ intermediate_scope = intermediate_scope->parent();
+ }
+ return;
+ }
+ current_scope = current_scope->parent();
+ }
+}
+
+
SourceLabel* LocalScope::LookupLabel(const String& name) {
LocalScope* current_scope = this;
while (current_scope != NULL) {
« no previous file with comments | « runtime/vm/scopes.h ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698