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

Unified Diff: runtime/vm/debugger.cc

Issue 249533003: Support evaluation of expressions in context of a stack frame (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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/debugger.h ('k') | runtime/vm/debugger_api_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/debugger.cc
===================================================================
--- runtime/vm/debugger.cc (revision 35336)
+++ runtime/vm/debugger.cc (working copy)
@@ -765,6 +765,61 @@
}
+RawObject* ActivationFrame::GetReceiver() {
+ GetDescIndices();
+ intptr_t num_variables = desc_indices_.length();
+ String& var_name = String::Handle();
+ Instance& value = Instance::Handle();
+ for (intptr_t i = 0; i < num_variables; i++) {
+ intptr_t ignore;
+ VariableAt(i, &var_name, &ignore, &ignore, &value);
+ if (var_name.Equals(Symbols::This())) {
+ return value.raw();
+ }
+ }
+ return Object::null();
+}
+
+
+RawObject* ActivationFrame::Evaluate(const String& expr) {
+ GetDescIndices();
+ const GrowableObjectArray& param_names =
+ GrowableObjectArray::Handle(GrowableObjectArray::New());
+ const GrowableObjectArray& param_values =
+ GrowableObjectArray::Handle(GrowableObjectArray::New());
+ String& name = String::Handle();
+ Instance& value = Instance::Handle();
+ intptr_t num_variables = desc_indices_.length();
+ for (intptr_t i = 0; i < num_variables; i++) {
+ intptr_t ignore;
+ VariableAt(i, &name, &ignore, &ignore, &value);
+ if (!name.Equals(Symbols::This())) {
+ param_names.Add(name);
+ param_values.Add(value);
+ }
+ }
+
+ if (function().is_static()) {
+ const Class& cls = Class::Handle(function().Owner());
+ return cls.Evaluate(expr,
+ Array::Handle(Array::MakeArray(param_names)),
+ Array::Handle(Array::MakeArray(param_values)));
+ } else {
+ const Object& receiver = Object::Handle(GetReceiver());
+ ASSERT(receiver.IsInstance());
+ if (!receiver.IsInstance()) {
+ return Object::null();
+ }
+ const Instance& inst = Instance::Cast(receiver);
+ return inst.Evaluate(expr,
+ Array::Handle(Array::MakeArray(param_names)),
+ Array::Handle(Array::MakeArray(param_values)));
+ }
+ UNREACHABLE();
+ return Object::null();
+}
+
+
const char* ActivationFrame::ToCString() {
const String& url = String::Handle(SourceUrl());
intptr_t line = LineNumber();
« no previous file with comments | « runtime/vm/debugger.h ('k') | runtime/vm/debugger_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698