mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-17 06:51:24 +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:
@ -264,8 +264,10 @@ impl Bindgen {
|
||||
(mem::replace(m, blank_module), &name[..])
|
||||
}
|
||||
Input::Path(ref path) => {
|
||||
let contents = fs::read(&path)
|
||||
let wasm = wit_text::parse_file(&path)
|
||||
.with_context(|| format!("failed to read `{}`", path.display()))?;
|
||||
wit_validator::validate(&wasm)
|
||||
.with_context(|| format!("failed to validate `{}`", path.display()))?;
|
||||
let module = walrus::ModuleConfig::new()
|
||||
// Skip validation of the module as LLVM's output is
|
||||
// generally already well-formed and so we won't gain much
|
||||
@ -278,7 +280,7 @@ impl Bindgen {
|
||||
.generate_name_section(!self.remove_name_section)
|
||||
.generate_producers_section(!self.remove_producers_section)
|
||||
.on_parse(wit_walrus::on_parse)
|
||||
.parse(&contents)
|
||||
.parse(&wasm)
|
||||
.context("failed to parse input file as wasm")?;
|
||||
let stem = match &self.out_name {
|
||||
Some(name) => &name,
|
||||
|
@ -92,8 +92,8 @@ pub fn process(
|
||||
|
||||
impl<'a> Context<'a> {
|
||||
fn init(&mut self) -> Result<(), Error> {
|
||||
let stack_pointer = wasm_bindgen_wasm_conventions::get_shadow_stack_pointer(self.module)?;
|
||||
self.aux.shadow_stack_pointer = Some(stack_pointer);
|
||||
self.aux.shadow_stack_pointer =
|
||||
wasm_bindgen_wasm_conventions::get_shadow_stack_pointer(self.module);
|
||||
|
||||
// Make a map from string name to ids of all exports
|
||||
for export in self.module.exports.iter() {
|
||||
|
Reference in New Issue
Block a user