mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-02 12:48:14 +00:00
Fix calling time.now() in wasm js runtime
This commit is contained in:
@@ -10,7 +10,7 @@ _now :: proc "contextless" () -> Time {
|
|||||||
foreign odin_env {
|
foreign odin_env {
|
||||||
time_now :: proc "contextless" () -> i64 ---
|
time_now :: proc "contextless" () -> i64 ---
|
||||||
}
|
}
|
||||||
return Time{time_now()}
|
return Time{time_now()*1e6}
|
||||||
}
|
}
|
||||||
|
|
||||||
_sleep :: proc "contextless" (d: Duration) {
|
_sleep :: proc "contextless" (d: Duration) {
|
||||||
@@ -26,7 +26,7 @@ _tick_now :: proc "contextless" () -> Tick {
|
|||||||
foreign odin_env {
|
foreign odin_env {
|
||||||
tick_now :: proc "contextless" () -> i64 ---
|
tick_now :: proc "contextless" () -> i64 ---
|
||||||
}
|
}
|
||||||
return Tick{tick_now()}
|
return Tick{tick_now()*1e6}
|
||||||
}
|
}
|
||||||
|
|
||||||
_yield :: proc "contextless" () {
|
_yield :: proc "contextless" () {
|
||||||
|
|||||||
Vendored
+3
-8
@@ -1334,14 +1334,9 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement) {
|
|||||||
abort: () => { Module.abort() },
|
abort: () => { Module.abort() },
|
||||||
evaluate: (str_ptr, str_len) => { eval.call(null, wasmMemoryInterface.loadString(str_ptr, str_len)); },
|
evaluate: (str_ptr, str_len) => { eval.call(null, wasmMemoryInterface.loadString(str_ptr, str_len)); },
|
||||||
|
|
||||||
time_now: () => {
|
// return a bigint to be converted to i64
|
||||||
// convert ms to ns
|
time_now: () => BigInt(Date.now()),
|
||||||
return Date.now() * 1e6;
|
tick_now: () => BigInt(performance.now()),
|
||||||
},
|
|
||||||
tick_now: () => {
|
|
||||||
// convert ms to ns
|
|
||||||
return performance.now() * 1e6;
|
|
||||||
},
|
|
||||||
time_sleep: (duration_ms) => {
|
time_sleep: (duration_ms) => {
|
||||||
if (duration_ms > 0) {
|
if (duration_ms > 0) {
|
||||||
// TODO(bill): Does this even make any sense?
|
// TODO(bill): Does this even make any sense?
|
||||||
|
|||||||
Reference in New Issue
Block a user