Mate.hs now uses lately introduced Utilities lookupMethod
authorHarald Steinlechner <haraldsteinlechner@gmail.com>
Tue, 27 Mar 2012 19:07:59 +0000 (21:07 +0200)
committerHarald Steinlechner <haraldsteinlechner@gmail.com>
Tue, 27 Mar 2012 19:07:59 +0000 (21:07 +0200)
Makefile
Mate.hs

index 7bc23cfc42fe8bf023ba07e6cb825eab0ecbd8b9..191b3cce97b5e30abb9b32e5732c426f96ee1669 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ all: mate Test.class
 %.class: %.java
        javac $<
 
-mate: Mate.hs trap.c
+mate: Mate.hs Utilities.hs trap.c
        ghc --make -Wall -O2 $^ -o $@
 
 clean:
diff --git a/Mate.hs b/Mate.hs
index 3fcfca5c04e4c2056adfc4028083a565cfd06079..c32a446fce509aba096dffa943d1cc972eb24f19 100644 (file)
--- a/Mate.hs
+++ b/Mate.hs
@@ -27,6 +27,7 @@ import Foreign.C.Types
 import Harpy
 import Harpy.X86Disassembler
 
+import Utilities
 
 foreign import ccall "dynamic"
    code_void :: FunPtr (CInt -> IO CInt) -> (CInt -> IO CInt)
@@ -69,8 +70,11 @@ runstuff env bytecode = do
           (_, Right ((entryPtr, endOffset), disasm)) <- runCodeGen emittedcode env ()
           printf "entry point: 0x%08x\n" ((fromIntegral $ ptrToIntPtr entryPtr) :: Int)
 
+          
           let entryFuncPtr = ((castPtrToFunPtr entryPtr) :: FunPtr (CInt -> IO CInt))
+          printf "got ptr\n"
           result <- code_void entryFuncPtr (fromIntegral 0x1337)
+          printf "called code_void\n"
           let iresult::Int; iresult = fromIntegral result
           printf "result: 0x%08x\n" iresult -- expecting (2 * 0x1337) + 0x42 = 0x26b0
 
@@ -135,11 +139,3 @@ compile_ins IMUL = do nop
 compile_ins RETURN = do nop
 compile_ins _ = do nop
 
--- TODO: actually this function already exists in hs-java-0.3!
-lookupMethod :: B.ByteString -> Class Resolved -> Maybe (Method Resolved)
-lookupMethod name cls = look (classMethods cls)
-  where
-    look [] = Nothing
-    look (f:fs)
-      | methodName f == name = Just f
-      | otherwise  = look fs