Created
August 7, 2023 20:12
-
-
Save tshemsedinov/c807de6b001133767577352562c0c9f7 to your computer and use it in GitHub Desktop.
Rust compiled by wasm-pack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use wasm_bindgen::prelude::*; | |
#[wasm_bindgen] | |
extern { | |
pub fn callback(res: i32); | |
} | |
#[wasm_bindgen] | |
pub fn add(a: i32, b: i32) -> i32 { | |
return a + b; | |
} | |
#[wasm_bindgen] | |
pub fn add_callback(a: i32, b: i32) { | |
callback(a + b) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(module | |
(type (;0;) (func (param i32))) | |
(type (;1;) (func (param i32 i32))) | |
(type (;2;) (func (param i32 i32) (result i32))) | |
(import "wbg" "__wbg_callback_330497ee23f1aa0e" (func (;0;) (type 0))) | |
(func (;1;) (type 1) (param i32 i32) | |
local.get 0 | |
local.get 1 | |
i32.add | |
call 0) | |
(func (;2;) (type 2) (param i32 i32) (result i32) | |
local.get 0 | |
local.get 1 | |
i32.add) | |
(memory (;0;) 17) | |
(export "memory" (memory 0)) | |
(export "add" (func 2)) | |
(export "add_callback" (func 1))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment