Import globals and export func that uses them
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)) | |
(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)) |
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
extern int glob; | |
extern void frobinate(int); | |
void foo() { | |
frobinate(glob); | |
} |
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
#[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