hs-java: upgrade to 0.3.1
authorBernhard Urban <lewurm@gmail.com>
Sat, 19 May 2012 13:56:18 +0000 (15:56 +0200)
committerBernhard Urban <lewurm@gmail.com>
Sat, 19 May 2012 13:56:18 +0000 (15:56 +0200)
0.3 has JAR support, so stay tuned \o/

Mate.hs
Mate/BasicBlocks.hs
Mate/ClassPool.hs
Mate/MethodPool.hs
Mate/Strings.hs
Mate/Types.hs
Mate/Utilities.hs
Mate/X86CodeGen.hs
mate.cabal
tools/installhaskellenv.sh

diff --git a/Mate.hs b/Mate.hs
index d60df06367cd69bc5c6e85d00bff3940acef3c26..911c1dbd1c1ef1b892a511c65835f3e3c73537e9 100644 (file)
--- a/Mate.hs
+++ b/Mate.hs
@@ -30,7 +30,7 @@ main = do
       hmap <- parseMethod cls "main"
       case hmap of
         Just hmap' -> do
-          let methods = classMethods cls; methods :: [Method Resolved]
+          let methods = classMethods cls; methods :: [Method Direct]
           let method = find (\x -> methodName x == "main") methods
           case method of
             Just m -> do
index 3c0b93cfef82b9380aedce1f04aedeceaae0bdf1..b52f22d2c4a9e4b5f246f408572784613d67cf4e 100644 (file)
@@ -24,7 +24,6 @@ import JVM.ClassFile
 import JVM.Converter
 import JVM.Assembler
 
-import Mate.Utilities
 import Mate.Types
 import Mate.Debug
 
@@ -86,7 +85,7 @@ test_04 = testInstance "./tests/Fac.class" "fac"
 #endif
 
 
-parseMethod :: Class Resolved -> B.ByteString -> IO (Maybe MapBB)
+parseMethod :: Class Direct -> B.ByteString -> IO (Maybe MapBB)
 parseMethod cls method = do
                      let maybe_bb = testCFG $ lookupMethod method cls
                      let msig = methodSignature $ classMethods cls !! 1
@@ -104,7 +103,7 @@ parseMethod cls method = do
                      return maybe_bb
 
 
-testCFG :: Maybe (Method Resolved) -> Maybe MapBB
+testCFG :: Maybe (Method Direct) -> Maybe MapBB
 testCFG (Just m) = case attrByName m "Code" of
        Nothing -> Nothing
        Just bytecode -> Just $ buildCFG $ codeInstructions $ decodeMethod bytecode
