Chromium Code Reviews| 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) { |