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/double_conversion.h" | 10 #include "vm/double_conversion.h" |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 } else if ((Mint::kMinValue <= result) && (result <= Mint::kMaxValue)) { | 199 } else if ((Mint::kMinValue <= result) && (result <= Mint::kMaxValue)) { |
200 return Mint::New(static_cast<int64_t>(result)); | 200 return Mint::New(static_cast<int64_t>(result)); |
201 } else { | 201 } else { |
202 return BigintOperations::NewFromDouble(result); | 202 return BigintOperations::NewFromDouble(result); |
203 } | 203 } |
204 } | 204 } |
205 | 205 |
206 | 206 |
207 DEFINE_NATIVE_ENTRY(Double_parse, 1) { | 207 DEFINE_NATIVE_ENTRY(Double_parse, 1) { |
208 GET_NON_NULL_NATIVE_ARGUMENT(String, value, arguments->NativeArgAt(0)); | 208 GET_NON_NULL_NATIVE_ARGUMENT(String, value, arguments->NativeArgAt(0)); |
209 const String& dummy_key = String::Handle(Symbols::Empty()); | 209 Scanner scanner(value, Symbols::Empty()); |
210 Scanner scanner(value, dummy_key); | |
211 const Scanner::GrowableTokenStream& tokens = scanner.GetStream(); | 210 const Scanner::GrowableTokenStream& tokens = scanner.GetStream(); |
212 String* number_string; | 211 String* number_string; |
213 bool is_positive; | 212 bool is_positive; |
214 if (Scanner::IsValidLiteral(tokens, | 213 if (Scanner::IsValidLiteral(tokens, |
215 Token::kDOUBLE, | 214 Token::kDOUBLE, |
216 &is_positive, | 215 &is_positive, |
217 &number_string)) { | 216 &number_string)) { |
218 const char* cstr = number_string->ToCString(); | 217 const char* cstr = number_string->ToCString(); |
219 char* p_end = NULL; | 218 char* p_end = NULL; |
220 double double_value = strtod(cstr, &p_end); | 219 double double_value = strtod(cstr, &p_end); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 | 329 |
331 DEFINE_NATIVE_ENTRY(Double_getIsNegative, 1) { | 330 DEFINE_NATIVE_ENTRY(Double_getIsNegative, 1) { |
332 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0)); | 331 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0)); |
333 // Include negative zero, infinity. | 332 // Include negative zero, infinity. |
334 return Bool::Get(signbit(arg.value()) && !isnan(arg.value())); | 333 return Bool::Get(signbit(arg.value()) && !isnan(arg.value())); |
335 } | 334 } |
336 | 335 |
337 // Add here only functions using/referring to old-style casts. | 336 // Add here only functions using/referring to old-style casts. |
338 | 337 |
339 } // namespace dart | 338 } // namespace dart |
OLD | NEW |