wasm_interp: Handle calls to imports

This commit is contained in:
Brian Carroll 2022-12-01 20:41:38 +00:00
parent b10ac827f1
commit c866ce6b09
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0
6 changed files with 103 additions and 34 deletions

View file

@ -24,3 +24,26 @@ pub trait ImportDispatcher {
memory: &mut [u8],
) -> Option<Value>;
}
pub const DEFAULT_IMPORTS: DefaultImportDispatcher = DefaultImportDispatcher {};
pub struct DefaultImportDispatcher {}
impl ImportDispatcher for DefaultImportDispatcher {
fn dispatch(
&mut self,
module_name: &str,
function_name: &str,
arguments: &[Value],
memory: &mut [u8],
) -> Option<Value> {
if module_name == wasi::MODULE_NAME {
wasi::dispatch(function_name, arguments, memory)
} else {
panic!(
"DefaultImportDispatcher does not implement {}.{}",
module_name, function_name
);
}
}
}