From 0a69f59df9a35aff0f53aacc0da81a44b4d5f4e6 Mon Sep 17 00:00:00 2001 From: Andrea Peruffo Date: Wed, 31 Jul 2024 16:32:22 +0100 Subject: [PATCH] fix the readmes --- README.md | 6 +++--- aot/README.md | 14 +++----------- wasi/README.md | 14 +++----------- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index ae4d6a12f..795c6855b 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ import com.dylibso.chicory.runtime.Instance; import java.io.File; // point this to your path on disk -WasmModule module = WasmModule.builder(new File("./factorial.wasm")).build(); +Module module = Module.builder(new File("./factorial.wasm")).build(); Instance instance = Instance.builder(module).build(); ``` @@ -171,7 +171,7 @@ copyFileFromWasmCorpus("count_vowels.rs.wasm", "count_vowels.wasm"); Build and instantiate this module: ```java -Instance instance = Instance.builder(WasmModule.builder(new File("./count_vowels.wasm")).build()).build(); +Instance instance = Instance.builder(Module.builder(new File("./count_vowels.wasm")).build()).build(); ExportFunction countVowels = instance.export("count_vowels"); ``` @@ -278,7 +278,7 @@ Now we just need to pass this host function in during our instantiation phase: ```java import com.dylibso.chicory.runtime.HostImports; var imports = new HostImports(new HostFunction[] {func}); -var instance = Instance.builder(WasmModule.builder(new File("./logger.wasm")).build()).withHostImports(imports).build(); +var instance = Instance.builder(Module.builder(new File("./logger.wasm")).build()).withHostImports(imports).build(); var logIt = instance.export("logIt"); logIt.apply(); // should print "Hello, World!" 10 times diff --git a/aot/README.md b/aot/README.md index 9769b13df..e7116afe2 100644 --- a/aot/README.md +++ b/aot/README.md @@ -15,17 +15,9 @@ To enable use the AotMachine factory when building the module: // ... import com.dylibso.chicory.wasm.Module; -import com.dylibso.chicory.wasm.WasmModule; +import com.dylibso.chicory.runtime.Instance; import com.dylibso.chicory.aot.AotMachine; // ... -var is = getClass().getResourceAsStream("compiled/basic.c.wasm"); -Instance. - -builder(Module.builder(is). - -build()). - -withMachineFactory(AotMachine::new). - -build(); +var is = ClassLoader.getSystemClassLoader().getResourceAsStream("compiled/basic.c.wasm"); +Instance.builder(Module.builder(is).build()).withMachineFactory(AotMachine::new).build(); ``` diff --git a/wasi/README.md b/wasi/README.md index 869e8a4a0..dc93dac86 100644 --- a/wasi/README.md +++ b/wasi/README.md @@ -155,8 +155,8 @@ import com.dylibso.chicory.log.SystemLogger; import com.dylibso.chicory.wasi.WasiOptions; import com.dylibso.chicory.wasi.WasiPreview1; import com.dylibso.chicory.wasm.Module; -import com.dylibso.chicory.wasm.WasmModule; import com.dylibso.chicory.runtime.HostImports; +import com.dylibso.chicory.runtime.Instance; import java.io.File; @@ -169,15 +169,7 @@ var wasi = new WasiPreview1(logger, WasiOptions.builder().build()); var imports = new HostImports(wasi.toHostFunctions()); // create the module and connect imports // this will execute the module if it's a WASI command-pattern module -Instance. - -builder(Module.builder(new File("hello-wasi.wasm")). - -build()). - -withHostImports(imports). - -build(); +Instance.builder(Module.builder(new File("hello-wasi.wasm")).build()).withHostImports(imports).build(); ``` > **Note**: Take note that we don't explicitly execute the module. The module will run when you instantiate it. This @@ -216,7 +208,7 @@ var imports = new HostImports(wasi.toHostFunctions()); // greet-wasi is a rust program that greets the string passed in stdin // instantiating will execute the module if it's a WASI command-pattern module -Instance.builder(WasmModule.builder(new File("greet-wasi.wasm")).build()).withHostImports(imports).build(); +Instance.builder(Module.builder(new File("greet-wasi.wasm")).build()).withHostImports(imports).build(); // check that we output the greeting assert(fakeStdout.toString().equals("Hello, Andrea!"));