Index: runtime/lib/double.cc |
diff --git a/runtime/lib/double.cc b/runtime/lib/double.cc |
index 00c68e823af1033d676c8ada5744f8cd8eaa93b8..5cec30b556a258a1057b2fb21c0c9d20101cda12 100644 |
--- a/runtime/lib/double.cc |
+++ b/runtime/lib/double.cc |
@@ -203,12 +203,37 @@ DEFINE_NATIVE_ENTRY(Double_toStringAsFixed, 2) { |
DEFINE_NATIVE_ENTRY(Double_toStringAsExponential, 2) { |
- UNIMPLEMENTED(); |
+ const Double& arg = Double::CheckedHandle(arguments->At(0)); |
+ GET_NATIVE_ARGUMENT(Smi, fraction_digits, arguments->At(1)); |
+ double d = arg.value(); |
+ int fraction_digits_value = fraction_digits.Value(); |
Ivan Posva
2012/01/26 00:35:39
Potentially losing bits here!
floitsch
2012/01/27 12:51:07
The dart code already checked that the number was
|
+ String& result = String::Handle(); |
+ bool succeeded = |
+ DoubleToStringAsExponential(d, fraction_digits_value, result); |
+ if (!succeeded) { |
+ GrowableArray<const Object*> args; |
+ args.Add(&String::ZoneHandle(String::New( |
+ "Illegal arguments to double.toStringAsExponential"))); |
+ Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); |
+ } |
+ arguments->SetReturn(result); |
} |
DEFINE_NATIVE_ENTRY(Double_toStringAsPrecision, 2) { |
- UNIMPLEMENTED(); |
+ const Double& arg = Double::CheckedHandle(arguments->At(0)); |
+ GET_NATIVE_ARGUMENT(Smi, precision, arguments->At(1)); |
+ double d = arg.value(); |
+ int precision_value = precision.Value(); |
Ivan Posva
2012/01/26 00:35:39
ditto!
floitsch
2012/01/27 12:51:07
Done.
|
+ String& result = String::Handle(); |
+ bool succeeded = DoubleToStringAsPrecision(d, precision_value, result); |
+ if (!succeeded) { |
+ GrowableArray<const Object*> args; |
+ args.Add(&String::ZoneHandle(String::New( |
+ "Illegal arguments to double.toStringAsPrecision"))); |
+ Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); |
+ } |
+ arguments->SetReturn(result); |
} |