Some documentation.
[hs-java.git] / TestGen.hs
index 0e5ff90184b7f05fea5e31c167707559e8f24554..c8cd0ef3c91578696e3db0355efc384f76225343 100644 (file)
@@ -14,10 +14,13 @@ import qualified Java.IO
 test :: Generate ()
 test = do
   withClassPath $ do
+      -- Add current directory (with Hello.class) to ClassPath
       addDirectory "."
 
+  -- Load method signature: Hello.hello()
   helloJava <- getClassMethod "./Hello" "hello"
 
+  -- Initializer method. Just calls java.lang.Object.<init>
   newMethod [ACC_PUBLIC] "<init>" [] ReturnsVoid $ do
       setStackSize 1
 
@@ -25,6 +28,7 @@ test = do
       invokeSpecial Java.Lang.object Java.Lang.objectInit
       i0 RETURN
 
+  -- Declare hello() method and bind it's signature to hello.
   hello <- newMethod [ACC_PUBLIC, ACC_STATIC] "hello" [IntType] ReturnsVoid $ do
       setStackSize 8
 
@@ -45,15 +49,18 @@ test = do
       pop
       i0 RETURN
 
+  -- Main class method. 
   newMethod [ACC_PUBLIC, ACC_STATIC] "main" [arrayOf Java.Lang.stringClass] ReturnsVoid $ do
       setStackSize 1
 
       iconst_5
+      -- Call previously declared method
       invokeStatic "Test" hello
       i0 RETURN
 
   return ()
 
+main :: IO ()
 main = do
   testClass <- generate [] "Test" test
   B.writeFile "Test.class" (encodeClass testClass)