diff --git a/lib/emscripten/src/lib.rs b/lib/emscripten/src/lib.rs index 62cee5c601e..1d88ba7a881 100644 --- a/lib/emscripten/src/lib.rs +++ b/lib/emscripten/src/lib.rs @@ -756,6 +756,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject }, "asm2wasm" => { "f64-rem" => func!(crate::math::f64_rem), + "f64-to-int" => func!(crate::math::f64_to_int), }, }; diff --git a/lib/emscripten/src/math.rs b/lib/emscripten/src/math.rs index c73580d7776..704a5885466 100644 --- a/lib/emscripten/src/math.rs +++ b/lib/emscripten/src/math.rs @@ -39,7 +39,7 @@ pub fn _emscripten_random(_ctx: &mut Ctx) -> f64 { -1.0 } -// emscripten: f64-rem +// emscripten: asm2wasm.f64-rem pub fn f64_rem(_ctx: &mut Ctx, x: f64, y: f64) -> f64 { debug!("emscripten::f64-rem"); x % y @@ -59,3 +59,9 @@ pub fn exp(_ctx: &mut Ctx, value: f64) -> f64 { pub fn log(_ctx: &mut Ctx, value: f64) -> f64 { value.ln() } + +// emscripten: asm2wasm.f64-to-int +pub fn f64_to_int(_ctx: &mut Ctx, value: f64) -> i32 { + debug!("emscripten::f64_to_int {}", value); + value as i32 +}