Index: runtime/vm/dart_api_message.h |
diff --git a/runtime/vm/dart_api_message.h b/runtime/vm/dart_api_message.h |
index d8a4339e7f5ea369b9c108cab584c33b5714e0c1..76a97884f4abab28d1ba37f437b10805a5caecbb 100644 |
--- a/runtime/vm/dart_api_message.h |
+++ b/runtime/vm/dart_api_message.h |
@@ -82,6 +82,48 @@ class ApiMessageReader : public BaseReader { |
Dart_CObject dynamic_type_marker; |
}; |
+ |
+class ApiMessageWriter : public BaseWriter { |
+ public: |
+ ApiMessageWriter(uint8_t** buffer, ReAlloc alloc) |
+ : BaseWriter(buffer, alloc), object_id_(0) { |
+ ASSERT(kDartCObjectTypeMask >= Dart_CObject::kNumberOfTypes - 1); |
+ } |
+ ~ApiMessageWriter() { } |
+ |
+ // Writes a message of integers. |
+ void WriteMessage(intptr_t field_count, intptr_t *data); |
+ |
+ void WriteCMessage(Dart_CObject* object); |
+ |
+ void FinalizeBuffer() { |
+ BaseWriter::FinalizeBuffer(Snapshot::kMessage); |
+ } |
+ |
+ private: |
+ static const intptr_t kDartCObjectTypeBits = 4; |
+ static const intptr_t kDartCObjectTypeMask = (1 << kDartCObjectTypeBits) - 1; |
+ static const intptr_t kDartCObjectMarkMask = ~kDartCObjectTypeMask; |
+ static const intptr_t kDartCObjectMarkOffset = 1; |
+ |
+ void MarkCObject(Dart_CObject* object, intptr_t object_id); |
+ void UnmarkCObject(Dart_CObject* object); |
+ bool IsCObjectMarked(Dart_CObject* object); |
+ intptr_t GetMarkedCObjectMark(Dart_CObject* object); |
+ void UnmarkAllCObjects(Dart_CObject* object); |
+ |
+ void WriteSmi(int64_t value); |
+ void WriteMint(Dart_CObject* object, int64_t value); |
+ void WriteInt32(Dart_CObject* object); |
+ void WriteInt64(Dart_CObject* object); |
+ void WriteInlinedHeader(Dart_CObject* object); |
+ void WriteCObject(Dart_CObject* object); |
+ |
+ intptr_t object_id_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ApiMessageWriter); |
+}; |
+ |
} // namespace dart |
#endif // VM_DART_API_MESSAGE_H_ |