Skip to content

Commit

Permalink
Added f64-to-int
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary committed Apr 5, 2019
1 parent 1c2f0e9 commit b03a05f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/emscripten/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
};

Expand Down
8 changes: 7 additions & 1 deletion lib/emscripten/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

0 comments on commit b03a05f

Please sign in to comment.