1#![forbid(unsafe_code)]
2#![warn(clippy::dbg_macro)]
3
4extern crate wain_ast;
5
6pub mod trap;
7
8mod cast;
9mod globals;
10mod import;
11mod memory;
12mod runtime;
13mod stack;
14mod table;
15mod value;
16
17pub use import::{check_func_signature, DefaultImporter, ImportInvalidError, ImportInvokeError, Importer};
18pub use memory::Memory;
19pub use runtime::Runtime;
20pub use stack::Stack;
21pub use value::Value;
22
23use std::io;
24use trap::Result;
25use wain_ast::Module;
26
27pub fn execute(module: &Module<'_>) -> Result<()> {
41 let stdin = io::stdin();
42 let stdout = io::stdout();
43 let importer = DefaultImporter::with_stdio(stdin.lock(), stdout.lock());
44 let mut runtime = Runtime::instantiate(module, importer)?;
45 if runtime.module().entrypoint.is_none() {
46 runtime.invoke("_start", &[])?;
47 }
48 Ok(())
49}