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

Unified Diff: runtime/vm/object_service.cc

Issue 1865553003: vm-service: Answer fields from superclass to subclass in declaration order (layout order). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: reverse abc Created 4 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/observatory/tests/service/instance_field_order_rpc_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object_service.cc
diff --git a/runtime/vm/object_service.cc b/runtime/vm/object_service.cc
index 90f9e1d67b48d7c170bd2a23efb5103d5c017284..3cfc25b9bbf584d0c739dc36d58b1a328b5ff685 100644
--- a/runtime/vm/object_service.cc
+++ b/runtime/vm/object_service.cc
@@ -1034,27 +1034,34 @@ void Instance::PrintSharedInstanceJSON(JSONObject* jsobj,
return;
}
- // Walk the superclass chain, adding all instance fields.
+ // Add all fields in layout order, from superclass to subclass.
+ GrowableArray<Class*> classes;
Class& cls = Class::Handle(this->clazz());
+ do {
+ cls.Print();
+ classes.Add(&Class::Handle(cls.raw()));
+ cls = cls.SuperClass();
+ } while (!cls.IsNull());
+
+ Array& field_array = Array::Handle();
+ Field& field = Field::Handle();
+ Instance& field_value = Instance::Handle();
{
- Instance& fieldValue = Instance::Handle();
JSONArray jsarr(jsobj, "fields");
- while (!cls.IsNull()) {
- const Array& field_array = Array::Handle(cls.fields());
- Field& field = Field::Handle();
+ for (intptr_t i = classes.length() - 1; i >= 0; i--) {
+ field_array = classes[i]->fields();
if (!field_array.IsNull()) {
- for (intptr_t i = 0; i < field_array.Length(); i++) {
- field ^= field_array.At(i);
+ for (intptr_t j = 0; j < field_array.Length(); j++) {
+ field ^= field_array.At(j);
if (!field.is_static()) {
- fieldValue ^= GetField(field);
+ field_value ^= GetField(field);
JSONObject jsfield(&jsarr);
jsfield.AddProperty("type", "BoundField");
jsfield.AddProperty("decl", field);
- jsfield.AddProperty("value", fieldValue);
+ jsfield.AddProperty("value", field_value);
}
}
}
- cls = cls.SuperClass();
}
}
« no previous file with comments | « runtime/observatory/tests/service/instance_field_order_rpc_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698