1.1 --- a/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js Thu Jan 31 15:26:09 2013 +0100
1.2 +++ b/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js Thu Jan 31 20:19:38 2013 +0100
1.3 @@ -91,6 +91,7 @@
1.4
1.5 Number.prototype.and64 = function(x) {
1.6 var low = this & x;
1.7 + low += (low < 0) ? (__m32+1) : 0;
1.8 if (this.hi && x.hi) {
1.9 var hi = this.hi & x.hi;
1.10 return hi.next32(low);
1.11 @@ -98,6 +99,16 @@
1.12 return low;
1.13 };
1.14
1.15 +Number.prototype.or64 = function(x) {
1.16 + var low = this | x;
1.17 + low += (low < 0) ? (__m32+1) : 0;
1.18 + if (this.hi || x.hi) {
1.19 + var hi = this.hi | x.hi;
1.20 + return hi.next32(low);
1.21 + };
1.22 + return low;
1.23 +};
1.24 +
1.25 Number.prototype.shl64 = function(x) {
1.26 if (x >= 32) {
1.27 var hi = (this << (x - 32)) | 0;
2.1 --- a/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Thu Jan 31 15:26:09 2013 +0100
2.2 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Thu Jan 31 20:19:38 2013 +0100
2.3 @@ -588,7 +588,7 @@
2.4 emit(out, "@1 |= @2;", smapper.getI(1), smapper.popI());
2.5 break;
2.6 case opc_lor:
2.7 - emit(out, "@1 |= @2;", smapper.getL(1), smapper.popL());
2.8 + emit(out, "@1 = @1.or64(@2);", smapper.getL(1), smapper.popL());
2.9 break;
2.10 case opc_ixor:
2.11 emit(out, "@1 ^= @2;", smapper.getI(1), smapper.popI());
3.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java Thu Jan 31 15:26:09 2013 +0100
3.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java Thu Jan 31 20:19:38 2013 +0100
3.3 @@ -255,6 +255,26 @@
3.4 45);
3.5 }
3.6
3.7 + @Test public void longAnd() throws Exception {
3.8 + final long res = 0x00fa37d7763e0ca1l & 0xa7b3432fff00123el;
3.9 + assertExec("LOng binary AND",
3.10 + Numbers.class, "andL__J_3B_3B",
3.11 + Double.valueOf(res),
3.12 + new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
3.13 + new byte[] { (byte)0xa7, (byte)0xb3, (byte)0x43, (byte)0x2f, (byte)0xff, (byte)0x00, (byte)0x12, (byte)0x3e }
3.14 + );
3.15 + }
3.16 +
3.17 + @Test public void longOr() throws Exception {
3.18 + final long res = 0x00fa37d7763e0ca1l | 0xa7b3432fff00123el;
3.19 + assertExec("Long binary OR",
3.20 + Numbers.class, "orL__J_3B_3B",
3.21 + Double.valueOf(res),
3.22 + new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
3.23 + new byte[] { (byte)0xa7, (byte)0xb3, (byte)0x43, (byte)0x2f, (byte)0xff, (byte)0x00, (byte)0x12, (byte)0x3e }
3.24 + );
3.25 + }
3.26 +
3.27 private static CharSequence codeSeq;
3.28 private static Invocable code;
3.29
4.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/Numbers.java Thu Jan 31 15:26:09 2013 +0100
4.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/Numbers.java Thu Jan 31 20:19:38 2013 +0100
4.3 @@ -111,4 +111,20 @@
4.4 DataInputStream disValue = new DataInputStream(isValue);
4.5 return (disValue.readLong() >> nBits);
4.6 }
4.7 +
4.8 + public static long andL(byte[] arrX, byte[] arrY) throws IOException {
4.9 + ByteArrayInputStream isX = new ByteArrayInputStream(arrX);
4.10 + DataInputStream disX = new DataInputStream(isX);
4.11 + ByteArrayInputStream isY = new ByteArrayInputStream(arrY);
4.12 + DataInputStream disY = new DataInputStream(isY);
4.13 + return (disX.readLong() & disY.readLong());
4.14 + }
4.15 +
4.16 + public static long orL(byte[] arrX, byte[] arrY) throws IOException {
4.17 + ByteArrayInputStream isX = new ByteArrayInputStream(arrX);
4.18 + DataInputStream disX = new DataInputStream(isX);
4.19 + ByteArrayInputStream isY = new ByteArrayInputStream(arrY);
4.20 + DataInputStream disY = new DataInputStream(isY);
4.21 + return (disX.readLong() | disY.readLong());
4.22 + }
4.23 }