From f26f497131923886889deb4b843b179518888b1f Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 13 Jul 2024 14:10:40 +0900 Subject: feat: add examples/hello-world --- examples/hello-world/index.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 examples/hello-world/index.php (limited to 'examples') diff --git a/examples/hello-world/index.php b/examples/hello-world/index.php new file mode 100644 index 0000000..9b0b1bd --- /dev/null +++ b/examples/hello-world/index.php @@ -0,0 +1,35 @@ +decode(); + +$store = Store::empty(); +$linker = new Linker($store); + +$linker->register('', 'putc', Extern::Func(FuncInst::Host(new FuncType([ValType::I32], []), function (Runtime $runtime, int $c) { printf('%c', $c); }))); + +$runtime = Runtime::instantiate($store, $module, $linker->resolve($module)); + +$runtime->invoke('main', []); -- cgit v1.2.3-70-g09d2