2 {-# LANGUAGE OverloadedStrings #-}
6 import System.Environment
9 import Data.String.Utils
10 import qualified Data.ByteString.Lazy as B
18 import Mate.BasicBlocks
19 import Mate.MethodPool
22 import Mate.X86TrapHandling
31 let bclspath = B.pack $ map (fromIntegral . ord) clspath
32 cls <- getClassFile bclspath
33 executeMain bclspath cls
34 ["-jar", jarpath] -> do
35 addClassPathJAR jarpath
36 res <- readMainClass jarpath
38 Nothing -> error "JAR: no MainClass entry found. Try to pass the jar file via -cp instead."
40 let mc' = replace "." "/" mc
41 let bclspath = B.pack $ map (fromIntegral . ord) mc'
42 cls <- getClassFile bclspath
43 executeMain bclspath cls
44 _ -> error "Usage: mate [<class-file> | -jar <jar-file>]"
46 executeMain :: B.ByteString -> Class Direct -> IO ()
47 executeMain bclspath cls = do
48 hmap <- parseMethod cls "main"
51 let methods = classMethods cls; methods :: [Method Direct]
52 let method = find (\x -> methodName x == "main") methods
55 let mi = MethodInfo "main" bclspath $ methodSignature m
56 entry <- compileBB hmap' mi
57 addMethodRef entry mi [bclspath]
59 printf "executing `main' now:\n"
62 Nothing -> error "main not found"
63 Nothing -> error "main not found"