From 80d5ae469ba6b14791836ec83ad021dfa40ade98 Mon Sep 17 00:00:00 2001 From: Mica White Date: Sat, 31 Oct 2026 12:16:51 -0400 Subject: Fix import --- src/script/wasm.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src') 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 { Ok(context_ref(context).time.delta_time().as_nanos() as u64) } -pub fn linker(store: &mut Store) -> Result { +pub fn linker() -> Result { 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, -- cgit v1.3.1