-
-
-parseMethod :: Class Resolved -> B.ByteString -> IO (Maybe MapBB)
-parseMethod cls method = do
- putStr "BB: analysing: "
- let msig = methodSignature $ (classMethods cls) !! 1
- B.putStrLn (method `B.append` ": " `B.append` (encode msig))
- return $ testCFG $ lookupMethod method cls
-
-
-testCFG :: Maybe (Method Resolved) -> Maybe MapBB
-testCFG (Just m) = case attrByName m "Code" of
- Nothing -> Nothing
- Just bytecode -> Just $ buildCFG $ codeInstructions $ decodeMethod bytecode
-testCFG _ = Nothing
+#endif
+#endif
+
+
+parseMethod :: Class Direct -> B.ByteString -> MethodSignature -> IO (Maybe MapBB)
+parseMethod cls method sig = do
+ let maybe_bb = testCFG $ lookupMethodSig method sig cls
+ let msig = methodSignature $ classMethods cls !! 1
+ printfBb "BB: analysing \"%s\"\n" $ toString (method `B.append` ": " `B.append` encode msig)
+#ifdef DBG_BB
+ printMapBB maybe_bb
+#endif
+ -- small example how to get information about
+ -- exceptions of a method
+ -- TODO: remove ;-)
+ let (Just m) = lookupMethodSig method sig cls
+ case attrByName m "Code" of
+ Nothing -> printfBb "exception: no handler for this method\n"
+ Just exceptionstream -> printfBb "exception: \"%s\"\n" (show $ codeExceptions $ decodeMethod exceptionstream)
+ return maybe_bb
+
+
+testCFG :: Maybe (Method Direct) -> Maybe MapBB
+testCFG m = do
+ m' <- m
+ bytecode <- attrByName m' "Code"
+ return $ buildCFG $ codeInstructions $ decodeMethod bytecode