mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
wasm_interp: Handle calls to imports
This commit is contained in:
parent
b10ac827f1
commit
c866ce6b09
6 changed files with 103 additions and 34 deletions
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue