Index: runtime/vm/scopes.cc |
diff --git a/runtime/vm/scopes.cc b/runtime/vm/scopes.cc |
index f0c5080b8e4a5a384c68a2098d14d3687d504ba2..701e3e244999031a1f0881bfda55220292f02b5f 100644 |
--- a/runtime/vm/scopes.cc |
+++ b/runtime/vm/scopes.cc |
@@ -617,19 +617,23 @@ LocalScope* LocalScope::RestoreOuterScope(const ContextScope& context_scope) { |
} |
-void LocalScope::RecursivelyCaptureAllVariables() { |
- for (intptr_t i = 0; i < num_variables(); i++) { |
- if ((VariableAt(i)->name().raw() == Symbols::StackTraceVar().raw()) || |
- (VariableAt(i)->name().raw() == Symbols::ExceptionVar().raw()) || |
- (VariableAt(i)->name().raw() == Symbols::SavedTryContextVar().raw())) { |
- // Don't capture those variables because the VM expects them to be on the |
- // stack. |
- continue; |
+void LocalScope::CaptureLocalVariables(LocalScope* top_scope) { |
+ LocalScope* scope = this; |
+ while (scope != top_scope->parent()) { |
+ ASSERT(scope->function_level() == function_level()); |
hausner
2015/09/02 22:07:55
Tiny detail: you could do the assertion outside of
regis
2015/09/03 01:28:04
Done.
|
+ for (intptr_t i = 0; i < scope->num_variables(); i++) { |
+ LocalVariable* variable = scope->VariableAt(i); |
+ if ((variable->name().raw() == Symbols::StackTraceVar().raw()) || |
+ (variable->name().raw() == Symbols::ExceptionVar().raw()) || |
+ (variable->name().raw() == Symbols::SavedTryContextVar().raw())) { |
+ // Don't capture those variables because the VM expects them to be on |
+ // the stack. |
+ continue; |
+ } |
+ scope->CaptureVariable(variable); |
} |
- CaptureVariable(VariableAt(i)); |
+ scope = scope->parent(); |
} |
- if (sibling() != NULL) { sibling()->RecursivelyCaptureAllVariables(); } |
- if (child() != NULL) { child()->RecursivelyCaptureAllVariables(); } |
} |