add platform module providing implementation of random functions

This commit is contained in:
2021-11-08 23:16:17 +01:00
parent 35ff01d7a8
commit 3be4e7b101
5 changed files with 38 additions and 1 deletions

View File

@@ -61,6 +61,8 @@ fn main() -> Result<()> {
let mut loader = Loader::new(&engine)?;
let platform_module = wasmtime::Module::new(&engine, include_bytes!("../platform/platform.wasm"))?;
let module = wasmtime::Module::new(&engine, loader.load(&uw8_module)?)?;
let mut store = wasmtime::Store::new(&engine, ());
@@ -93,6 +95,12 @@ fn main() -> Result<()> {
)?;
}
let platform_instance = linker.instantiate(&mut store, &platform_module)?;
for export in platform_instance.exports(&mut store) {
linker.define("env", export.name(), export.into_func().expect("platform surely only exports functions"))?;
}
let instance = linker.instantiate(&mut store, &module)?;
let tic = instance.get_typed_func::<i32, (), _>(&mut store, "tic")?;