wasmtime: Support reference types in the Rust API
This is a mix of exposing new things (e.g. a `Table::fill` method) and extending existing support to `externref`s (e.g. `Table::new`). Part of #929
This commit is contained in:
@@ -494,6 +494,16 @@ impl Instance {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn defined_table_fill(
|
||||
&self,
|
||||
table_index: DefinedTableIndex,
|
||||
dst: u32,
|
||||
val: TableElement,
|
||||
len: u32,
|
||||
) -> Result<(), Trap> {
|
||||
self.tables.get(table_index).unwrap().fill(dst, val, len)
|
||||
}
|
||||
|
||||
// Get table element by index.
|
||||
fn table_get(&self, table_index: DefinedTableIndex, index: u32) -> Option<TableElement> {
|
||||
self.tables
|
||||
@@ -1115,6 +1125,21 @@ impl InstanceHandle {
|
||||
self.instance().table_set(table_index, index, val)
|
||||
}
|
||||
|
||||
/// Fill a region of the table.
|
||||
///
|
||||
/// Returns an error if the region is out of bounds or val is not of the
|
||||
/// correct type.
|
||||
pub fn defined_table_fill(
|
||||
&self,
|
||||
table_index: DefinedTableIndex,
|
||||
dst: u32,
|
||||
val: TableElement,
|
||||
len: u32,
|
||||
) -> Result<(), Trap> {
|
||||
self.instance()
|
||||
.defined_table_fill(table_index, dst, val, len)
|
||||
}
|
||||
|
||||
/// Get a table defined locally within this module.
|
||||
pub fn get_defined_table(&self, index: DefinedTableIndex) -> &Table {
|
||||
self.instance().get_defined_table(index)
|
||||
|
||||
Reference in New Issue
Block a user