Skip to content

Commit

Permalink
fix the readmes
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaTP committed Jul 31, 2024
1 parent b009345 commit 0a69f59
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 25 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
```

Expand Down Expand Up @@ -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");
```

Expand Down Expand Up @@ -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
Expand Down
14 changes: 3 additions & 11 deletions aot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
```
14 changes: 3 additions & 11 deletions wasi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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!"));
Expand Down

0 comments on commit 0a69f59

Please sign in to comment.