1 {-# LANGUAGE OverloadedStrings #-}
4 import System.Environment
6 import Data.String.Utils
8 import qualified Data.ByteString.Lazy as B
16 import Mate.BasicBlocks
17 import Mate.X86CodeGen
18 import Mate.MethodPool
28 cls <- parseClassFile clspath
30 hmap <- parseMethod cls "main"
34 let methods = classMethods cls; methods :: [Method Resolved]
35 let idx = findIndex (\x -> (methodName x) == "main") methods
38 let (Just m) = find (\x -> (methodName x) == "main") methods
39 let bclspath = B.pack $ map (fromIntegral . ord) (replace ".class" "" clspath)
40 entry <- compileBB hmap' (MethodInfo "main" bclspath (methodSignature m) (fromIntegral idx'))
41 printf "executing `main' now:\n"
43 Nothing -> error "main not found"
44 Nothing -> error "main not found"
45 _ -> error "Usage: mate <class-file>"