| 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:
|
|
|