Skip to content

Commit 95e342b

Browse files
committed
[lua] Implement Sys.time, Sys.getEnv, and Timer.stamp for lua-vanilla mode
Sys.time() and Sys.getEnv() were throwing NotImplementedException in lua-vanilla mode despite having trivial vanilla Lua implementations via os.time() and os.getenv(). Timer.stamp() now uses os.clock() directly on all Lua targets for subsecond precision. Addresses #12843 (hxcoro with -D lua-vanilla).
1 parent 2f37c31 commit 95e342b

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

std/haxe/Timer.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ class Timer {
173173
return untyped __global__.__time_stamp();
174174
#elseif python
175175
return Sys.cpuTime();
176+
#elseif lua
177+
return lua.Os.clock();
176178
#elseif sys
177179
return Sys.time();
178180
#else

std/lua/_std/Sys.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ class Sys {
4646
public static inline function programPath():String return haxe.io.Path.join([getCwd(), Lua.arg[0]]);
4747
public static function getCwd():String return notImplemented();
4848
public static function setCwd(s:String):Void notImplemented();
49-
public static function getEnv(s:String):Null<String> return notImplemented();
49+
public static inline function getEnv(s:String):Null<String> return lua.Os.getenv(s);
5050
public static function putEnv(s:String, v:Null<String>):Void notImplemented();
5151
public static inline function setTimeLocale(loc:String):Bool return lua.Os.setlocale(loc) != null;
5252
public static function sleep(seconds:Float):Void notImplemented();
5353
public static inline function stderr():haxe.io.Output return @:privateAccess new FileOutput(Io.stderr);
5454
public static inline function stdin():haxe.io.Input return @:privateAccess new FileInput(Io.stdin);
5555
public static inline function stdout():haxe.io.Output return @:privateAccess new FileOutput(Io.stdout);
56-
public static function time():Float return notImplemented();
56+
public static inline function time():Float return lua.Os.time();
5757
}
5858

5959
#else

0 commit comments

Comments
 (0)