| Index: dart/runtime/lib/bigint.dart
|
| ===================================================================
|
| --- dart/runtime/lib/bigint.dart (revision 42037)
|
| +++ dart/runtime/lib/bigint.dart (working copy)
|
| @@ -66,9 +66,9 @@
|
|
|
| // Internal data structure.
|
| bool get _neg native "Bigint_getNeg";
|
| - void set _neg(bool neg) native "Bigint_setNeg";
|
| + void set _neg(bool value) native "Bigint_setNeg";
|
| int get _used native "Bigint_getUsed";
|
| - void set _used(int used) native "Bigint_setUsed";
|
| + void set _used(int value) native "Bigint_setUsed";
|
| Uint32List get _digits native "Bigint_getDigits";
|
| void set _digits(Uint32List digits) {
|
| // The VM expects digits_ to be a Uint32List.
|
| @@ -76,7 +76,7 @@
|
| _set_digits(digits);
|
| }
|
|
|
| - void _set_digits(Uint32List digits) native "Bigint_setDigits";
|
| + void _set_digits(Uint32List value) native "Bigint_setDigits";
|
|
|
| // Factory returning an instance initialized to value 0.
|
| factory _Bigint() native "Bigint_allocate";
|
| @@ -1118,6 +1118,41 @@
|
| bool get isEven => _used == 0 || (_digits[0] & 1) == 0;
|
| bool get isNegative => _neg;
|
|
|
| + String _toPow2String(int radix) {
|
| + if (_used == 0) return "0";
|
| + assert(radix & (radix - 1) == 0);
|
| + final bitsPerChar = radix.bitLength - 1;
|
| + final firstcx = _neg ? 1 : 0; // Index of first char in str after the sign.
|
| + final lastdx = _used - 1; // Index of last digit in bigint.
|
| + final bitLength = lastdx*DIGIT_BITS + _nbits(_digits[lastdx]);
|
| + // Index of char in str. Initialize with str length.
|
| + var cx = firstcx + (bitLength + bitsPerChar - 1) ~/ bitsPerChar;
|
| + _OneByteString str = _OneByteString._allocate(cx);
|
| + str._setAt(0, 0x2d); // '-'. Is overwritten if not negative.
|
| + final mask = radix - 1;
|
| + var dx = 0; // Digit index in bigint.
|
| + var bx = 0; // Bit index in bigint digit.
|
| + do {
|
| + var ch;
|
| + if (bx > (DIGIT_BITS - bitsPerChar)) {
|
| + ch = _digits[dx++] >> bx;
|
| + bx += bitsPerChar - DIGIT_BITS;
|
| + if (dx <= lastdx) {
|
| + ch |= (_digits[dx] & ((1 << bx) - 1)) << (bitsPerChar - bx);
|
| + }
|
| + } else {
|
| + ch = (_digits[dx] >> bx) & mask;
|
| + bx += bitsPerChar;
|
| + if (bx >= DIGIT_BITS) {
|
| + bx -= DIGIT_BITS;
|
| + dx++;
|
| + }
|
| + }
|
| + str._setAt(--cx, _IntegerImplementation._digits.codeUnitAt(ch));
|
| + } while (cx > firstcx);
|
| + return str;
|
| + }
|
| +
|
| _leftShiftWithMask32(int count, int mask) {
|
| if (_used == 0) return 0;
|
| if (count is! _Smi) {
|
|
|