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

Unified Diff: runtime/vm/scopes.cc

Issue 8983034: Getting value of local variables on stack trace (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 12 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') | no next file » | 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 3014)
+++ runtime/vm/scopes.cc (working copy)
@@ -173,29 +173,31 @@
}
-static int CompareVariableRanges(
- LocalVariable* const* a, LocalVariable* const* b) {
- if ((*a)->token_index() < (*b)->token_index()) return -1;
- if ((*a)->token_index() > (*b)->token_index()) return 1;
- return 0;
-}
-
-
RawLocalVarDescriptors* LocalScope::GetVarDescriptors() {
GrowableArray<LocalVariable*> vars(8);
+ // Variables of each scope are guaranteed to be consecutive elements
+ // in array vars. See CollectLocalVariables() below. The outermost
+ // scope (containing the function parameters) has id 0.
CollectLocalVariables(&vars);
- vars.Sort(&CompareVariableRanges);
const LocalVarDescriptors& var_desc =
LocalVarDescriptors::Handle(LocalVarDescriptors::New(vars.length()));
+ intptr_t scope_id = -1;
+ LocalScope* current_scope = NULL;
for (int i = 0; i < vars.length(); i++) {
LocalVariable* var = vars[i];
+ if (current_scope != var->owner()) {
+ current_scope = var->owner();
+ scope_id += 1;
+ }
var_desc.SetVar(i, var->name(), var->index(),
- var->token_index(), var->owner()->end_token_index());
+ scope_id, var->token_index(), var->owner()->end_token_index());
}
return var_desc.raw();
}
+// Add variables that are declared in this scope to vars, then collect
+// variables of children, followed by siblings.
void LocalScope::CollectLocalVariables(GrowableArray<LocalVariable*>* vars) {
for (int i = 0; i < this->variables_.length(); i++) {
LocalVariable* var = variables_[i];
« no previous file with comments | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698