codegen: typestuff for compiling classpath files
[mate.git] / Mate / Utilities.hs
index c76d68043c94877ef187389e80929ac175bb2a46..89020a5d1d65cfda9dedd217c42a568ec13620d0 100644 (file)
@@ -43,6 +43,8 @@ methodGetArgsCount cls idx = fromIntegral $ length args
 methodHaveReturnValue :: Class Direct -> Word16 -> Bool
 methodHaveReturnValue cls idx = case ret of
     ReturnsVoid -> False;
+    (Returns BoolType) -> True
+    (Returns CharByte) -> True
     (Returns IntType) -> True;
     (Returns (Array _ _)) -> True
     (Returns (ObjectType _)) -> True;
@@ -53,3 +55,11 @@ methodHaveReturnValue cls idx = case ret of
     (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