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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/bin/dartutils.cc » ('j') | runtime/bin/dartutils.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef BIN_DARTUTILS_H_ 5 #ifndef BIN_DARTUTILS_H_
6 #define BIN_DARTUTILS_H_ 6 #define BIN_DARTUTILS_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "include/dart_native_api.h" 9 #include "include/dart_native_api.h"
10 10
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 return Dart_ScopeAllocate(size); 261 return Dart_ScopeAllocate(size);
262 } 262 }
263 263
264 static CObject* Null(); 264 static CObject* Null();
265 static CObject* True(); 265 static CObject* True();
266 static CObject* False(); 266 static CObject* False();
267 static CObject* Bool(bool value); 267 static CObject* Bool(bool value);
268 static Dart_CObject* NewInt32(int32_t value); 268 static Dart_CObject* NewInt32(int32_t value);
269 static Dart_CObject* NewInt64(int64_t value); 269 static Dart_CObject* NewInt64(int64_t value);
270 static Dart_CObject* NewIntptr(intptr_t value); 270 static Dart_CObject* NewIntptr(intptr_t value);
271 // TODO(sgjesse): Add support for kBigint. 271 static Dart_CObject* NewBigint(const char* hex_value);
272 static char* BigintToHexValue(Dart_CObject* bigint);
272 static Dart_CObject* NewDouble(double value); 273 static Dart_CObject* NewDouble(double value);
273 static Dart_CObject* NewString(intptr_t length); 274 static Dart_CObject* NewString(intptr_t length);
274 static Dart_CObject* NewString(const char* str); 275 static Dart_CObject* NewString(const char* str);
275 static Dart_CObject* NewArray(intptr_t length); 276 static Dart_CObject* NewArray(intptr_t length);
276 static Dart_CObject* NewUint8Array(intptr_t length); 277 static Dart_CObject* NewUint8Array(intptr_t length);
278 static Dart_CObject* NewUint32Array(intptr_t length);
277 static Dart_CObject* NewExternalUint8Array( 279 static Dart_CObject* NewExternalUint8Array(
278 intptr_t length, uint8_t* data, void* peer, 280 intptr_t length, uint8_t* data, void* peer,
279 Dart_WeakPersistentHandleFinalizer callback); 281 Dart_WeakPersistentHandleFinalizer callback);
280 282
281 static Dart_CObject* NewIOBuffer(int64_t length); 283 static Dart_CObject* NewIOBuffer(int64_t length);
282 static void FreeIOBufferData(Dart_CObject* object); 284 static void FreeIOBufferData(Dart_CObject* object);
283 285
284 Dart_CObject* AsApiCObject() { return cobject_; } 286 Dart_CObject* AsApiCObject() { return cobject_; }
285 287
286 // Create a new CObject array with an illegal arguments error. 288 // Create a new CObject array with an illegal arguments error.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 413
412 private: 414 private:
413 DISALLOW_COPY_AND_ASSIGN(CObjectIntptr); 415 DISALLOW_COPY_AND_ASSIGN(CObjectIntptr);
414 }; 416 };
415 417
416 418
417 class CObjectBigint : public CObject { 419 class CObjectBigint : public CObject {
418 public: 420 public:
419 DECLARE_COBJECT_CONSTRUCTORS(Bigint) 421 DECLARE_COBJECT_CONSTRUCTORS(Bigint)
420 422
421 char* Value() const { return cobject_->value.as_bigint; } 423 char* Value() {
424 if (hex_value_ == NULL) {
425 hex_value_ = BigintToHexValue(cobject_);
426 }
427 ASSERT(hex_value_ != NULL);
428 return hex_value_;
429 }
430
431 ~CObjectBigint() {
432 free(hex_value_);
433 }
422 434
423 private: 435 private:
436 char* hex_value_;
424 DISALLOW_COPY_AND_ASSIGN(CObjectBigint); 437 DISALLOW_COPY_AND_ASSIGN(CObjectBigint);
425 }; 438 };
426 439
427 440
428 class CObjectDouble : public CObject { 441 class CObjectDouble : public CObject {
429 public: 442 public:
430 DECLARE_COBJECT_CONSTRUCTORS(Double) 443 DECLARE_COBJECT_CONSTRUCTORS(Double)
431 444
432 double Value() const { return cobject_->value.as_double; } 445 double Value() const { return cobject_->value.as_double; }
433 446
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 553
541 ~ScopedBlockingCall() { 554 ~ScopedBlockingCall() {
542 Dart_IsolateUnblocked(); 555 Dart_IsolateUnblocked();
543 } 556 }
544 }; 557 };
545 558
546 } // namespace bin 559 } // namespace bin
547 } // namespace dart 560 } // namespace dart
548 561
549 #endif // BIN_DARTUTILS_H_ 562 #endif // BIN_DARTUTILS_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/dartutils.cc » ('j') | runtime/bin/dartutils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698