case hmap of
Just hmap' -> do
let methods = classMethods cls; methods :: [Method Resolved]
- let idx = findIndex (\x -> (methodName x) == "main") methods
- case idx of
- Just idx' -> do
- let (Just m) = find (\x -> (methodName x) == "main") methods
+ let method = find (\x -> (methodName x) == "main") methods
+ case method of
+ Just m -> do
let bclspath = B.pack $ map (fromIntegral . ord) (replace ".class" "" clspath)
- entry <- compileBB hmap' (MethodInfo "main" bclspath (methodSignature m) (fromIntegral idx'))
+ entry <- compileBB hmap' (MethodInfo "main" bclspath (methodSignature m))
printf "executing `main' now:\n"
executeFuncPtr entry
Nothing -> error "main not found"
import Foreign.C.Types
import Foreign.StablePtr
-import JVM.ClassFile
import JVM.Converter
import Harpy
cmap <- ptr2cmap ptr_cmap
let w32_from = fromIntegral signal_from
- let mi@(MethodInfo method cm _ cpidx) = cmap M.! w32_from
+ let mi@(MethodInfo method cm _) = cmap M.! w32_from
-- TODO(bernhard): replace parsing with some kind of classpool
cls <- parseClassFile $ toString $ cm `B.append` ".class"
case M.lookup mi mmap of
Nothing -> do
printf "getMethodEntry(from 0x%08x): no method \"%s\" found. compile it\n" w32_from (show mi)
- -- TODO(bernhard): maybe we have to load the class first?
- -- (Or better in X86CodeGen?)
- let (CMethod _ nt) = (constsPool cls) M.! cpidx
- hmap <- parseMethod cls (ntName nt)
+ hmap <- parseMethod cls method
printMapBB hmap
case hmap of
Just hmap' -> do
data MethodInfo = MethodInfo {
methName :: B.ByteString,
cName :: B.ByteString,
- mSignature :: MethodSignature,
- cpIndex :: Word16 }
+ mSignature :: MethodSignature}
instance Eq MethodInfo where
- (MethodInfo m_a c_a s_a i_a) == (MethodInfo m_b c_b s_b i_b) =
- (m_a == m_b) && (c_a == c_b) && (s_a == s_b) && (i_a == i_b)
+ (MethodInfo m_a c_a s_a) == (MethodInfo m_b c_b s_b) =
+ (m_a == m_b) && (c_a == c_b) && (s_a == s_b)
-- TODO(bernhard): not really efficient. also, outsource that to hs-java
instance Ord MethodSignature where
cmp_args = (show args_a) `compare` (show args_b)
instance Ord MethodInfo where
- compare (MethodInfo m_a c_a s_a i_a) (MethodInfo m_b c_b s_b i_b)
+ compare (MethodInfo m_a c_a s_a) (MethodInfo m_b c_b s_b)
| cmp_m /= EQ = cmp_m
| cmp_c /= EQ = cmp_c
- | cmp_s /= EQ = cmp_s
- | otherwise = i_a `compare` i_b
+ | otherwise = s_a `compare` s_b
where
cmp_m = m_a `compare` m_b
cmp_c = c_a `compare` c_b
- cmp_s = s_a `compare` s_b
instance Show MethodInfo where
- show (MethodInfo method c sig idx) =
- (toString c) ++ "." ++ (toString method) ++ "." ++ (show sig) ++ "@" ++ (show idx)
+ show (MethodInfo method c sig) =
+ (toString c) ++ "." ++ (toString method) ++ "." ++ (show sig)
toString :: B.ByteString -> String