bb_offset <- getCodeOffset
let bbstarts' = M.insert bid bb_offset bbstarts
defineLabel $ getLabel bid lmap
- cs <- mapM emit' $ code bb
+ cs <- mapM emit'' $ code bb
let calls' = calls `M.union` M.fromList (catMaybes cs)
case successor bb of
Return -> return (calls', bbstarts')
let imm8 = is8BitOffset offset
return $ Just (calladdr + (if imm8 then 3 else 6), trapcause imm8)
+ emit'' :: J.Instruction -> CodeGen e s (Maybe (Word32, TrapCause))
+ emit'' insn = newNamedLabel ("jvm_insn: " ++ show insn) >>= defineLabel >> emit' insn
+
emit' :: J.Instruction -> CodeGen e s (Maybe (Word32, TrapCause))
emit' (INVOKESPECIAL cpidx) = emitInvoke cpidx True
emit' (INVOKESTATIC cpidx) = emitInvoke cpidx False
package tests;
public class WhileArray1 {
+ public char arr[] = new char[10];
+
public static void main(String args[]) {
- char a[] = new char[10];
- char b[] = new char[10];
+ WhileArray1 a = new WhileArray1();
+ WhileArray1 b = new WhileArray1();
for (int i = 0; i < 10; i++) {
- a[i] = b[i] = (char) i;
+ a.arr[i] = b.arr[i] = (char) i;
}
- System.out.printf("success? %d\n", equal(a, b, 5) ? 1 : 0);
+ System.out.printf("success? %d\n", equal(a, b, 10) ? 1 : 0);
for (int i = 0; i < 10; i++) {
- b[i] = (char) i;
- a[i] = (char) (b[i] + 2);
+ b.arr[i] = (char) i;
+ a.arr[i] = (char) (b.arr[i] + 2);
}
- System.out.printf("success? %d\n", equal(a, b, 5) ? 1 : 0);
+ System.out.printf("success? %d\n", equal(a, b, 10) ? 1 : 0);
}
- public static boolean equal(char[] a, char[] b, int len) {
+ public static boolean equal(WhileArray1 a, WhileArray1 b, int len) {
/* stolen from the equals implementation of java.lang.String of
* GNU Classpath */
int x = 0, y = 0;
while (--len >= 0) {
System.out.printf("idx: x: %d, y: %d\n", x, y);
- if (a[x++] != b[y++]) {
+ if (a.arr[x++] != b.arr[y++]) {
return false;
}
}