| OLD | NEW |
| 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 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 12803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12814 return 0.0; | 12814 return 0.0; |
| 12815 } | 12815 } |
| 12816 | 12816 |
| 12817 | 12817 |
| 12818 int64_t Integer::AsInt64Value() const { | 12818 int64_t Integer::AsInt64Value() const { |
| 12819 UNIMPLEMENTED(); | 12819 UNIMPLEMENTED(); |
| 12820 return 0; | 12820 return 0; |
| 12821 } | 12821 } |
| 12822 | 12822 |
| 12823 | 12823 |
| 12824 int32_t Integer::AsTruncatedUint32Value() const { |
| 12825 UNIMPLEMENTED(); |
| 12826 return 0; |
| 12827 } |
| 12828 |
| 12829 |
| 12824 int Integer::CompareWith(const Integer& other) const { | 12830 int Integer::CompareWith(const Integer& other) const { |
| 12825 UNIMPLEMENTED(); | 12831 UNIMPLEMENTED(); |
| 12826 return 0; | 12832 return 0; |
| 12827 } | 12833 } |
| 12828 | 12834 |
| 12829 | 12835 |
| 12830 // Returns true if the signed Integer does not fit into a | 12836 // Returns true if the signed Integer does not fit into a |
| 12831 // Javascript integer. | 12837 // Javascript integer. |
| 12832 bool Integer::CheckJavascriptIntegerOverflow() const { | 12838 bool Integer::CheckJavascriptIntegerOverflow() const { |
| 12833 // Always overflow if the value doesn't fit into an int64_t. | 12839 // Always overflow if the value doesn't fit into an int64_t. |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13083 double Smi::AsDoubleValue() const { | 13089 double Smi::AsDoubleValue() const { |
| 13084 return static_cast<double>(this->Value()); | 13090 return static_cast<double>(this->Value()); |
| 13085 } | 13091 } |
| 13086 | 13092 |
| 13087 | 13093 |
| 13088 int64_t Smi::AsInt64Value() const { | 13094 int64_t Smi::AsInt64Value() const { |
| 13089 return this->Value(); | 13095 return this->Value(); |
| 13090 } | 13096 } |
| 13091 | 13097 |
| 13092 | 13098 |
| 13099 int32_t Smi::AsTruncatedUint32Value() const { |
| 13100 return this->Value() & 0xFFFFFFFF; |
| 13101 } |
| 13102 |
| 13103 |
| 13093 static bool FitsIntoSmi(const Integer& integer) { | 13104 static bool FitsIntoSmi(const Integer& integer) { |
| 13094 if (integer.IsSmi()) { | 13105 if (integer.IsSmi()) { |
| 13095 return true; | 13106 return true; |
| 13096 } | 13107 } |
| 13097 if (integer.IsMint()) { | 13108 if (integer.IsMint()) { |
| 13098 int64_t mint_value = integer.AsInt64Value(); | 13109 int64_t mint_value = integer.AsInt64Value(); |
| 13099 return Smi::IsValid64(mint_value); | 13110 return Smi::IsValid64(mint_value); |
| 13100 } | 13111 } |
| 13101 if (integer.IsBigint()) { | 13112 if (integer.IsBigint()) { |
| 13102 return BigintOperations::FitsIntoSmi(Bigint::Cast(integer)); | 13113 return BigintOperations::FitsIntoSmi(Bigint::Cast(integer)); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13216 double Mint::AsDoubleValue() const { | 13227 double Mint::AsDoubleValue() const { |
| 13217 return static_cast<double>(this->value()); | 13228 return static_cast<double>(this->value()); |
| 13218 } | 13229 } |
| 13219 | 13230 |
| 13220 | 13231 |
| 13221 int64_t Mint::AsInt64Value() const { | 13232 int64_t Mint::AsInt64Value() const { |
| 13222 return this->value(); | 13233 return this->value(); |
| 13223 } | 13234 } |
| 13224 | 13235 |
| 13225 | 13236 |
| 13237 int32_t Mint::AsTruncatedUint32Value() const { |
| 13238 return this->value() & 0xFFFFFFFF; |
| 13239 } |
| 13240 |
| 13241 |
| 13226 int Mint::CompareWith(const Integer& other) const { | 13242 int Mint::CompareWith(const Integer& other) const { |
| 13227 ASSERT(!FitsIntoSmi(*this)); | 13243 ASSERT(!FitsIntoSmi(*this)); |
| 13228 if (other.IsMint() || other.IsSmi()) { | 13244 if (other.IsMint() || other.IsSmi()) { |
| 13229 int64_t a = AsInt64Value(); | 13245 int64_t a = AsInt64Value(); |
| 13230 int64_t b = other.AsInt64Value(); | 13246 int64_t b = other.AsInt64Value(); |
| 13231 if (a < b) { | 13247 if (a < b) { |
| 13232 return -1; | 13248 return -1; |
| 13233 } else if (a > b) { | 13249 } else if (a > b) { |
| 13234 return 1; | 13250 return 1; |
| 13235 } else { | 13251 } else { |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13483 | 13499 |
| 13484 | 13500 |
| 13485 int64_t Bigint::AsInt64Value() const { | 13501 int64_t Bigint::AsInt64Value() const { |
| 13486 if (!BigintOperations::FitsIntoInt64(*this)) { | 13502 if (!BigintOperations::FitsIntoInt64(*this)) { |
| 13487 UNREACHABLE(); | 13503 UNREACHABLE(); |
| 13488 } | 13504 } |
| 13489 return BigintOperations::ToInt64(*this); | 13505 return BigintOperations::ToInt64(*this); |
| 13490 } | 13506 } |
| 13491 | 13507 |
| 13492 | 13508 |
| 13509 int32_t Bigint::AsTruncatedUint32Value() const { |
| 13510 return BigintOperations::TruncateToUint32(*this); |
| 13511 } |
| 13512 |
| 13513 |
| 13493 // For positive values: Smi < Mint < Bigint. | 13514 // For positive values: Smi < Mint < Bigint. |
| 13494 int Bigint::CompareWith(const Integer& other) const { | 13515 int Bigint::CompareWith(const Integer& other) const { |
| 13495 ASSERT(!FitsIntoSmi(*this)); | 13516 ASSERT(!FitsIntoSmi(*this)); |
| 13496 ASSERT(!BigintOperations::FitsIntoInt64(*this)); | 13517 ASSERT(!BigintOperations::FitsIntoInt64(*this)); |
| 13497 if (other.IsBigint()) { | 13518 if (other.IsBigint()) { |
| 13498 return BigintOperations::Compare(*this, Bigint::Cast(other)); | 13519 return BigintOperations::Compare(*this, Bigint::Cast(other)); |
| 13499 } | 13520 } |
| 13500 if (this->IsNegative() == other.IsNegative()) { | 13521 if (this->IsNegative() == other.IsNegative()) { |
| 13501 return this->IsNegative() ? -1 : 1; | 13522 return this->IsNegative() ? -1 : 1; |
| 13502 } | 13523 } |
| (...skipping 2486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15989 return "_MirrorReference"; | 16010 return "_MirrorReference"; |
| 15990 } | 16011 } |
| 15991 | 16012 |
| 15992 | 16013 |
| 15993 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 16014 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 15994 Instance::PrintToJSONStream(stream, ref); | 16015 Instance::PrintToJSONStream(stream, ref); |
| 15995 } | 16016 } |
| 15996 | 16017 |
| 15997 | 16018 |
| 15998 } // namespace dart | 16019 } // namespace dart |
| OLD | NEW |