From fb42a1f78a371a5f1208998e424aee49d06281e6 Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Thu, 2 Aug 2012 21:37:24 +0200 Subject: [PATCH] hlint: stuff --- Mate/BasicBlocks.hs | 13 +++++++------ Mate/X86CodeGen.hs | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Mate/BasicBlocks.hs b/Mate/BasicBlocks.hs index d863f55..d4cd2b1 100644 --- a/Mate/BasicBlocks.hs +++ b/Mate/BasicBlocks.hs @@ -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) diff --git a/Mate/X86CodeGen.hs b/Mate/X86CodeGen.hs index 8f2bbfb..6def8de 100644 --- a/Mate/X86CodeGen.hs +++ b/Mate/X86CodeGen.hs @@ -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) -- 2.25.1