Explorar o código

[java/cs] Add EntryPoint support. Closes #5350

Cauê Waneck %!s(int64=9) %!d(string=hai) anos
pai
achega
9d450a11ed
Modificáronse 2 ficheiros con 16 adicións e 4 borrados
  1. 11 3
      src/generators/gencs.ml
  2. 5 1
      src/generators/genjava.ml

+ 11 - 3
src/generators/gencs.ml

@@ -2411,8 +2411,12 @@ let configure gen =
 					write w "public static void Main() ";
 					write w "public static void Main() ";
 					begin_block w;
 					begin_block w;
 					(if Hashtbl.mem gen.gtypes (["cs"], "Boot") then write w "global::cs.Boot.init();"; newline w);
 					(if Hashtbl.mem gen.gtypes (["cs"], "Boot") then write w "global::cs.Boot.init();"; newline w);
-					expr_s w { eexpr = TTypeExpr(TClassDecl cl); etype = t_dynamic; epos = null_pos };
-					write w ".main();";
+					(match gen.gcon.main with
+						| None ->
+							expr_s w { eexpr = TTypeExpr(TClassDecl cl); etype = t_dynamic; epos = null_pos };
+							write w ".main();"
+						| Some expr ->
+							expr_s w expr);
 					end_block w;
 					end_block w;
 					end_block w;
 					end_block w;
 					newline w;
 					newline w;
@@ -2452,7 +2456,11 @@ let configure gen =
 			write w "public static void Main()";
 			write w "public static void Main()";
 			begin_block w;
 			begin_block w;
 			(if Hashtbl.mem gen.gtypes (["cs"], "Boot") then write w "global::cs.Boot.init();"; newline w);
 			(if Hashtbl.mem gen.gtypes (["cs"], "Boot") then write w "global::cs.Boot.init();"; newline w);
-			write w "main();";
+			(match gen.gcon.main with
+				| None ->
+					write w "main();";
+				| Some expr ->
+						expr_s w expr);
 			end_block w
 			end_block w
 		end;
 		end;
 
 

+ 5 - 1
src/generators/genjava.ml

@@ -1953,7 +1953,11 @@ let configure gen =
 								| _ -> ()
 								| _ -> ()
 				with | Not_found -> ()
 				with | Not_found -> ()
 				);
 				);
-				write w "main();";
+				(match gen.gcon.main with
+					| Some(expr) ->
+						expr_s w expr
+					| None ->
+						write w "main();");
 				end_block w;
 				end_block w;
 				newline w
 				newline w
 			| _ -> ()
 			| _ -> ()