mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-24 18:21:33 +00:00
Add test for consuming interface types inputs (#1900)
This commit adds a test suite for consuming interface types modules as input and producing a JS polyfill output. The tests are relatively simple today and don't exercise a ton of functionality, but they should hopefully cover the breadth of at least some basics of what wasm interface types supports today. A few small fixes were applied along the way, such as: * Don't require modules to have a stack pointer * Allow passing `*.wat`, `*.wit`, or `*.wasm` files as input to `wasm-bindgen` instead of always requiring `*.wasm`.
This commit is contained in:
@ -33,7 +33,7 @@ pub fn get_memory(module: &Module) -> Result<MemoryId, Error> {
|
||||
///
|
||||
/// It must have been previously added to the module's exports via
|
||||
/// `export_shadow_stack_pointer`.
|
||||
pub fn get_shadow_stack_pointer(module: &Module) -> Result<GlobalId, Error> {
|
||||
pub fn get_shadow_stack_pointer(module: &Module) -> Option<GlobalId> {
|
||||
let candidates = module
|
||||
.globals
|
||||
.iter()
|
||||
@ -48,12 +48,10 @@ pub fn get_shadow_stack_pointer(module: &Module) -> Result<GlobalId, Error> {
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let ssp = match candidates.len() {
|
||||
0 => bail!("could not find the shadow stack pointer for the module"),
|
||||
match candidates.len() {
|
||||
0 => None,
|
||||
// TODO: have an actual check here.
|
||||
1 => candidates[0].id(),
|
||||
_ => bail!("too many mutable globals to infer which is the shadow stack pointer"),
|
||||
};
|
||||
|
||||
Ok(ssp)
|
||||
1 => Some(candidates[0].id()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user