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 "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
6 | 6 |
7 #include "platform/math.h" | 7 #include "platform/math.h" |
8 | 8 |
9 #include "vm/code_generator.h" // DartModulo. | 9 #include "vm/code_generator.h" // DartModulo. |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 if (0 <= start && start < end && end <= len) { | 223 if (0 <= start && start < end && end <= len) { |
224 double double_value; | 224 double double_value; |
225 if (String::ParseDouble(value, start, end, &double_value)) { | 225 if (String::ParseDouble(value, start, end, &double_value)) { |
226 return Double::New(double_value); | 226 return Double::New(double_value); |
227 } | 227 } |
228 } | 228 } |
229 return Object::null(); | 229 return Object::null(); |
230 } | 230 } |
231 | 231 |
232 | 232 |
| 233 DEFINE_NATIVE_ENTRY(Double_toString, 1) { |
| 234 const Number& number = Number::CheckedHandle(arguments->NativeArgAt(0)); |
| 235 Heap::Space space = isolate->heap()->ShouldPretenure(kOneByteStringCid) ? |
| 236 Heap::kPretenured : Heap::kNew; |
| 237 return number.ToString(space); |
| 238 } |
| 239 |
| 240 |
233 DEFINE_NATIVE_ENTRY(Double_toStringAsFixed, 2) { | 241 DEFINE_NATIVE_ENTRY(Double_toStringAsFixed, 2) { |
234 // The boundaries are exclusive. | 242 // The boundaries are exclusive. |
235 static const double kLowerBoundary = -1e21; | 243 static const double kLowerBoundary = -1e21; |
236 static const double kUpperBoundary = 1e21; | 244 static const double kUpperBoundary = 1e21; |
237 | 245 |
238 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0)); | 246 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0)); |
239 GET_NON_NULL_NATIVE_ARGUMENT(Smi, fraction_digits, arguments->NativeArgAt(1)); | 247 GET_NON_NULL_NATIVE_ARGUMENT(Smi, fraction_digits, arguments->NativeArgAt(1)); |
240 double d = arg.value(); | 248 double d = arg.value(); |
241 intptr_t fraction_digits_value = fraction_digits.Value(); | 249 intptr_t fraction_digits_value = fraction_digits.Value(); |
242 if (0 <= fraction_digits_value && fraction_digits_value <= 20 | 250 if (0 <= fraction_digits_value && fraction_digits_value <= 20 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 DEFINE_NATIVE_ENTRY(Double_flipSignBit, 1) { | 312 DEFINE_NATIVE_ENTRY(Double_flipSignBit, 1) { |
305 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0)); | 313 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0)); |
306 const double in_val = arg.value(); | 314 const double in_val = arg.value(); |
307 const int64_t bits = bit_cast<int64_t, double>(in_val) ^ kSignBitDouble; | 315 const int64_t bits = bit_cast<int64_t, double>(in_val) ^ kSignBitDouble; |
308 return Double::New(bit_cast<double, int64_t>(bits)); | 316 return Double::New(bit_cast<double, int64_t>(bits)); |
309 } | 317 } |
310 | 318 |
311 // Add here only functions using/referring to old-style casts. | 319 // Add here only functions using/referring to old-style casts. |
312 | 320 |
313 } // namespace dart | 321 } // namespace dart |
OLD | NEW |