Index: runtime/lib/integers.dart |
diff --git a/runtime/lib/integers.dart b/runtime/lib/integers.dart |
index dca7ef8434670a2934ac7a1de4e2777691e00248..31a71fb884a062ffe3afe0903aa5719490e31f3a 100644 |
--- a/runtime/lib/integers.dart |
+++ b/runtime/lib/integers.dart |
@@ -95,6 +95,15 @@ class _IntegerImplementation { |
bool get isNegative => this < 0; |
bool get isInfinite => false; |
+ int toUnsigned(int width) { |
+ return this & ((1 << width) - 1); |
+ } |
+ |
+ int toSigned(int width) { |
+ int signMask = 1 << (width - 1); |
+ return (this & (signMask - 1)) - (this & signMask); |
Lasse Reichstein Nielsen
2013/09/06 12:40:11
Clever. I don't see a good way to document why thi
sra1
2013/09/06 22:11:57
I'll give it a shot.
|
+ } |
+ |
int compareTo(num other) { |
final int EQUAL = 0, LESS = -1, GREATER = 1; |
if (other is double) { |
@@ -212,6 +221,8 @@ class _Smi extends _IntegerImplementation implements int { |
return this; |
} |
int operator ~() native "Smi_bitNegate"; |
+ int get bitLength native "Smi_bitLength"; |
+ |
int _shrFromInt(int other) native "Smi_shrFromInt"; |
int _shlFromInt(int other) native "Smi_shlFromInt"; |
@@ -252,6 +263,7 @@ class _Mint extends _IntegerImplementation implements int { |
return this; |
} |
int operator ~() native "Mint_bitNegate"; |
+ int get bitLength native "Mint_bitLength"; |
// Shift by mint exceeds range that can be handled by the VM. |
int _shrFromInt(int other) { |
@@ -275,6 +287,7 @@ class _Bigint extends _IntegerImplementation implements int { |
return this; |
} |
int operator ~() native "Bigint_bitNegate"; |
+ int get bitLength native "Bigint_bitLength"; |
// Shift by bigint exceeds range that can be handled by the VM. |
int _shrFromInt(int other) { |