index 216194709978fc72a8107c284629a0a9e4aa2e69..f9f103829bbb3117affd5d06c7a8ebb814c5b296 100644 (file)
@@ -38,7 +38,6 @@ import JVM.Converter
 import Mate.BasicBlocks
 import {-# SOURCE #-} Mate.MethodPool
 import Mate.Types
-import Mate.Utilities
 import Mate.Debug
 import Mate.GarbageAlloc
 
@@ -49,7 +48,7 @@ getClassInfo path = do
     Nothing -> loadAndInitClass path
     Just ci -> return ci
 
-getClassFile :: B.ByteString -> IO (Class Resolved)
+getClassFile :: B.ByteString -> IO (Class Direct)
 getClassFile path = do
   ci <- getClassInfo path
   return $ ciFile ci
@@ -183,7 +182,7 @@ loadInterface path = do
   getname p y = p `B.append` methodName y `B.append` encode (methodSignature y)
 
 
-calculateFields :: Class Resolved -> Maybe ClassInfo -> IO (FieldMap, FieldMap)
+calculateFields :: Class Direct -> Maybe ClassInfo -> IO (FieldMap, FieldMap)
 calculateFields cf superclass = do
     -- TODO(bernhard): correct sizes. int only atm
 
@@ -212,7 +211,7 @@ getsupermap :: Maybe ClassInfo -> (ClassInfo -> FieldMap) -> FieldMap
 getsupermap superclass getter = case superclass of Just x -> getter x; Nothing -> M.empty
 
 
-calculateMethodMap :: Class Resolved -> Maybe ClassInfo -> IO (FieldMap, Word32)
+calculateMethodMap :: Class Direct -> Maybe ClassInfo -> IO (FieldMap, Word32)
 calculateMethodMap cf superclass = do
     let methods = filter
                   (\x -> (not . S.member ACC_STATIC . methodAccessFlags) x &&
index 216a287daa15c1683a857b5aee7ffc2620428c1f..c243d113950084fa56652f7b4950a64765c50797 100644 (file)
@@ -27,7 +27,6 @@ import Text.Printf
 import Mate.BasicBlocks
 import Mate.Types
 import Mate.X86CodeGen
-import Mate.Utilities
 import Mate.ClassPool
 import Mate.Debug
 
@@ -82,8 +81,8 @@ getMethodEntry signal_from methodtable = do
         Nothing -> error $ show method ++ " not found. abort"
     Just w32 -> return (fromIntegral w32)
 
-lookupMethodRecursive :: B.ByteString -> [B.ByteString] -> Class Resolved
-                         -> IO (Maybe (Method Resolved, [B.ByteString], Class Resolved))
+lookupMethodRecursive :: B.ByteString -> [B.ByteString] -> Class Direct
+                         -> IO (Maybe (Method Direct, [B.ByteString], Class Direct))
 lookupMethodRecursive name clsnames cls =
   case res of
     Just x -> return $ Just (x, nextclsn, cls)
index 794af0ff3eb8c68c668532a506e944328379e395..f1762b0a5ae1e9790639b69857ebf9bc5e9f9e82 100644 (file)
@@ -13,6 +13,8 @@ import qualified Data.ByteString.Internal as BI
 import Text.Printf
 #endif
 
+import JVM.ClassFile
+
 import Foreign.Ptr
 import Foreign.Marshal.Utils
 import Foreign.Marshal.Array
index 79b0396307e40c6abb4340d186025cee79cd0161..0f8b4a9b922fa7cf9a312da88f57ee07139e91c6 100644 (file)
@@ -2,12 +2,10 @@
 {-# LANGUAGE ForeignFunctionInterface #-}
 module Mate.Types where
 
-import Data.Char
 import Data.Word
 import Data.Int
 import qualified Data.Map as M
 import qualified Data.ByteString.Lazy as B
-import Codec.Binary.UTF8.String hiding (encode,decode)
 
 import Data.IORef
 import System.IO.Unsafe
@@ -74,7 +72,7 @@ type ClassMap = M.Map B.ByteString ClassInfo
 
 data ClassInfo = ClassInfo {
   ciName :: B.ByteString,
-  ciFile :: Class Resolved,
+  ciFile :: Class Direct,
   ciStaticMap  :: FieldMap,
   ciFieldMap :: FieldMap,
   ciMethodMap :: FieldMap,
@@ -98,14 +96,16 @@ type VirtualMap = M.Map Word32 B.ByteString
 
 
 -- store each parsed Interface upon first loading
-type InterfaceMap = M.Map B.ByteString (Class Resolved)
+type InterfaceMap = M.Map B.ByteString (Class Direct)
 
 -- store offset for each <Interface><Method><Signature> pair
 type InterfaceMethodMap = M.Map B.ByteString Word32
 
 
+{-
 toString :: B.ByteString -> String
 toString bstr = decodeString $ map (chr . fromIntegral) $ B.unpack bstr
+-}
 
 
 data MateCtx = MateCtx {
index 4d1cd07a5ad6a1153dddbe77e2bee0b0c8c590b5..4ae0bac7d23c765199a3651686316d112e87de9b 100644 (file)
@@ -11,35 +11,26 @@ import JVM.ClassFile
 import Mate.Types
 
 
--- 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
-
-buildMethodID :: Class Resolved -> Word16 -> MethodInfo
+buildMethodID :: Class Direct -> Word16 -> MethodInfo
 buildMethodID cls idx = MethodInfo (ntName nt) rc (ntSignature nt)
   where (rc, nt) = case constsPool cls M.! idx of
                     (CMethod rc' nt') -> (rc', nt')
                     (CIfaceMethod rc' nt') -> (rc', nt')
                     _ -> error "buildMethodID: something wrong. abort."
 
-buildStaticFieldID :: Class Resolved -> Word16 -> StaticFieldInfo
+buildStaticFieldID :: Class Direct -> Word16 -> StaticFieldInfo
 buildStaticFieldID cls idx = StaticFieldInfo rc (ntName fnt)
   where (CField rc fnt) = constsPool cls M.! idx
 
-buildFieldOffset :: Class Resolved -> Word16 -> (B.ByteString, B.ByteString)
+buildFieldOffset :: Class Direct -> Word16 -> (B.ByteString, B.ByteString)
 buildFieldOffset cls idx = (rc, ntName fnt)
   where (CField rc fnt) = constsPool cls M.! idx
 
-buildClassID :: Class Resolved -> Word16 -> B.ByteString
+buildClassID :: Class Direct -> Word16 -> B.ByteString
 buildClassID cls idx = cl
   where (CClass cl) = constsPool cls M.! idx
 
-methodGetArgsCount :: Class Resolved -> Word16 -> Word32
+methodGetArgsCount :: Class Direct -> Word16 -> Word32
 methodGetArgsCount cls idx = fromIntegral $ length args
   where
   nt = case constsPool cls M.! idx of
@@ -49,7 +40,7 @@ methodGetArgsCount cls idx = fromIntegral $ length args
   (MethodSignature args _) = ntSignature nt
 
 -- TODO(bernhard): Extend it to more than just int, and provide typeinformation
-methodHaveReturnValue :: Class Resolved -> Word16 -> Bool
+methodHaveReturnValue :: Class Direct -> Word16 -> Bool
 methodHaveReturnValue cls idx = case ret of
     ReturnsVoid -> False;
     (Returns IntType) -> True;
index 1b4ef954ce9def82da78439b50be1e3c5fa27352..a44a5d04f45785afdc7a569b0286a1c57f8c3638 100644 (file)
@@ -45,7 +45,7 @@ type BBStarts = M.Map BlockID Int
 type CompileInfo = (EntryPoint, BBStarts, Int, TrapMap)
 
 
-emitFromBB :: B.ByteString -> Class Resolved -> MapBB -> CodeGen e s (CompileInfo, [Instruction])
+emitFromBB :: B.ByteString -> Class Direct -> MapBB -> CodeGen e s (CompileInfo, [Instruction])
 emitFromBB method cls hmap =  do
         llmap <- sequence [newNamedLabel ("bb_" ++ show x) | (x,_) <- M.toList hmap]
         let lmap = zip (Prelude.fst $ unzip $ M.toList hmap) llmap
index 4ce578e94d9b3e8c4d682919a7302fe7f4675380..96f31b65d690cf157175487386104ab7114c8d65 100644 (file)
@@ -8,7 +8,7 @@ copyright:
 maintainer: lewurm@gmail.com, haraldsteinlechner@gmail.com
 build-depends: base -any, 
                mate-common -any, 
-               hs-java ==0.2.0.99,
+               hs-java ==0.3.1,
                bytestring -any,
                harpy ==0.4.3.99,
                heap -any,
index 175b7078adf2efb7db88852eaa3d198efff95d5a..159d2528641a805019eba535ef0e64ac73487198 100755 (executable)
@@ -23,7 +23,6 @@ rm -rf harpy
 
 git clone git://wien.tomnetworks.com/hs-java.git
 cd hs-java
-git checkout -t origin/v0.2
 cabal install --enable-shared
 cd ..
 rm -rf hs-java