-{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
-#include "debug.h"
module Main where
import System.Environment
import qualified Data.ByteString.Lazy as B
import Control.Monad
-#ifdef DEBUG
-import Text.Printf
-#endif
import JVM.ClassFile
import Java.JAR
import Mate.Types
import Mate.ClassPool
import Mate.NativeMachine
+import Mate.Debug
+
+import Mate.GC.Boehm
main :: IO ()
main = do
executeMain :: B.ByteString -> Class Direct -> IO ()
-executeMain bclspath cls = do
+executeMain bclspath cls = do
+ initGC --required on some platforms. [todo bernhard: maybe this should be moved somewhere else - maybe at a global place where vm initialization takes place
+
let methods = classMethods cls; methods :: [Method Direct]
case find (\x -> methodName x == "main") methods of
Just m -> do
rawmethod <- parseMethod cls "main" $ methodSignature m
entry <- compileBB rawmethod mi
addMethodRef entry mi [bclspath]
-#ifdef DEBUG
- printf "executing `main' now:\n"
-#endif
+ printfInfo "executing `main' now:\n"
executeFuncPtr entry
Nothing -> error "main not found"