Skip to content

Commit 4364d38

Browse files
authored
Add support for more *.wast syntax (#13042)
This is used in Wizard, for example, and is easy to support as well.
1 parent fc8a88d commit 4364d38

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

crates/wast/src/wast.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct WastContext {
1919
/// recently defined.
2020
current: Option<InstanceKind>,
2121
core_linker: Linker<()>,
22-
modules: HashMap<String, ModuleKind>,
22+
modules: HashMap<Option<String>, ModuleKind>,
2323
#[cfg(feature = "component-model")]
2424
component_linker: component::Linker<()>,
2525

@@ -645,18 +645,16 @@ impl WastContext {
645645
line: _,
646646
} => {
647647
let module = self.module_definition(&file)?;
648-
if let Some(name) = name {
649-
self.modules.insert(name.to_string(), module);
650-
}
648+
self.modules.insert(name.map(|s| s.to_string()), module);
651649
}
652650
ModuleInstance {
653651
instance,
654652
module,
655653
line: _,
656654
} => {
657-
let module = module
658-
.as_deref()
659-
.and_then(|n| self.modules.get(n))
655+
let module = self
656+
.modules
657+
.get(&module.as_ref().map(|s| s.to_string()))
660658
.cloned()
661659
.ok_or_else(|| format_err!("no module named {module:?}"))?;
662660
self.module(instance.as_deref(), &module)?;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
(module definition (func (export "f")))
2+
(module instance)
3+
4+
(invoke "f")
5+
(assert_return (invoke "f"))

0 commit comments

Comments
 (0)