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

Side by Side Diff: runtime/vm/object.h

Issue 23875015: - Base JSON stream printing on stack objects. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/json_test.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 return reinterpret_cast<Raw##object*>(raw); \ 119 return reinterpret_cast<Raw##object*>(raw); \
120 } \ 120 } \
121 static Raw##object* null() { \ 121 static Raw##object* null() { \
122 return reinterpret_cast<Raw##object*>(Object::null()); \ 122 return reinterpret_cast<Raw##object*>(Object::null()); \
123 } \ 123 } \
124 virtual const char* ToCString() const; \ 124 virtual const char* ToCString() const; \
125 /* Object is printed as JSON into stream. If ref is true only a header */ \ 125 /* Object is printed as JSON into stream. If ref is true only a header */ \
126 /* with an object id is printed. If ref is false the object is fully */ \ 126 /* with an object id is printed. If ref is false the object is fully */ \
127 /* printed. */ \ 127 /* printed. */ \
128 virtual void PrintToJSONStream(JSONStream* stream, bool ref = true) const; \ 128 virtual void PrintToJSONStream(JSONStream* stream, bool ref = true) const; \
129 virtual const char* JSONType(bool ref) const { \
130 return ref ? "@"#object : ""#object; \
131 } \
129 static const ClassId kClassId = k##object##Cid; \ 132 static const ClassId kClassId = k##object##Cid; \
130 private: /* NOLINT */ \ 133 private: /* NOLINT */ \
131 /* Initialize the handle based on the raw_ptr in the presence of null. */ \ 134 /* Initialize the handle based on the raw_ptr in the presence of null. */ \
132 static void initializeHandle(object* obj, RawObject* raw_ptr) { \ 135 static void initializeHandle(object* obj, RawObject* raw_ptr) { \
133 if (raw_ptr != Object::null()) { \ 136 if (raw_ptr != Object::null()) { \
134 obj->SetRaw(raw_ptr); \ 137 obj->SetRaw(raw_ptr); \
135 } else { \ 138 } else { \
136 obj->raw_ = Object::null(); \ 139 obj->raw_ = Object::null(); \
137 object fake_object; \ 140 object fake_object; \
138 obj->set_vtable(fake_object.vtable()); \ 141 obj->set_vtable(fake_object.vtable()); \
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 250
248 virtual const char* ToCString() const { 251 virtual const char* ToCString() const {
249 if (IsNull()) { 252 if (IsNull()) {
250 return "null"; 253 return "null";
251 } else { 254 } else {
252 return "Object"; 255 return "Object";
253 } 256 }
254 } 257 }
255 258
256 virtual void PrintToJSONStream(JSONStream* stream, bool ref = true) const { 259 virtual void PrintToJSONStream(JSONStream* stream, bool ref = true) const {
257 if (IsNull()) { 260 JSONObject jsobj(stream);
258 stream->OpenObject(); 261 jsobj.AddProperty("type", JSONType(ref));
259 stream->PrintProperty("type", "null"); 262 }
260 stream->CloseObject(); 263
261 return; 264 virtual const char* JSONType(bool ref) const {
262 } 265 return IsNull() ? "null" : "Object";
263 ASSERT(!IsNull());
264 stream->OpenObject();
265 stream->PrintProperty("type", "Object");
266 stream->CloseObject();
267 } 266 }
268 267
269 // Returns the name that is used to identify an object in the 268 // Returns the name that is used to identify an object in the
270 // namespace dictionary. 269 // namespace dictionary.
271 // Object::DictionaryName() returns String::null(). Only subclasses 270 // Object::DictionaryName() returns String::null(). Only subclasses
272 // of Object that need to be entered in the library and library prefix 271 // of Object that need to be entered in the library and library prefix
273 // namespaces need to provide an implementation. 272 // namespaces need to provide an implementation.
274 virtual RawString* DictionaryName() const; 273 virtual RawString* DictionaryName() const;
275 274
276 bool IsNew() const { return raw()->IsNewObject(); } 275 bool IsNew() const { return raw()->IsNewObject(); }
(...skipping 5872 matching lines...) Expand 10 before | Expand all | Expand 10 after
6149 6148
6150 6149
6151 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6150 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6152 intptr_t index) { 6151 intptr_t index) {
6153 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6152 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6154 } 6153 }
6155 6154
6156 } // namespace dart 6155 } // namespace dart
6157 6156
6158 #endif // VM_OBJECT_H_ 6157 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/json_test.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698