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

Unified Diff: runtime/vm/raw_object_snapshot.cc

Issue 2005723004: Fraction class prototype and test (not to be committed). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: work in progress Created 4 years, 5 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/raw_object.cc ('k') | runtime/vm/scanner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/raw_object_snapshot.cc
diff --git a/runtime/vm/raw_object_snapshot.cc b/runtime/vm/raw_object_snapshot.cc
index c2448a3274a2b1662aba1ff95b3cbeebeed8ccbc..b75701ac1a51ed6519d487127abe4633a1e91091 100644
--- a/runtime/vm/raw_object_snapshot.cc
+++ b/runtime/vm/raw_object_snapshot.cc
@@ -2081,6 +2081,58 @@ void RawBigint::WriteTo(SnapshotWriter* writer,
}
+RawFraction* Fraction::ReadFrom(SnapshotReader* reader,
+ intptr_t object_id,
+ intptr_t tags,
+ Snapshot::Kind kind,
+ bool as_reference) {
+ ASSERT(reader != NULL);
+
+ // Allocate fraction object.
+ Fraction& obj = Fraction::ZoneHandle(reader->zone(), NEW_OBJECT(Fraction));
+ reader->AddBackRef(object_id, &obj, kIsDeserialized);
+
+ // Set all the object fields.
+ READ_OBJECT_FIELDS(obj, obj.raw()->from(), obj.raw()->to(), kAsInlinedObject);
+
+ // If it is a canonical constant make it one.
+ // When reading a full snapshot we don't need to canonicalize the object
+ // as it would already be a canonical object.
+ // When reading a script snapshot or a message snapshot we always have
+ // to canonicalize the object.
+ if (RawObject::IsCanonical(tags)) {
+ if (Snapshot::IsFull(kind)) {
+ // Set the canonical bit.
+ obj.SetCanonical();
+ } else {
+ obj ^= obj.CheckAndCanonicalize(reader->thread(), NULL);
+ ASSERT(!obj.IsNull());
+ ASSERT(obj.IsCanonical());
+ }
+ }
+ return obj.raw();
+}
+
+
+void RawFraction::WriteTo(SnapshotWriter* writer,
+ intptr_t object_id,
+ Snapshot::Kind kind,
+ bool as_reference) {
+ ASSERT(writer != NULL);
+
+ // Write out the serialization header value for this object.
+ writer->WriteInlinedObjectHeader(object_id);
+
+ // Write out the class and tags information.
+ writer->WriteIndexedObject(kFractionCid);
+ writer->WriteTags(writer->GetObjectTags(this));
+
+ // Write out all the object pointer fields.
+ SnapshotWriterVisitor visitor(writer, kAsInlinedObject);
+ visitor.VisitPointers(from(), to());
+}
+
+
RawDouble* Double::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
intptr_t tags,
« no previous file with comments | « runtime/vm/raw_object.cc ('k') | runtime/vm/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698