Skip to content

Commit 6c80824

Browse files
authored
wasmparser: Add TypesRef methods to expose some rec group-related data (#1498)
We already compute and store all of this internally for validation, just need to expose some of it so that Wasmtime can re-canonicalize rec groups from a Wasm module context to a whole engine context.
1 parent fcb4f18 commit 6c80824

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

crates/wasmparser/src/validator/types.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,22 @@ impl<'a> TypesRef<'a> {
15181518
self.list.get(id)
15191519
}
15201520

1521+
/// Get the id of the rec group that the given type id was defined within.
1522+
pub fn rec_group_id_of(&self, id: CoreTypeId) -> RecGroupId {
1523+
self.list.rec_group_id_of(id)
1524+
}
1525+
1526+
/// Get the types within a rec group.
1527+
pub fn rec_group_elements(&self, id: RecGroupId) -> impl ExactSizeIterator<Item = CoreTypeId> {
1528+
let range = &self.list.rec_group_elements[id];
1529+
(range.start.index..range.end.index).map(|index| CoreTypeId { index })
1530+
}
1531+
1532+
/// Get the super type of the given type id, if any.
1533+
pub fn supertype_of(&self, id: CoreTypeId) -> Option<CoreTypeId> {
1534+
self.list.supertype_of(id)
1535+
}
1536+
15211537
/// Gets a core WebAssembly type id from a type index.
15221538
///
15231539
/// Note that this is in contrast to [`TypesRef::component_type_at`] which

0 commit comments

Comments
 (0)