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

Unified Diff: runtime/vm/object.h

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/method_recognizer.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index c3d39af7ec4ccca3d5e1de1c4b6c3df2fd0c2fab..56bcfd057160b86a7a3d53e1bc7e85bff40bbaf1 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -1210,6 +1210,9 @@ class Class : public Object {
int64_t value, intptr_t* index) const;
RawBigint* LookupCanonicalBigint(Zone* zone,
const Bigint& value, intptr_t* index) const;
+ RawFraction* LookupCanonicalFraction(Zone* zone,
+ const Fraction& value,
+ intptr_t* index) const;
// The methods above are more efficient than this generic one.
RawInstance* LookupCanonicalInstance(Zone* zone,
const Instance& value) const;
@@ -6344,7 +6347,52 @@ class Bigint : public Integer {
};
-// Class Double represents class Double in corelib_impl, which implements
+class Fraction : public Number {
+ public:
+ RawInteger* numerator() const {
+ return raw_ptr()->numerator_;
+ }
+ RawInteger* denominator() const {
+ return raw_ptr()->denominator_;
+ }
+ virtual bool CanonicalizeEquals(const Instance& other) const;
+
+ static RawFraction* New(Heap::Space space = Heap::kNew); // For snapshots.
+
+ static RawFraction* New(uint64_t numerator,
+ uint64_t denominator,
+ Heap::Space space = Heap::kNew);
+
+ // Returns a canonical Fraction object allocated in the old gen space.
+ static RawFraction* NewCanonical(const Fraction& value);
+
+ // Returns a canonical Fraction object (allocated in the old gen space) or
+ // Fraction::null() if str points to a string that does not convert to a
+ // Fraction value.
+ static RawFraction* NewCanonical(const String& str);
+
+ static intptr_t InstanceSize() {
+ return RoundedAllocationSize(sizeof(RawFraction));
+ }
+
+ static intptr_t numerator_offset() {
+ return OFFSET_OF(RawFraction, numerator_);
+ }
+ static intptr_t denominator_offset() {
+ return OFFSET_OF(RawFraction, denominator_);
+ }
+
+ private:
+ void set_numerator(const Integer& value) const;
+ void set_denominator(const Integer& value) const;
+
+ FINAL_HEAP_OBJECT_IMPLEMENTATION(Fraction, Number);
+ friend class Class;
+ friend class Number;
+};
+
+
+// Class Double represents Dart class _Double in runtime/lib, which implements
// abstract class double in corelib.
class Double : public Number {
public:
« no previous file with comments | « runtime/vm/method_recognizer.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698