Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(553)

Unified Diff: lib/double.cc

Issue 10874072: Use the return value of vm native methods to set the return value, (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/date.cc ('k') | lib/error.cc » ('j') | vm/bootstrap_natives.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/double.cc
===================================================================
--- lib/double.cc (revision 11528)
+++ lib/double.cc (working copy)
@@ -17,8 +17,7 @@
DEFINE_NATIVE_ENTRY(Double_doubleFromInteger, 2) {
ASSERT(AbstractTypeArguments::CheckedHandle(arguments->At(0)).IsNull());
const Integer& value = Integer::CheckedHandle(arguments->At(1));
- const Double& result = Double::Handle(Double::New(value.AsDoubleValue()));
- arguments->SetReturn(result);
+ return Double::New(value.AsDoubleValue());
}
@@ -26,8 +25,7 @@
double left = Double::CheckedHandle(arguments->At(0)).value();
GET_NATIVE_ARGUMENT(Double, right_object, arguments->At(1));
double right = right_object.value();
- const Double& result = Double::Handle(Double::New(left + right));
- arguments->SetReturn(result);
+ return Double::New(left + right);
}
@@ -35,8 +33,7 @@
double left = Double::CheckedHandle(arguments->At(0)).value();
GET_NATIVE_ARGUMENT(Double, right_object, arguments->At(1));
double right = right_object.value();
- const Double& result = Double::Handle(Double::New(left - right));
- arguments->SetReturn(result);
+ return Double::New(left - right);
}
@@ -44,8 +41,7 @@
double left = Double::CheckedHandle(arguments->At(0)).value();
GET_NATIVE_ARGUMENT(Double, right_object, arguments->At(1));
double right = right_object.value();
- const Double& result = Double::Handle(Double::New(left * right));
- arguments->SetReturn(result);
+ return Double::New(left * right);
}
@@ -53,8 +49,7 @@
double left = Double::CheckedHandle(arguments->At(0)).value();
GET_NATIVE_ARGUMENT(Double, right_object, arguments->At(1));
double right = right_object.value();
- const Double& result = Double::Handle(Double::New(left / right));
- arguments->SetReturn(result);
+ return Double::New(left / right);
}
@@ -62,8 +57,7 @@
double left = Double::CheckedHandle(arguments->At(0)).value();
GET_NATIVE_ARGUMENT(Double, right_object, arguments->At(1));
double right = right_object.value();
- const Double& result = Double::Handle(Double::New(trunc(left / right)));
- arguments->SetReturn(result);
+ return Double::New(trunc(left / right));
}
@@ -82,8 +76,7 @@
remainder += right;
}
}
- const Double& result = Double::Handle(Double::New(remainder));
- arguments->SetReturn(result);
+ return Double::New(remainder);
}
@@ -91,8 +84,7 @@
double left = Double::CheckedHandle(arguments->At(0)).value();
GET_NATIVE_ARGUMENT(Double, right_object, arguments->At(1));
double right = right_object.value();
- const Double& result = Double::Handle(Double::New(fmod(left, right)));
- arguments->SetReturn(result);
+ return Double::New(fmod(left, right));
}
@@ -100,16 +92,14 @@
const Double& left = Double::CheckedHandle(arguments->At(0));
GET_NATIVE_ARGUMENT(Double, right, arguments->At(1));
bool result = right.IsNull() ? false : (left.value() > right.value());
- arguments->SetReturn(Bool::Handle(Bool::Get(result)));
+ return Bool::Get(result);
}
DEFINE_NATIVE_ENTRY(Double_greaterThanFromInteger, 2) {
const Double& right = Double::CheckedHandle(arguments->At(0));
GET_NATIVE_ARGUMENT(Integer, left, arguments->At(1));
- const Bool& result = Bool::Handle(Bool::Get(
- left.AsDoubleValue() > right.value()));
- arguments->SetReturn(result);
+ return Bool::Get(left.AsDoubleValue() > right.value());
}
@@ -117,38 +107,36 @@
const Double& left = Double::CheckedHandle(arguments->At(0));
GET_NATIVE_ARGUMENT(Double, right, arguments->At(1));
bool result = right.IsNull() ? false : (left.value() == right.value());
- arguments->SetReturn(Bool::Handle(Bool::Get(result)));
+ return Bool::Get(result);
}
DEFINE_NATIVE_ENTRY(Double_equalToInteger, 2) {
const Double& left = Double::CheckedHandle(arguments->At(0));
GET_NATIVE_ARGUMENT(Integer, right, arguments->At(1));
- const Bool& result =
- Bool::Handle(Bool::Get(left.value() == right.AsDoubleValue()));
- arguments->SetReturn(result);
+ return Bool::Get(left.value() == right.AsDoubleValue());
}
DEFINE_NATIVE_ENTRY(Double_round, 1) {
const Double& arg = Double::CheckedHandle(arguments->At(0));
- arguments->SetReturn(Double::Handle(Double::New(round(arg.value()))));
+ return Double::New(round(arg.value()));
}
DEFINE_NATIVE_ENTRY(Double_floor, 1) {
const Double& arg = Double::CheckedHandle(arguments->At(0));
- arguments->SetReturn(Double::Handle(Double::New(floor(arg.value()))));
+ return Double::New(floor(arg.value()));
}
DEFINE_NATIVE_ENTRY(Double_ceil, 1) {
const Double& arg = Double::CheckedHandle(arguments->At(0));
- arguments->SetReturn(Double::Handle(Double::New(ceil(arg.value()))));
+ return Double::New(ceil(arg.value()));
}
DEFINE_NATIVE_ENTRY(Double_truncate, 1) {
const Double& arg = Double::CheckedHandle(arguments->At(0));
- arguments->SetReturn(Double::Handle(Double::New(trunc(arg.value()))));
+ return Double::New(trunc(arg.value()));
}
@@ -156,7 +144,7 @@
const double operand = Double::CheckedHandle(arguments->At(0)).value();
GET_NATIVE_ARGUMENT(Double, exponent_object, arguments->At(1));
const double exponent = exponent_object.value();
- arguments->SetReturn(Double::Handle(Double::New(pow(operand, exponent))));
+ return Double::New(pow(operand, exponent));
}
@@ -175,12 +163,11 @@
}
double result = trunc(arg.value());
if ((Smi::kMinValue <= result) && (result <= Smi::kMaxValue)) {
- arguments->SetReturn(Smi::Handle(Smi::New(static_cast<intptr_t>(result))));
+ return Smi::New(static_cast<intptr_t>(result));
} else if ((Mint::kMinValue <= result) && (result <= Mint::kMaxValue)) {
- arguments->SetReturn(Mint::Handle(Mint::New(static_cast<int64_t>(result))));
+ return Mint::New(static_cast<int64_t>(result));
} else {
- arguments->SetReturn(
- Bigint::Handle(BigintOperations::NewFromDouble(result)));
+ return BigintOperations::NewFromDouble(result);
}
}
@@ -196,14 +183,13 @@
intptr_t fraction_digits_value = fraction_digits.Value();
if (0 <= fraction_digits_value && fraction_digits_value <= 20
&& kLowerBoundary < d && d < kUpperBoundary) {
- String& result = String::Handle();
- result = DoubleToStringAsFixed(d, static_cast<int>(fraction_digits_value));
- arguments->SetReturn(result);
+ return DoubleToStringAsFixed(d, static_cast<int>(fraction_digits_value));
} else {
GrowableArray<const Object*> args;
args.Add(&String::ZoneHandle(String::New(
"Illegal arguments to double.toStringAsFixed")));
Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
+ return Object::null();
}
}
@@ -214,15 +200,14 @@
double d = arg.value();
intptr_t fraction_digits_value = fraction_digits.Value();
if (-1 <= fraction_digits_value && fraction_digits_value <= 20) {
- String& result = String::Handle();
- result = DoubleToStringAsExponential(
+ return DoubleToStringAsExponential(
d, static_cast<int>(fraction_digits_value));
- arguments->SetReturn(result);
} else {
GrowableArray<const Object*> args;
args.Add(&String::ZoneHandle(String::New(
"Illegal arguments to double.toStringAsExponential")));
Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
+ return Object::null();
}
}
@@ -233,46 +218,33 @@
double d = arg.value();
intptr_t precision_value = precision.Value();
if (1 <= precision_value && precision_value <= 21) {
- String& result = String::Handle();
- result = DoubleToStringAsPrecision(d, static_cast<int>(precision_value));
- arguments->SetReturn(result);
+ return DoubleToStringAsPrecision(d, static_cast<int>(precision_value));
} else {
GrowableArray<const Object*> args;
args.Add(&String::ZoneHandle(String::New(
"Illegal arguments to double.toStringAsPrecision")));
Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
+ return Object::null();
}
}
DEFINE_NATIVE_ENTRY(Double_isInfinite, 1) {
const Double& arg = Double::CheckedHandle(arguments->At(0));
- if (isinf(arg.value())) {
- arguments->SetReturn(Bool::Handle(Bool::True()));
- } else {
- arguments->SetReturn(Bool::Handle(Bool::False()));
- }
+ return Bool::Get(isinf(arg.value()));
}
DEFINE_NATIVE_ENTRY(Double_isNaN, 1) {
const Double& arg = Double::CheckedHandle(arguments->At(0));
- if (isnan(arg.value())) {
- arguments->SetReturn(Bool::Handle(Bool::True()));
- } else {
- arguments->SetReturn(Bool::Handle(Bool::False()));
- }
+ return Bool::Get(isnan(arg.value()));
}
DEFINE_NATIVE_ENTRY(Double_isNegative, 1) {
const Double& arg = Double::CheckedHandle(arguments->At(0));
// Include negative zero, infinity.
- if (signbit(arg.value()) && !isnan(arg.value())) {
- arguments->SetReturn(Bool::Handle(Bool::True()));
- } else {
- arguments->SetReturn(Bool::Handle(Bool::False()));
- }
+ return Bool::Get(signbit(arg.value()) && !isnan(arg.value()));
}
// Add here only functions using/referring to old-style casts.
« no previous file with comments | « lib/date.cc ('k') | lib/error.cc » ('j') | vm/bootstrap_natives.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698