nitj: compile java main function stub
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 30 Jun 2015 19:08:56 +0000 (15:08 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 21 Jul 2015 21:23:21 +0000 (17:23 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/compiler/java_compiler.nit

index 03fef84..dfdff67 100644 (file)
@@ -217,8 +217,8 @@ class JavaCompiler
                # compile method structures
                compile_mmethods_to_java
 
-               # TODO compile main
-               modelbuilder.toolcontext.info("NOT YET IMPLEMENTED", 0)
+               # compile main
+               compile_main_function
        end
 
        # Prepare the boxes used to represent Java primitive types
@@ -260,6 +260,17 @@ class JavaCompiler
                        end
                end
        end
+
+       # Generate Java main that call Sys.main
+       fun compile_main_function do
+               var v = new_visitor("{mainmodule.jname}_Main.java")
+               v.add("public class {mainmodule.jname}_Main \{")
+               v.add("  public static void main(String[] args) \{")
+               modelbuilder.toolcontext.info("NOT YET IMPLEMENTED", 0)
+               # TODO compile call to Sys::main
+               v.add("  \}")
+               v.add("\}")
+       end
 end
 
 # The class visiting the AST