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

Unified Diff: runtime/vm/dart_api_message.cc

Issue 9363023: Add support for big integers to the native message format (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from asiva@ Created 8 years, 10 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
« no previous file with comments | « runtime/vm/dart_api_message.h ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_message.cc
diff --git a/runtime/vm/dart_api_message.cc b/runtime/vm/dart_api_message.cc
index 3624242d25aab309b5bec2ead99351ed60b64600..23fd0f7afb7ae19321d03c237a339bb6a0823fc6 100644
--- a/runtime/vm/dart_api_message.cc
+++ b/runtime/vm/dart_api_message.cc
@@ -88,6 +88,19 @@ Dart_CObject* ApiMessageReader::AllocateDartCObjectInt64(int64_t val) {
}
+Dart_CObject* ApiMessageReader::AllocateDartCObjectBigint(intptr_t length) {
+ // Allocate a Dart_CObject structure followed by an array of chars
+ // for the bigint hex string content. The pointer to the bigint
+ // content is set up to this area.
+ Dart_CObject* value =
+ reinterpret_cast<Dart_CObject*>(
+ alloc_(NULL, 0, sizeof(Dart_CObject) + length + 1));
+ value->value.as_bigint = reinterpret_cast<char*>(value) + sizeof(*value);
+ value->type = Dart_CObject::kBigint;
+ return value;
+}
+
+
Dart_CObject* ApiMessageReader::AllocateDartCObjectDouble(double val) {
Dart_CObject* value = AllocateDartCObject(Dart_CObject::kDouble);
value->value.as_double = val;
@@ -206,6 +219,18 @@ Dart_CObject* ApiMessageReader::ReadInlinedObject(intptr_t object_id) {
}
break;
}
+ case ObjectStore::kBigintClass: {
+ // Read in the hex string representation of the bigint.
+ intptr_t len = ReadIntptrValue();
+ Dart_CObject* object = AllocateDartCObjectBigint(len);
+ char* p = object->value.as_bigint;
+ for (intptr_t i = 0; i < len; i++) {
+ p[i] = Read<uint8_t>();
+ }
+ p[len] = '\0';
+ return object;
+ break;
+ }
case ObjectStore::kDoubleClass: {
// Read the double value for the object.
Dart_CObject* object = AllocateDartCObjectDouble(Read<double>());
« no previous file with comments | « runtime/vm/dart_api_message.h ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698