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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 509153003: New bigint implementation in the vm. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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
Index: runtime/vm/dart_api_impl.cc
===================================================================
--- runtime/vm/dart_api_impl.cc (revision 40060)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -7,7 +7,6 @@
#include "include/dart_native_api.h"
#include "platform/assert.h"
-#include "vm/bigint_operations.h"
#include "vm/class_finalizer.h"
#include "vm/compiler.h"
#include "vm/dart.h"
@@ -148,8 +147,8 @@
intptr_t cid = obj.GetClassId();
if (cid == kBigintCid) {
const Bigint& bigint = Bigint::Cast(obj);
- if (BigintOperations::FitsIntoInt64(bigint)) {
- *value = BigintOperations::ToInt64(bigint);
+ if (bigint.FitsIntoInt64()) {
+ *value = bigint.AsInt64Value();
return true;
}
}
@@ -174,8 +173,8 @@
intptr_t cid = obj.GetClassId();
if (cid == kBigintCid) {
const Bigint& bigint = Bigint::Cast(obj);
- if (BigintOperations::FitsIntoUint64(bigint)) {
- *value = BigintOperations::ToUint64(bigint);
+ if (bigint.FitsIntoUint64()) {
+ *value = bigint.AsUint64Value();
return true;
}
}
@@ -884,8 +883,8 @@
}
if (result.IsBigint()) {
const Bigint& bigint = Bigint::Cast(result);
- if (BigintOperations::FitsIntoUint64(bigint)) {
- return BigintOperations::ToUint64(bigint);
+ if (bigint.FitsIntoUint64()) {
+ return bigint.AsUint64Value();
}
}
return 0;
@@ -1906,7 +1905,7 @@
if (int_obj.IsNull()) {
RETURN_TYPE_ERROR(isolate, integer, Integer);
}
- ASSERT(!BigintOperations::FitsIntoInt64(Bigint::Cast(int_obj)));
+ ASSERT(!Bigint::Cast(int_obj).FitsIntoInt64());
*fits = false;
return Api::Success();
}
@@ -1931,7 +1930,7 @@
if (int_obj.IsMint()) {
*fits = !int_obj.IsNegative();
} else {
- *fits = BigintOperations::FitsIntoUint64(Bigint::Cast(int_obj));
+ *fits = Bigint::Cast(int_obj).FitsIntoUint64();
}
return Api::Success();
}
@@ -1982,8 +1981,8 @@
return Api::Success();
} else {
const Bigint& bigint = Bigint::Cast(int_obj);
- if (BigintOperations::FitsIntoInt64(bigint)) {
- *value = BigintOperations::ToInt64(bigint);
+ if (bigint.FitsIntoInt64()) {
+ *value = bigint.AsInt64Value();
return Api::Success();
}
}
@@ -2016,8 +2015,8 @@
return Api::Success();
} else {
const Bigint& bigint = Bigint::Cast(int_obj);
- if (BigintOperations::FitsIntoUint64(bigint)) {
- *value = BigintOperations::ToUint64(bigint);
+ if (bigint.FitsIntoUint64()) {
+ *value = bigint.AsUint64Value();
return Api::Success();
}
}
@@ -2041,11 +2040,10 @@
}
if (int_obj.IsSmi() || int_obj.IsMint()) {
const Bigint& bigint = Bigint::Handle(isolate,
- BigintOperations::NewFromInt64(int_obj.AsInt64Value()));
- *value = BigintOperations::ToHexCString(bigint, BigintAllocate);
+ Bigint::NewFromInt64(int_obj.AsInt64Value()));
+ *value = bigint.ToHexCString(BigintAllocate);
} else {
- *value = BigintOperations::ToHexCString(Bigint::Cast(int_obj),
- BigintAllocate);
+ *value = Bigint::Cast(int_obj).ToHexCString(BigintAllocate);
}
return Api::Success();
}
@@ -2485,7 +2483,7 @@
// Check for a non-canonical Mint range value.
ASSERT(retval.IsBigint());
const Bigint& bigint = Bigint::Handle();
- if (BigintOperations::FitsIntoInt64(bigint)) {
+ if (bigint.FitsIntoInt64()) {
int64_t bigint_value = bigint.AsInt64Value();
if (bigint_value >= kIntptrMin && bigint_value <= kIntptrMax) {
*len = static_cast<intptr_t>(bigint_value);

Powered by Google App Engine
This is Rietveld 408576698