diff options
| author | Mica White <botahamec@outlook.com> | 2026-10-31 12:16:51 -0400 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2026-10-31 12:16:51 -0400 |
| commit | 80d5ae469ba6b14791836ec83ad021dfa40ade98 (patch) | |
| tree | 91b22b8cf697dac3804343993f77b152e8a50ee6 /src/script/wasm.rs | |
| parent | fde01cceb898b944b646a8fed1ce81cb14e523ef (diff) | |
Fix import
Diffstat (limited to 'src/script/wasm.rs')
| -rw-r--r-- | src/script/wasm.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/script/wasm.rs b/src/script/wasm.rs index cb08ba2..975f798 100644 --- a/src/script/wasm.rs +++ b/src/script/wasm.rs @@ -8,7 +8,7 @@ use crossterm::{ event::KeyCode, style::{Attribute, Attributes, Color, ContentStyle}, }; -use tinywasm::{FuncContext, HostFunction, Imports, ModuleInstance, Store}; +use tinywasm::{FuncContext, HostFunction, Imports, ModuleInstance}; use crate::{ buffer::Cell, @@ -45,8 +45,8 @@ impl Default for WasmRunner { impl WasmRunner { pub fn new() -> Self { let engine = tinywasm::Engine::default(); - let mut store = tinywasm::Store::new(engine.clone()); - let linker = linker(&mut store).unwrap(); + let store = tinywasm::Store::new(engine.clone()); + let linker = linker().unwrap(); let store = Arc::new(spin::Mutex::new(store)); Self { engine, @@ -60,7 +60,7 @@ impl WasmRunner { let instance = tinywasm::ModuleInstance::instantiate( &mut self.store.lock(), &module, - Some(self.linker.clone()), + Some(&self.linker), )?; Ok(WasmModule { instance }) } @@ -1032,17 +1032,16 @@ fn delta_time(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result<u64> { Ok(context_ref(context).time.delta_time().as_nanos() as u64) } -pub fn linker(store: &mut Store) -> Result<Imports, tinywasm::Error> { +pub fn linker() -> Result<Imports, tinywasm::Error> { macro_rules! add_fns { - ($linker: expr, $store: expr, [$($func: ident),*]) => { - $($linker.define("tortuise", stringify!($func), HostFunction::from($store, $func));)* + ($linker: expr, [$($func: ident),*]) => { + $($linker.define("tortuise", stringify!($func), HostFunction::from($func));)* }; } let mut linker = Imports::new(); add_fns!( linker, - store, [ add_cell, add_eternal_cell, |
