# HG changeset patch # User Lubomir Nerad # Date 1360242472 -3600 # Node ID 873df84db4f7a0b1bde592a00bb32eb432cab854 # Parent bb50e2b5ac0b8e21dc174625b47d37dcfa3b0799 Fixed iinc_w's incrBy value offset diff -r bb50e2b5ac0b -r 873df84db4f7 vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java --- a/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Thu Feb 07 13:32:13 2013 +0100 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Thu Feb 07 14:07:52 2013 +0100 @@ -631,7 +631,7 @@ final int varIndx = wide ? readUShort(byteCodes, i++) : readUByte(byteCodes, i); ++i; - final int incrBy = wide ? readIntArg(byteCodes, i++) + final int incrBy = wide ? readShort(byteCodes, i++) : byteCodes[i]; wide = false; if (incrBy == 1) { @@ -1344,20 +1344,25 @@ final int indxLo = byteCodes[offsetInstruction + 2]; return (indxHi & 0xffffff00) | (indxLo & 0xff); } - private int readInt4(byte[] byteCodes, int offsetInstruction) { - final int d = byteCodes[offsetInstruction + 0] << 24; - final int c = byteCodes[offsetInstruction + 1] << 16; - final int b = byteCodes[offsetInstruction + 2] << 8; - final int a = byteCodes[offsetInstruction + 3]; + private int readInt4(byte[] byteCodes, int offset) { + final int d = byteCodes[offset + 0] << 24; + final int c = byteCodes[offset + 1] << 16; + final int b = byteCodes[offset + 2] << 8; + final int a = byteCodes[offset + 3]; return (d & 0xff000000) | (c & 0xff0000) | (b & 0xff00) | (a & 0xff); } - private int readUByte(byte[] byteCodes, int offsetInstruction) { - return byteCodes[offsetInstruction] & 0xff; + private int readUByte(byte[] byteCodes, int offset) { + return byteCodes[offset] & 0xff; } - private int readUShort(byte[] byteCodes, int offsetInstruction) { - return ((byteCodes[offsetInstruction] & 0xff) << 8) - | (byteCodes[offsetInstruction + 1] & 0xff); + private int readUShort(byte[] byteCodes, int offset) { + return ((byteCodes[offset] & 0xff) << 8) + | (byteCodes[offset + 1] & 0xff); + } + + private int readShort(byte[] byteCodes, int offset) { + return (byteCodes[offset] << 8) + | (byteCodes[offset + 1] & 0xff); } private static void countArgs(String descriptor, char[] returnType, StringBuilder sig, StringBuilder cnt) {