code style: just different indent
[mate.git] / Mate / Utilities.hs
index 89020a5d1d65cfda9dedd217c42a568ec13620d0..fd4fc76307fea2bb66ba7dfc90843482c77c6beb 100644 (file)
@@ -5,6 +5,7 @@ module Mate.Utilities where
 import Data.Word
 import qualified Data.Map as M
 import qualified Data.ByteString.Lazy as B
+import Data.List
 
 import JVM.ClassFile
 
@@ -13,10 +14,11 @@ import Mate.Types
 
 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."
+  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 Direct -> Word16 -> StaticFieldInfo
 buildStaticFieldID cls idx = StaticFieldInfo rc (ntName fnt)
@@ -33,11 +35,11 @@ buildClassID cls idx = cl
 methodGetArgsCount :: Class Direct -> Word16 -> Word32
 methodGetArgsCount cls idx = fromIntegral $ length args
   where
-  nt = case constsPool cls M.! idx of
-    (CMethod _ nt') -> nt'
-    (CIfaceMethod _ nt') -> nt'
-    _ -> error "methodGetArgsCount: something wrong. abort."
-  (MethodSignature args _) = ntSignature nt
+    nt = case constsPool cls M.! idx of
+      (CMethod _ nt') -> nt'
+      (CIfaceMethod _ nt') -> nt'
+      _ -> error "methodGetArgsCount: something wrong. abort."
+    (MethodSignature args _) = ntSignature nt
 
 -- TODO(bernhard): Extend it to more than just int, and provide typeinformation
 methodHaveReturnValue :: Class Direct -> Word16 -> Bool
@@ -50,16 +52,12 @@ methodHaveReturnValue cls idx = case ret of
     (Returns (ObjectType _)) -> True;
     _ -> error $ "methodHaveReturnValue: todo: " ++ show ret
   where
-  nt = case constsPool cls M.! idx of
-    (CMethod _ nt') -> nt'
-    (CIfaceMethod _ nt') -> nt'
-    _ -> error "methodHaveReturnValue: something wrong. abort."
-  (MethodSignature _ ret) = ntSignature nt
+    nt = case constsPool cls M.! idx of
+      (CMethod _ nt') -> nt'
+      (CIfaceMethod _ nt') -> nt'
+      _ -> error "methodHaveReturnValue: something wrong. abort."
+    (MethodSignature _ ret) = ntSignature nt
 
 lookupMethodSig :: B.ByteString -> MethodSignature -> Class Direct -> Maybe (Method Direct)
-lookupMethodSig name sig cls = look (classMethods cls)
-  where
-  look [] = Nothing
-  look (f:fs)
-    | methodName f == name && methodSignature f == sig = Just f
-    | otherwise = look fs
+lookupMethodSig name sig cls =
+  find (\x -> methodName x == name && methodSignature x == sig) $ classMethods cls