Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 <math.h> | 5 #include <math.h> |
| 6 | 6 |
| 7 #include "vm/bootstrap_natives.h" | 7 #include "vm/bootstrap_natives.h" |
| 8 | 8 |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/code_generator.h" // DartModulo. | 10 #include "vm/code_generator.h" // DartModulo. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 | 74 |
| 75 | 75 |
| 76 static RawInteger* DoubleToInteger(double val, const char* error_msg) { | 76 static RawInteger* DoubleToInteger(double val, const char* error_msg) { |
| 77 if (isinf(val) || isnan(val)) { | 77 if (isinf(val) || isnan(val)) { |
| 78 const Array& args = Array::Handle(Array::New(1)); | 78 const Array& args = Array::Handle(Array::New(1)); |
| 79 args.SetAt(0, String::Handle(String::New(error_msg))); | 79 args.SetAt(0, String::Handle(String::New(error_msg))); |
| 80 Exceptions::ThrowByType(Exceptions::kUnsupported, args); | 80 Exceptions::ThrowByType(Exceptions::kUnsupported, args); |
| 81 } | 81 } |
| 82 const Bigint& big = Bigint::Handle(BigintOperations::NewFromDouble(val)); | 82 const Bigint& big = Bigint::Handle(BigintOperations::NewFromDouble(val)); |
| 83 if (BigintOperations::FitsIntoSmi(big)) { | 83 if (BigintOperations::FitsIntoSmi(big)) { |
| 84 return BigintOperations::ToSmi(big); | 84 return BigintOperations::ToSmi(big); |
|
siva
2013/05/16 19:52:50
Do we still need this check?
We could just do:
If
srdjan
2013/05/16 20:03:31
Done.
| |
| 85 } else if (BigintOperations::FitsIntoMint(big)) { | 85 } else if (BigintOperations::FitsIntoMint(big)) { |
| 86 return Mint::New(BigintOperations::ToMint(big)); | 86 return Integer::New(BigintOperations::ToMint(big)); |
| 87 } else { | 87 } else { |
| 88 return big.raw(); | 88 return big.raw(); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 DEFINE_NATIVE_ENTRY(Double_trunc_div, 2) { | 92 DEFINE_NATIVE_ENTRY(Double_trunc_div, 2) { |
| 93 double left = Double::CheckedHandle(arguments->NativeArgAt(0)).value(); | 93 double left = Double::CheckedHandle(arguments->NativeArgAt(0)).value(); |
| 94 GET_NON_NULL_NATIVE_ARGUMENT(Double, right_object, arguments->NativeArgAt(1)); | 94 GET_NON_NULL_NATIVE_ARGUMENT(Double, right_object, arguments->NativeArgAt(1)); |
| 95 double right = right_object.value(); | 95 double right = right_object.value(); |
| 96 if (FLAG_trace_intrinsified_natives) { | 96 if (FLAG_trace_intrinsified_natives) { |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 | 358 |
| 359 DEFINE_NATIVE_ENTRY(Double_getIsNegative, 1) { | 359 DEFINE_NATIVE_ENTRY(Double_getIsNegative, 1) { |
| 360 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0)); | 360 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0)); |
| 361 // Include negative zero, infinity. | 361 // Include negative zero, infinity. |
| 362 return Bool::Get(signbit(arg.value()) && !isnan(arg.value())); | 362 return Bool::Get(signbit(arg.value()) && !isnan(arg.value())); |
| 363 } | 363 } |
| 364 | 364 |
| 365 // Add here only functions using/referring to old-style casts. | 365 // Add here only functions using/referring to old-style casts. |
| 366 | 366 |
| 367 } // namespace dart | 367 } // namespace dart |
| OLD | NEW |