Skip to content

Instantly share code, notes, and snippets.

@kubkon
Created Jun 4, 2020
Embed
What would you like to do?
Import globals and export func that uses them
(module
(type (;0;) (func (param i32)))
(type (;1;) (func))
(import "env" "frobinate" (func $frobinate (type 0)))
(import "env" "glob" (global (;0;) i32))
(export "foo" (func $foo))
(func $foo (type 1)
global.get 0
call $frobinate
return))
extern int glob;
extern void frobinate(int);
void foo() {
frobinate(glob);
}
#[link(wasm_import_module = "env")]
extern "C" {
static glob: u32;
fn frobinate(num: u32);
}
#[no_mangle]
pub unsafe extern "C" fn foo() {
frobinate(glob);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment