Chromium Code Reviews| Index: runtime/vm/object.h |
| =================================================================== |
| --- runtime/vm/object.h (revision 27302) |
| +++ runtime/vm/object.h (working copy) |
| @@ -126,6 +126,9 @@ |
| /* with an object id is printed. If ref is false the object is fully */ \ |
| /* printed. */ \ |
| virtual void PrintToJSONStream(JSONStream* stream, bool ref = true) const; \ |
| + virtual const char* JSONType(bool ref) const { \ |
| + return ref ? "@"#object : ""#object; \ |
|
siva
2013/09/09 22:45:26
format error in '\'
Ivan Posva
2013/09/10 17:21:31
Done.
|
| + } \ |
| static const ClassId kClassId = k##object##Cid; \ |
| private: /* NOLINT */ \ |
| /* Initialize the handle based on the raw_ptr in the presence of null. */ \ |
| @@ -254,18 +257,14 @@ |
| } |
| virtual void PrintToJSONStream(JSONStream* stream, bool ref = true) const { |
| - if (IsNull()) { |
| - stream->OpenObject(); |
| - stream->PrintProperty("type", "null"); |
| - stream->CloseObject(); |
| - return; |
| - } |
| - ASSERT(!IsNull()); |
| - stream->OpenObject(); |
| - stream->PrintProperty("type", "Object"); |
| - stream->CloseObject(); |
| + JSONObject jsobj(stream); |
| + jsobj.AddProperty("type", JSONType(ref)); |
| } |
| + virtual const char* JSONType(bool ref) const { |
| + return IsNull() ? "null" : "Object"; |
| + } |
| + |
| // Returns the name that is used to identify an object in the |
| // namespace dictionary. |
| // Object::DictionaryName() returns String::null(). Only subclasses |