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

Unified Diff: lib/math.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/isolate.cc ('k') | lib/mirrors.cc » ('j') | vm/bootstrap_natives.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/math.cc
===================================================================
--- lib/math.cc (revision 11528)
+++ lib/math.cc (working copy)
@@ -18,59 +18,57 @@
DEFINE_NATIVE_ENTRY(MathNatives_sqrt, 1) {
GET_NATIVE_ARGUMENT(Double, operand, arguments->At(0));
- arguments->SetReturn(Double::Handle(Double::New(sqrt(operand.value()))));
+ return Double::New(sqrt(operand.value()));
}
DEFINE_NATIVE_ENTRY(MathNatives_sin, 1) {
GET_NATIVE_ARGUMENT(Double, operand, arguments->At(0));
- arguments->SetReturn(Double::Handle(Double::New(sin(operand.value()))));
+ return Double::New(sin(operand.value()));
}
DEFINE_NATIVE_ENTRY(MathNatives_cos, 1) {
GET_NATIVE_ARGUMENT(Double, operand, arguments->At(0));
- arguments->SetReturn(Double::Handle(Double::New(cos(operand.value()))));
+ return Double::New(cos(operand.value()));
}
DEFINE_NATIVE_ENTRY(MathNatives_tan, 1) {
GET_NATIVE_ARGUMENT(Double, operand, arguments->At(0));
- arguments->SetReturn(Double::Handle(Double::New(tan(operand.value()))));
+ return Double::New(tan(operand.value()));
}
DEFINE_NATIVE_ENTRY(MathNatives_asin, 1) {
GET_NATIVE_ARGUMENT(Double, operand, arguments->At(0));
- arguments->SetReturn(Double::Handle(Double::New(asin(operand.value()))));
+ return Double::New(asin(operand.value()));
}
DEFINE_NATIVE_ENTRY(MathNatives_acos, 1) {
GET_NATIVE_ARGUMENT(Double, operand, arguments->At(0));
- arguments->SetReturn(Double::Handle(Double::New(acos(operand.value()))));
+ return Double::New(acos(operand.value()));
}
DEFINE_NATIVE_ENTRY(MathNatives_atan, 1) {
GET_NATIVE_ARGUMENT(Double, operand, arguments->At(0));
- arguments->SetReturn(Double::Handle(Double::New(atan(operand.value()))));
+ return Double::New(atan(operand.value()));
}
DEFINE_NATIVE_ENTRY(MathNatives_atan2, 2) {
GET_NATIVE_ARGUMENT(Double, operand1, arguments->At(0));
GET_NATIVE_ARGUMENT(Double, operand2, arguments->At(1));
- arguments->SetReturn(Double::Handle(Double::New(
- atan2(operand1.value(), operand2.value()))));
+ return Double::New(atan2(operand1.value(), operand2.value()));
}
DEFINE_NATIVE_ENTRY(MathNatives_exp, 1) {
GET_NATIVE_ARGUMENT(Double, operand, arguments->At(0));
- arguments->SetReturn(Double::Handle(Double::New(exp(operand.value()))));
+ return Double::New(exp(operand.value()));
}
DEFINE_NATIVE_ENTRY(MathNatives_log, 1) {
GET_NATIVE_ARGUMENT(Double, operand, arguments->At(0));
- arguments->SetReturn(Double::Handle(Double::New(log(operand.value()))));
+ return Double::New(log(operand.value()));
}
DEFINE_NATIVE_ENTRY(MathNatives_random, 0) {
- arguments->SetReturn(Double::Handle(Double::
- New(static_cast<double>(Random::RandomInt32()-1)/0x80000000)));
+ return Double::New(static_cast<double>(Random::RandomInt32()-1)/0x80000000);
}
@@ -111,20 +109,19 @@
String* int_string;
bool is_positive;
if (IsValidLiteral(tokens, Token::kINTEGER, &is_positive, &int_string)) {
- Integer& result = Integer::Handle();
if (is_positive) {
- result = Integer::New(*int_string);
+ return Integer::New(*int_string);
} else {
String& temp = String::Handle();
temp = String::Concat(String::Handle(Symbols::New("-")),
*int_string);
- result = Integer::New(temp);
+ return Integer::New(temp);
}
- arguments->SetReturn(result);
} else {
GrowableArray<const Object*> args;
args.Add(&value);
Exceptions::ThrowByType(Exceptions::kFormat, args);
+ return Object::null();
}
}
@@ -143,40 +140,36 @@
if (!is_positive) {
double_value = -double_value;
}
- Double& result = Double::Handle(Double::New(double_value));
- arguments->SetReturn(result);
- return;
+ return Double::New(double_value);
}
if (IsValidLiteral(tokens, Token::kINTEGER, &is_positive, &number_string)) {
Integer& res = Integer::Handle(Integer::New(*number_string));
if (is_positive) {
- arguments->SetReturn(Double::Handle(Double::New(res.AsDoubleValue())));
+ return Double::New(res.AsDoubleValue());
} else {
- arguments->SetReturn(Double::Handle(Double::New(-res.AsDoubleValue())));
+ return Double::New(-res.AsDoubleValue());
}
- return;
}
// Infinity and nan.
if (IsValidLiteral(tokens, Token::kIDENT, &is_positive, &number_string)) {
if (number_string->Equals("NaN")) {
- arguments->SetReturn(Double::Handle(Double::New(NAN)));
- return;
+ return Double::New(NAN);
}
if (number_string->Equals("Infinity")) {
if (is_positive) {
- arguments->SetReturn(Double::Handle(Double::New(INFINITY)));
+ return Double::New(INFINITY);
} else {
- arguments->SetReturn(Double::Handle(Double::New(-INFINITY)));
+ return Double::New(-INFINITY);
}
- return;
}
}
GrowableArray<const Object*> args;
args.Add(&value);
Exceptions::ThrowByType(Exceptions::kFormat, args);
+ return Object::null();
}
} // namespace dart
« no previous file with comments | « lib/isolate.cc ('k') | lib/mirrors.cc » ('j') | vm/bootstrap_natives.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698