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

Unified Diff: runtime/bin/dartutils.h

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
« no previous file with comments | « no previous file | runtime/bin/dartutils.cc » ('j') | runtime/lib/bigint.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/dartutils.h
===================================================================
--- runtime/bin/dartutils.h (revision 40060)
+++ runtime/bin/dartutils.h (working copy)
@@ -268,12 +268,14 @@
static Dart_CObject* NewInt32(int32_t value);
static Dart_CObject* NewInt64(int64_t value);
static Dart_CObject* NewIntptr(intptr_t value);
- // TODO(sgjesse): Add support for kBigint.
+ static Dart_CObject* NewBigint(const char* hex_value);
+ static char* BigintToHexValue(Dart_CObject* bigint);
static Dart_CObject* NewDouble(double value);
static Dart_CObject* NewString(intptr_t length);
static Dart_CObject* NewString(const char* str);
static Dart_CObject* NewArray(intptr_t length);
static Dart_CObject* NewUint8Array(intptr_t length);
+ static Dart_CObject* NewUint32Array(intptr_t length);
static Dart_CObject* NewExternalUint8Array(
intptr_t length, uint8_t* data, void* peer,
Dart_WeakPersistentHandleFinalizer callback);
@@ -416,11 +418,33 @@
class CObjectBigint : public CObject {
public:
- DECLARE_COBJECT_CONSTRUCTORS(Bigint)
+ // DECLARE_COBJECT_CONSTRUCTORS(Bigint) would miss hex_value_ initialization.
+ explicit CObjectBigint(Dart_CObject *cobject) : CObject(cobject) {
+ ASSERT(type() == Dart_CObject_kBigint);
+ cobject_ = cobject;
+ hex_value_ = NULL;
+ }
+ explicit CObjectBigint(CObject* cobject) : CObject() {
+ ASSERT(cobject != NULL);
+ ASSERT(cobject->type() == Dart_CObject_kBigint);
+ cobject_ = cobject->AsApiCObject();
+ hex_value_ = NULL;
+ }
- char* Value() const { return cobject_->value.as_bigint; }
+ char* Value() {
+ if (hex_value_ == NULL) {
+ hex_value_ = BigintToHexValue(cobject_);
+ }
+ ASSERT(hex_value_ != NULL);
+ return hex_value_;
+ }
+ ~CObjectBigint() {
+ free(hex_value_);
+ }
+
private:
+ char* hex_value_;
DISALLOW_COPY_AND_ASSIGN(CObjectBigint);
};
« no previous file with comments | « no previous file | runtime/bin/dartutils.cc » ('j') | runtime/lib/bigint.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698