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

Side by Side Diff: runtime/vm/object.h

Issue 264853006: - implement IsNegative for class Double (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/lib/double.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 4777 matching lines...) Expand 10 before | Expand all | Expand 10 after
4788 static RawMixinAppType* New(); 4788 static RawMixinAppType* New();
4789 4789
4790 FINAL_HEAP_OBJECT_IMPLEMENTATION(MixinAppType, AbstractType); 4790 FINAL_HEAP_OBJECT_IMPLEMENTATION(MixinAppType, AbstractType);
4791 friend class Class; 4791 friend class Class;
4792 }; 4792 };
4793 4793
4794 4794
4795 class Number : public Instance { 4795 class Number : public Instance {
4796 public: 4796 public:
4797 // TODO(iposva): Fill in a useful Number interface. 4797 // TODO(iposva): Fill in a useful Number interface.
4798 virtual bool IsZero() const {
4799 // Number is an abstract class.
4800 UNREACHABLE();
4801 return false;
4802 }
4803 virtual bool IsNegative() const { 4798 virtual bool IsNegative() const {
4804 // Number is an abstract class. 4799 // Number is an abstract class.
4805 UNREACHABLE(); 4800 UNREACHABLE();
4806 return false; 4801 return false;
4807 } 4802 }
4803
4804 private:
4808 OBJECT_IMPLEMENTATION(Number, Instance); 4805 OBJECT_IMPLEMENTATION(Number, Instance);
4809 friend class Class; 4806 friend class Class;
4810 }; 4807 };
4811 4808
4812 4809
4813 class Integer : public Number { 4810 class Integer : public Number {
4814 public: 4811 public:
4815 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew); 4812 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew);
4816 static RawInteger* NewFromUint64( 4813 static RawInteger* NewFromUint64(
4817 uint64_t value, Heap::Space space = Heap::kNew); 4814 uint64_t value, Heap::Space space = Heap::kNew);
4818 4815
4819 // Returns a canonical Integer object allocated in the old gen space. 4816 // Returns a canonical Integer object allocated in the old gen space.
4820 static RawInteger* NewCanonical(const String& str); 4817 static RawInteger* NewCanonical(const String& str);
4821 4818
4822 // Do not throw JavascriptIntegerOverflow if 'silent' is true. 4819 // Do not throw JavascriptIntegerOverflow if 'silent' is true.
4823 static RawInteger* New(int64_t value, 4820 static RawInteger* New(int64_t value,
4824 Heap::Space space = Heap::kNew, 4821 Heap::Space space = Heap::kNew,
4825 const bool silent = false); 4822 const bool silent = false);
4826 4823
4824 // Integer is an abstract class.
4825 virtual bool IsZero() const {
4826 UNREACHABLE();
4827 return false;
4828 }
4827 virtual double AsDoubleValue() const; 4829 virtual double AsDoubleValue() const;
4828 virtual int64_t AsInt64Value() const; 4830 virtual int64_t AsInt64Value() const;
4829 virtual uint32_t AsTruncatedUint32Value() const; 4831 virtual uint32_t AsTruncatedUint32Value() const;
4830 4832
4831 // Returns 0, -1 or 1. 4833 // Returns 0, -1 or 1.
4832 virtual int CompareWith(const Integer& other) const; 4834 virtual int CompareWith(const Integer& other) const;
4833 4835
4834 // Return the most compact presentation of an integer. 4836 // Return the most compact presentation of an integer.
4835 RawInteger* AsValidInteger() const; 4837 RawInteger* AsValidInteger() const;
4836 4838
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
5073 // Class Double represents class Double in corelib_impl, which implements 5075 // Class Double represents class Double in corelib_impl, which implements
5074 // abstract class double in corelib. 5076 // abstract class double in corelib.
5075 class Double : public Number { 5077 class Double : public Number {
5076 public: 5078 public:
5077 double value() const { 5079 double value() const {
5078 return raw_ptr()->value_; 5080 return raw_ptr()->value_;
5079 } 5081 }
5080 5082
5081 bool EqualsToDouble(double value) const; 5083 bool EqualsToDouble(double value) const;
5082 virtual bool Equals(const Instance& other) const; 5084 virtual bool Equals(const Instance& other) const;
5085 virtual bool IsNegative() const {
5086 double dval = value();
5087 return (signbit(dval) && !isnan(dval));
5088 }
5083 5089
5084 static RawDouble* New(double d, Heap::Space space = Heap::kNew); 5090 static RawDouble* New(double d, Heap::Space space = Heap::kNew);
5085 5091
5086 static RawDouble* New(const String& str, Heap::Space space = Heap::kNew); 5092 static RawDouble* New(const String& str, Heap::Space space = Heap::kNew);
5087 5093
5088 // Returns a canonical double object allocated in the old gen space. 5094 // Returns a canonical double object allocated in the old gen space.
5089 static RawDouble* NewCanonical(double d); 5095 static RawDouble* NewCanonical(double d);
5090 5096
5091 // Returns a canonical double object (allocated in the old gen space) or 5097 // Returns a canonical double object (allocated in the old gen space) or
5092 // Double::null() if str points to a string that does not convert to a 5098 // Double::null() if str points to a string that does not convert to a
(...skipping 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after
6976 6982
6977 6983
6978 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6984 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6979 intptr_t index) { 6985 intptr_t index) {
6980 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6986 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6981 } 6987 }
6982 6988
6983 } // namespace dart 6989 } // namespace dart
6984 6990
6985 #endif // VM_OBJECT_H_ 6991 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/lib/double.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698