#include "debug.h"
module Mate.ClassPool (
getClassInfo,
+ classLoaded,
getClassFile,
getMethodTable,
getObjectSize,
import Mate.Types
import Mate.Debug
import Mate.GarbageAlloc
+import Mate.NativeSizes
getClassInfo :: B.ByteString -> IO ClassInfo
getClassInfo path = do
Nothing -> loadAndInitClass path
Just ci -> return ci
+classLoaded :: B.ByteString -> IO Bool
+classLoaded path = do
+ class_map <- getClassMap
+ return $ M.member path class_map
+
getClassFile :: B.ByteString -> IO (Class Direct)
getClassFile path = do
ci <- getClassInfo path
getMethodOffset :: B.ByteString -> B.ByteString -> IO Word32
getMethodOffset path method = do
ci <- getClassInfo path
- -- (4+) one slot for "interface-table-ptr"
- return $ (+4) $ fromIntegral $ ciMethodMap ci M.! method
+ -- (+ ptrSize) one slot for "interface-table-ptr"
+ return $ (+ ptrSize) $ fromIntegral $ ciMethodMap ci M.! method
getMethodTable :: B.ByteString -> IO Word32
getMethodTable path = do
-- TODO(bernhard): correct sizes for different types...
let fsize = fromIntegral $ M.size $ ciFieldMap ci
-- one slot for "method-table-ptr"
- return $ (1 + fsize) * 4
+ return $ (1 + fsize) * ptrSize
getStaticFieldAddr :: CPtrdiff -> IO CPtrdiff
getStaticFieldAddr from = do