hlint: stuff
authorBernhard Urban <lewurm@gmail.com>
Thu, 2 Aug 2012 19:37:24 +0000 (21:37 +0200)
committerBernhard Urban <lewurm@gmail.com>
Thu, 2 Aug 2012 14:25:38 +0000 (16:25 +0200)
Mate/BasicBlocks.hs
Mate/X86CodeGen.hs

index d863f55d36e6833d7a42a80ef7caa623acc08e35..d4cd2b18bb8cae87ec40ce09d41cc18ae59d5df6 100644 (file)
@@ -19,6 +19,7 @@ import Data.Int
 import Data.List
 import qualified Data.Map as M
 import qualified Data.ByteString.Lazy as B
+import Data.Maybe
 
 import JVM.ClassFile
 import JVM.Converter
@@ -89,12 +90,12 @@ test_04 = testInstance "./tests/Fac.class" "fac"
 
 parseMethod :: Class Direct -> B.ByteString -> MethodSignature -> IO RawMethod
 parseMethod cls methodname sig = do
-  let method = case lookupMethodSig methodname sig cls of
-        Just m -> m
-        Nothing -> error $ "method " ++ (show . toString) methodname ++ " not found"
-  let codeseg = case attrByName method "Code" of
-        Just m -> m
-        Nothing -> error $ "codeseg " ++ (show . toString) methodname ++ " not found"
+  let method = fromMaybe
+               (error $ "method " ++ (show . toString) methodname ++ " not found")
+               (lookupMethodSig methodname sig cls)
+  let codeseg = fromMaybe
+                (error $ "codeseg " ++ (show . toString) methodname ++ " not found")
+                (attrByName method "Code")
   let decoded = decodeMethod codeseg
   let mapbb = testCFG decoded
   let locals = fromIntegral (codeMaxLocals decoded)
index 8f2bbfb4af28f1cdddff71d005a04f2a6ce48ac9..6def8de41da1f5d8bafee84acce33cd413297dda 100644 (file)
@@ -107,7 +107,7 @@ emitFromBB cls method = do
       -- place a nop at the end, therefore the disasm doesn't screw up
       emit32 (0xffff9090 :: Word32) >> emit8 (0x90 :: Word8)
       -- discard arguments on stack
-      let argcnt = ((if hasThis then 1 else 0) + (methodGetArgsCount $ methodNameTypeByIdx cls cpidx)) * ptrSize
+      let argcnt = ((if hasThis then 1 else 0) + methodGetArgsCount (methodNameTypeByIdx cls cpidx)) * ptrSize
       when (argcnt > 0) (add esp argcnt)
       -- push result on stack if method has a return value
       when (methodHaveReturnValue cls cpidx) (push eax)
@@ -120,7 +120,7 @@ emitFromBB cls method = do
       calladdr <- getCurrentOffset
       call (Disp offset, eax)
       -- discard arguments on stack (`+1' for "this")
-      let argcnt = ptrSize * (1 + (methodGetArgsCount $ methodNameTypeByIdx cls cpidx))
+      let argcnt = ptrSize * (1 + methodGetArgsCount (methodNameTypeByIdx cls cpidx))
       when (argcnt > 0) (add esp argcnt)
       -- push result on stack if method has a return value
       when (methodHaveReturnValue cls cpidx) (push eax)