Quellcode durchsuchen

[java] Fixed Sys.cpuTime() and Sys.args with DCE. Fixed Issue #1091

Caue Waneck vor 13 Jahren
Ursprung
Commit
82c601fa0f
2 geänderte Dateien mit 9 neuen und 2 gelöschten Zeilen
  1. 8 1
      genjava.ml
  2. 1 1
      std/java/_std/Sys.hx

+ 8 - 1
genjava.ml

@@ -1393,7 +1393,14 @@ let configure gen =
       | Some path when path = cl.cl_path ->
         write w "public static void main(String[] args)";
         begin_block w;
-        (if Hashtbl.mem gen.gtypes ([], "Sys") then write w "Sys._args = args;"; newline w);
+        (try
+          let t = Hashtbl.find gen.gtypes ([], "Sys") in
+              match t with 
+                | TClassDecl(cl) when PMap.mem "_args" cl.cl_statics -> 
+                  write w "Sys._args = args;"; newline w
+                | _ -> ()
+        with | Not_found -> ()
+        );
         write w "main();";
         end_block w
       | _ -> ()

+ 1 - 1
std/java/_std/Sys.hx

@@ -185,7 +185,7 @@ import sys.io.Process;
 	**/
 	public static function cpuTime() : Float
 	{
-		return cast(System.nanoTime(), Float) / 1000;
+		return cast(System.nanoTime(), Float) / 1000000000;
 	}
 
 	/**