SHELL := bash
JAVAC := javac
-JAVA_FILES := $(wildcard tests/*.java)
+JAVA_FILES := $(wildcard tests/*.java java/lang/*.java java/io/*.java)
CLASS_FILES := $(JAVA_FILES:.java=.class)
HS_FILES := $(wildcard Mate/*.hs)
HS_BOOT := $(wildcard Mate/*.hs-boot)
@printf "should be: 0x%08x 0x%08x\n" 0x33 0x44
./$< tests/Instance4 | grep mainresult
@printf "should be: 0x%08x 0x%08x\n" 0x1337 0x1337
+ ./$< tests/Native2 | grep "printstream"
+ @printf "should be: 0x%08x\n" 0x1337
%.class: %.java
$(JAVAC) $<
IF_ICMP _ w16 -> twotargets w16
GOTO w16 -> onetarget w16
IRETURN -> notarget
+ ARETURN -> notarget
RETURN -> notarget
_ -> ((off, Nothing), x):next
where
methodHaveReturnValue cls idx = case ret of
ReturnsVoid -> False;
(Returns IntType) -> True;
+ (Returns (ObjectType _)) -> True;
_ -> error "methodHaveReturnValue: todo"
where
(CMethod _ nt) = (constsPool cls) M.! idx
jmp $ getLabel sid lmap
emit RETURN = do mov esp ebp; pop ebp; ret
+ emit ARETURN = emit IRETURN
emit IRETURN = do
pop eax
mov esp ebp
{
printf("printX: 0x%08x\n", a);
}
+
+void java_io_PrintStream__printf___I_V(int a)
+{
+ printf("printstream: 0x%08x\n", a);
+}
--- /dev/null
+package java.io;
+
+public class PrintStream {
+ public native void printf(int a);
+ public native void println(String a);
+}
--- /dev/null
+package java.lang;
+
+import java.io.*;
+
+public class System {
+ public static PrintStream out = new PrintStream();
+}
--- /dev/null
+package tests;
+
+public class Native2 {
+ public static void main(String []args) {
+ System.out.printf(0x1337);
+ }
+}