rust runtime
build / build (push) Failing after 1m1s

This commit is contained in:
2026-07-17 23:17:38 -06:00
parent 85d34883a6
commit aa5b45ec76
10 changed files with 1951 additions and 10 deletions
+5
View File
@@ -0,0 +1,5 @@
use wasmtime::*;
pub fn say_hi (_caller : Caller<'_, u32>) {
println! ("hiiii~")
}
+35
View File
@@ -0,0 +1,35 @@
mod gyehoek;
use std::io;
use std::io::Read;
use clio::*;
use clap::Parser;
use wasmtime::*;
/// A runtime for Gyehoek scheme.
#[derive(Parser, Debug)]
#[command(name = "gyehoek", version, about, long_about = None)]
struct Args {
/// Path to Wasm binary or textual source
#[clap(value_parser)]
wasm: Input,
}
fn read<R : Read> (mut rdr : R) -> io::Result<Vec<u8>> {
let mut buf = vec! [];
rdr.read_to_end (&mut buf)?;
Ok (buf)
}
pub fn main () -> wasmtime::Result<()> {
let args = Args::parse ();
let engine = Engine::default ();
let module = Module::new (&engine, read (args.wasm)?)?;
let mut linker = Linker::new (&engine);
linker.func_wrap ("gyehoek", "say-hi", gyehoek::say_hi)?;
let mut store : Store<u32> = Store::new (&engine, 4);
let instance = linker.instantiate (&mut store, &module)?;
let main = instance.get_typed_func::<(),()> (&mut store, "main")?;
main.call (&mut store, ())?;
Ok (())
}