Skip to content

Commit 2477062

Browse files
committed
Expose WebAssembly.Instance
1 parent d090e94 commit 2477062

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

crates/cli-support/src/intrinsic.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ intrinsics! {
252252
#[symbol = "__wbindgen_memory"]
253253
#[signature = fn() -> Externref]
254254
Memory,
255+
#[symbol = "__wbindgen_exports"]
256+
#[signature = fn() -> Externref]
257+
Exports,
255258
#[symbol = "__wbindgen_module"]
256259
#[signature = fn() -> Externref]
257260
Module,

crates/cli-support/src/js/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3498,6 +3498,11 @@ impl<'a> Context<'a> {
34983498
format!("init.__wbindgen_wasm_module")
34993499
}
35003500

3501+
Intrinsic::Exports => {
3502+
assert_eq!(args.len(), 0);
3503+
"wasm".to_string()
3504+
}
3505+
35013506
Intrinsic::Memory => {
35023507
assert_eq!(args.len(), 0);
35033508
let mut memories = self.module.memories.iter();

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,7 @@ externs! {
10821082

10831083
fn __wbindgen_not(idx: u32) -> u32;
10841084

1085+
fn __wbindgen_exports() -> u32;
10851086
fn __wbindgen_memory() -> u32;
10861087
fn __wbindgen_module() -> u32;
10871088
fn __wbindgen_function_table() -> u32;
@@ -1358,6 +1359,11 @@ pub fn module() -> JsValue {
13581359
unsafe { JsValue::_new(__wbindgen_module()) }
13591360
}
13601361

1362+
/// Returns a handle to this wasm instance's `WebAssembly.Instance.prototype.exports`
1363+
pub fn exports() -> JsValue {
1364+
unsafe { JsValue::_new(__wbindgen_exports()) }
1365+
}
1366+
13611367
/// Returns a handle to this wasm instance's `WebAssembly.Memory`
13621368
pub fn memory() -> JsValue {
13631369
unsafe { JsValue::_new(__wbindgen_memory()) }

0 commit comments

Comments
 (0)