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

Unified Diff: runtime/vm/object.cc

Issue 1157003003: Add TypedData instance kinds. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index dc5bbbe689c02fdbb5d9b4cc52c066445500a1f5..5f320810fc7a4eb3ca266dcb4eb01838526a85e2 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -20105,7 +20105,24 @@ const char* TypedData::ToCString() const {
void TypedData::PrintJSONImpl(JSONStream* stream, bool ref) const {
- Instance::PrintJSONImpl(stream, ref);
+ JSONObject jsobj(stream);
+ PrintSharedInstanceJSON(&jsobj, ref);
+ jsobj.AddProperty("kind", "TypedData");
+ jsobj.AddServiceId(*this);
+ jsobj.AddProperty("length", Length());
+ jsobj.AddProperty("elementType", ElementTypeName());
rmacnak 2015/06/05 20:32:35 This feels a bit leaky.
Cutch 2015/06/05 21:00:29 Let's drop elementType and use use the real list t
rmacnak 2015/06/08 22:12:03 Using UserVisibleName
+ if (ref) {
+ return;
+ }
+
+ {
+ JSONArray jsarr(&jsobj, "bytes");
+ for (intptr_t index = 0; index < LengthInBytes(); index++) {
+ NoSafepointScope no_safepoint;
+ uint8_t byte = *reinterpret_cast<uint8_t*>(DataAddr(index));
+ jsarr.AddValue(byte);
rmacnak 2015/06/05 20:32:35 base64 would be denser, but is less convenient to
Cutch 2015/06/05 21:00:29 We should use base64.
rmacnak 2015/06/08 22:12:03 Done.
+ }
+ }
}
@@ -20140,7 +20157,24 @@ const char* ExternalTypedData::ToCString() const {
void ExternalTypedData::PrintJSONImpl(JSONStream* stream,
bool ref) const {
- Instance::PrintJSONImpl(stream, ref);
+ JSONObject jsobj(stream);
+ PrintSharedInstanceJSON(&jsobj, ref);
+ jsobj.AddProperty("kind", "TypedData");
+ jsobj.AddServiceId(*this);
+ jsobj.AddProperty("length", Length());
+ jsobj.AddProperty("elementType", ElementTypeName());
+ if (ref) {
+ return;
+ }
+
+ {
+ JSONArray jsarr(&jsobj, "bytes");
+ for (intptr_t index = 0; index < LengthInBytes(); index++) {
+ NoSafepointScope no_safepoint;
+ uint8_t byte = *reinterpret_cast<uint8_t*>(DataAddr(index));
+ jsarr.AddValue(byte);
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698