hlint: more fixes
authorBernhard Urban <lewurm@gmail.com>
Tue, 12 Jun 2012 10:06:05 +0000 (12:06 +0200)
committerBernhard Urban <lewurm@gmail.com>
Tue, 12 Jun 2012 19:48:41 +0000 (21:48 +0200)
not everything fixed though. some ugly things in the codegen hopefully disappears
sometimes (e.g. due to an awesome reg allocator ;))

Mate.hs
Mate/ClassPool.hs
Mate/Strings.hs
Mate/Types.hs
Mate/X86TrapHandling.hs

diff --git a/Mate.hs b/Mate.hs
index 1c229e3cc560e8ddb1d2583febaa18b6eaf8c8c7..eb3c8733bab63d9261cc54f6247888e244220fbc 100644 (file)
--- a/Mate.hs
+++ b/Mate.hs
@@ -8,6 +8,7 @@ import Data.Char
 import Data.List
 import Data.List.Split
 import qualified Data.ByteString.Lazy as B
+import Control.Monad
 
 #ifdef DEBUG
 import Text.Printf
@@ -29,7 +30,7 @@ main = do
 
 parseArgs :: [String] -> Bool -> IO ()
 parseArgs ("-jar":jarpath:_) stdcp = do
-  if not stdcp then addClassPath "./" else return ()
+  unless stdcp $ addClassPath "./"
   addClassPathJAR jarpath
   res <- readMainClass jarpath
   case res of
@@ -52,7 +53,7 @@ parseArgs ("-classpath":xs) _ = parseArgs ("-":xs) True -- usage
 parseArgs (('-':_):_) _ = error "Usage: mate [-cp|-classpath <cp1:cp2:..>] [<class-file> | -jar <jar-file>]"
 -- first argument which isn't prefixed by '-' should be a class file
 parseArgs (clspath:_) stdcp = do
-  if not stdcp then addClassPath "./" else return ()
+  unless stdcp $ addClassPath "./"
   let bclspath = B.pack $ map (fromIntegral . ord) clspath
   cls <- getClassFile bclspath
   executeMain bclspath cls
index e476c8b5b92d47b05ff0f2c7a1c0c38b95766915..cb38b28fbd22d89b4237c0735e9d395089e7e85e 100644 (file)
@@ -1,6 +1,5 @@
 {-# LANGUAGE CPP #-}
 {-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE ForeignFunctionInterface #-}
 #include "debug.h"
 module Mate.ClassPool (
   getClassInfo,
@@ -284,15 +283,15 @@ readClassFile path' = readIORef classPaths >>= rcf
   where
   path = replace "." "/" path'
   rcf :: [MClassPath] -> IO (Class Direct)
-  rcf [] = error $ "readClassFile: Class \"" ++ (show path) ++ "\" not found."
-  rcf ((Directory pre):xs) = do
+  rcf [] = error $ "readClassFile: Class \"" ++ show path ++ "\" not found."
+  rcf (Directory pre:xs) = do
     let cf = pre ++ path ++ ".class"
     printfCp "rcf: searching @ %s for %s\n" (show pre) (show path)
     b <- doesFileExist cf
     if b
       then parseClassFile cf
       else rcf xs
-  rcf ((JAR p):xs) = do
+  rcf (JAR p:xs) = do
     printfCp "rcf: searching %s in JAR\n" (show path)
     entry <- getEntry p path
     case entry of
index 2ebda14e4861da078d754c6730999c6fc8e8e56e..3ac7f995401e99c2fb0abda89062f3ea5bd6ebc6 100644 (file)
@@ -62,7 +62,7 @@ allocateJavaString str = do
   poke ptr $ fromIntegral mtbl
 
   -- build array layout
-  let strlen = (fromIntegral $ B.length str)
+  let strlen = fromIntegral $ B.length str
   -- (+1) for \0, (+4) for length
   newstr <- mallocString (strlen + 5)
   BI.memset newstr 0 (fromIntegral $ strlen + 5)
index f49e0408e1a57cec351fb0952297523ce4b88995..71b08571e0bd578769deec226a7d0a628885a6c1 100644 (file)
@@ -1,5 +1,4 @@
 {-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE ForeignFunctionInterface #-}
 module Mate.Types where
 
 import Data.Word
index ef753141ccf1d4475926b7520fde9597beaf94ea..f383c2d3635afdec98079b70931d7101cf929374 100644 (file)
@@ -45,7 +45,7 @@ mateHandler eip eax ebx esp = do
     4 -> invokeHandler eax ebx esp True
     8 -> invokeHandler eax ebx esp False
     2 -> staticFieldHandler eip
-    x -> error $ "wtf: " ++ (show x)
+    x -> error $ "wtf: " ++ show x
 
 staticCallHandler :: CUInt -> IO CUInt
 staticCallHandler eip = do
@@ -86,7 +86,7 @@ invokeHandler method_table table2patch esp imm8 = do
   callerAddr <- callerAddrFromStack esp
   offset <- if imm8 then offsetOfCallInsn8 esp else offsetOfCallInsn32 esp
   entryAddr <- getMethodEntry callerAddr method_table
-  let call_insn = intPtrToPtr (fromIntegral $ table2patch + (fromIntegral offset))
+  let call_insn = intPtrToPtr (fromIntegral $ table2patch + fromIntegral offset)
   poke call_insn entryAddr
   return entryAddr
 
@@ -105,5 +105,4 @@ offsetOfCallInsn32 :: CUInt -> IO CUInt
 offsetOfCallInsn32 esp = do
   let ret_ptr = intPtrToPtr (fromIntegral esp) :: Ptr CUInt
   ret <- peek ret_ptr
-  retval <- peek (intPtrToPtr $ fromIntegral (ret - 4))
-  return retval
+  peek (intPtrToPtr $ fromIntegral (ret - 4))