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/double_conversion.h" | 10 #include "vm/double_conversion.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 Token::kDOUBLE, | 214 Token::kDOUBLE, |
| 215 &is_positive, | 215 &is_positive, |
| 216 &number_string)) { | 216 &number_string)) { |
| 217 const char* cstr = number_string->ToCString(); | 217 const char* cstr = number_string->ToCString(); |
| 218 char* p_end = NULL; | 218 char* p_end = NULL; |
| 219 double double_value = strtod(cstr, &p_end); | 219 double double_value = strtod(cstr, &p_end); |
| 220 ASSERT(p_end != cstr); | 220 ASSERT(p_end != cstr); |
| 221 if (!is_positive) { | 221 if (!is_positive) { |
| 222 double_value = -double_value; | 222 double_value = -double_value; |
| 223 } | 223 } |
| 224 return Double::New(double_value); | 224 return Double::NewCanonical(double_value); |
|
srdjan
2012/11/27 23:32:07
Do not canonicalize om this native, as it is calle
siva
2012/11/28 00:22:56
Done.
| |
| 225 } | 225 } |
| 226 | 226 |
| 227 if (Scanner::IsValidLiteral(tokens, | 227 if (Scanner::IsValidLiteral(tokens, |
| 228 Token::kINTEGER, | 228 Token::kINTEGER, |
| 229 &is_positive, | 229 &is_positive, |
| 230 &number_string)) { | 230 &number_string)) { |
| 231 Integer& res = Integer::Handle(Integer::New(*number_string)); | 231 Integer& res = Integer::Handle(Integer::NewCanonical(*number_string)); |
| 232 if (is_positive) { | 232 if (is_positive) { |
| 233 return Double::New(res.AsDoubleValue()); | 233 return Double::NewCanonical(res.AsDoubleValue()); |
| 234 } | 234 } |
| 235 return Double::New(-res.AsDoubleValue()); | 235 return Double::NewCanonical(-res.AsDoubleValue()); |
| 236 } | 236 } |
| 237 | 237 |
| 238 // Infinity and nan. | 238 // Infinity and nan. |
| 239 if (Scanner::IsValidLiteral(tokens, | 239 if (Scanner::IsValidLiteral(tokens, |
| 240 Token::kIDENT, | 240 Token::kIDENT, |
| 241 &is_positive, | 241 &is_positive, |
| 242 &number_string)) { | 242 &number_string)) { |
| 243 if (number_string->Equals("NaN")) { | 243 if (number_string->Equals("NaN")) { |
| 244 return Double::New(NAN); | 244 return Double::NewCanonical(NAN); |
| 245 } | 245 } |
| 246 if (number_string->Equals("Infinity")) { | 246 if (number_string->Equals("Infinity")) { |
| 247 if (is_positive) { | 247 if (is_positive) { |
| 248 return Double::New(INFINITY); | 248 return Double::NewCanonical(INFINITY); |
| 249 } | 249 } |
| 250 return Double::New(-INFINITY); | 250 return Double::NewCanonical(-INFINITY); |
| 251 } | 251 } |
| 252 } | 252 } |
| 253 | 253 |
| 254 GrowableArray<const Object*> args; | 254 GrowableArray<const Object*> args; |
| 255 args.Add(&value); | 255 args.Add(&value); |
| 256 Exceptions::ThrowByType(Exceptions::kFormat, args); | 256 Exceptions::ThrowByType(Exceptions::kFormat, args); |
| 257 return Object::null(); | 257 return Object::null(); |
| 258 } | 258 } |
| 259 | 259 |
| 260 | 260 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 | 329 |
| 330 DEFINE_NATIVE_ENTRY(Double_getIsNegative, 1) { | 330 DEFINE_NATIVE_ENTRY(Double_getIsNegative, 1) { |
| 331 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0)); | 331 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0)); |
| 332 // Include negative zero, infinity. | 332 // Include negative zero, infinity. |
| 333 return Bool::Get(signbit(arg.value()) && !isnan(arg.value())); | 333 return Bool::Get(signbit(arg.value()) && !isnan(arg.value())); |
| 334 } | 334 } |
| 335 | 335 |
| 336 // Add here only functions using/referring to old-style casts. | 336 // Add here only functions using/referring to old-style casts. |
| 337 | 337 |
| 338 } // namespace dart | 338 } // namespace dart |
| OLD | NEW |