Index: runtime/vm/dart_api_message.cc |
diff --git a/runtime/vm/dart_api_message.cc b/runtime/vm/dart_api_message.cc |
index e7fb7cc3f95d8a693a95aea6a0f7ad3741a4c4f7..a17772e8e5dc0ee55640d82620187a32de96bb86 100644 |
--- a/runtime/vm/dart_api_message.cc |
+++ b/runtime/vm/dart_api_message.cc |
@@ -162,6 +162,23 @@ Dart_CObject* ApiMessageReader::AllocateDartCObjectArray(intptr_t length) { |
} |
+Dart_CObject* ApiMessageReader::AllocateDartCObjectGrowableObjectArray( |
+ intptr_t length) { |
+ // Allocate a Dart_CObject structure for holding the GrowableObjectArray |
Mads Ager (google)
2012/09/10 13:28:18
Move this comment to before the method as it is a
Søren Gjesse
2012/09/10 14:02:02
Ended up removing this method.
|
+ // length. This object will be patched to an array when the actual content |
+ // of the GrowableObjectArray is read. |
+ Dart_CObject* value = |
+ reinterpret_cast<Dart_CObject*>( |
+ alloc_(NULL, 0, sizeof(Dart_CObject))); |
+ ASSERT(value != NULL); |
+ // Temporarily assign an illegal type. |
+ value->type = static_cast<Dart_CObject::Type>(Dart_CObject::kNumberOfTypes); |
+ value->value.as_array.length = length; |
+ value->value.as_array.values = NULL; |
+ return value; |
+} |
+ |
+ |
ApiMessageReader::BackRefNode* ApiMessageReader::AllocateBackRefNode( |
Dart_CObject* reference, |
DeserializeState state) { |
@@ -206,6 +223,23 @@ Dart_CObject* ApiMessageReader::ReadInlinedObject(intptr_t object_id) { |
value->value.as_array.values[i] = ReadObjectRef(); |
} |
return value; |
+ } else if (class_id == kGrowableObjectArrayCid) { |
+ // A GrowableObjectArray is serialized as its length followed by its backing |
+ // store. The backing store is an array with a length which might be longer |
+ // than the length of the GrowableObjectArray. |
+ intptr_t len = ReadSmiValue(); |
+ Dart_CObject* value = GetBackRef(object_id); |
+ if (value == NULL) { |
+ value = AllocateDartCObjectGrowableObjectArray(len); |
+ AddBackRef(object_id, value, kIsDeserialized); |
+ } |
+ // Read the content of the GrowableObjectArray. |
+ Dart_CObject* content = ReadObjectImpl(); |
+ ASSERT(content->type == Dart_CObject::kArray); |
+ // Make the GrowableObjectArray read into an array. |
Mads Ager (google)
2012/09/10 13:28:18
I find this comment confusing. Maybe add comments
Søren Gjesse
2012/09/10 14:02:02
Simplified to just allocate an empty array for the
|
+ value->type = content->type; |
+ value->value.as_array.values = content->value.as_array.values; |
+ return value; |
} |
return ReadInternalVMObject(class_id, object_id); |