Skip to content

Commit 058a9bc

Browse files
authored
Components: implement exception-tag translation in core module types. (#12122)
* Components: implement exception-tag translation in core module types. Fixes #12120. * Add `exceptions = true` config to wast.
1 parent 54826c0 commit 058a9bc

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

crates/environ/src/component/types_builder.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,16 @@ impl ComponentTypesBuilder {
411411
Table(ty) => EntityType::Table(self.convert_table_type(ty)?),
412412
Memory(ty) => EntityType::Memory((*ty).into()),
413413
Global(ty) => EntityType::Global(self.convert_global_type(ty)?),
414-
Tag(_) => bail!("exceptions proposal not implemented"),
414+
Tag(id) => {
415+
let func = self.module_types_builder_mut().intern_type(types, *id)?;
416+
let exc = self
417+
.module_types_builder_mut()
418+
.define_exception_type_for_tag(func);
419+
EntityType::Tag(crate::types::Tag {
420+
signature: func.into(),
421+
exception: exc.into(),
422+
})
423+
}
415424
FuncExact(_) => bail!("custom-descriptors proposal not implemented"),
416425
})
417426
}

tests/misc_testsuite/component-model/modules.wast

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
;;! reference_types = true
2+
;;! exceptions = true
23

34
(component $foo
45
(core module (export "a-module"))
@@ -477,3 +478,12 @@
477478

478479
(core instance (instantiate $import_globals (with "" (instance $m))))
479480
)
481+
482+
(component $tag-module
483+
(core module (export "m")
484+
(tag (export "t") (param i32))))
485+
(component
486+
(import "tag-module" (instance
487+
(export "m"
488+
(core module
489+
(export "t" (tag (param i32))))))))

0 commit comments

Comments
 (0)