diff --git a/pom.xml b/pom.xml index fc6cd6a..c6098c9 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,7 @@ 11 - 1.0.0-M1 + 1.0.0-M2 3.8.1 3.10.1 diff --git a/src/main/java/org/extism/chicory/sdk/ChicoryModule.java b/src/main/java/org/extism/chicory/sdk/ChicoryModule.java index cb54636..3c68d33 100644 --- a/src/main/java/org/extism/chicory/sdk/ChicoryModule.java +++ b/src/main/java/org/extism/chicory/sdk/ChicoryModule.java @@ -2,8 +2,8 @@ import com.dylibso.chicory.experimental.aot.AotMachine; import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.Module; import com.dylibso.chicory.wasm.Parser; +import com.dylibso.chicory.wasm.WasmModule; import java.nio.file.Path; @@ -11,7 +11,7 @@ class ChicoryModule { static final boolean IS_NATIVE_IMAGE_AOT = Boolean.getBoolean("com.oracle.graalvm.isaot"); - static Module fromWasm(ManifestWasm m) { + static WasmModule fromWasm(ManifestWasm m) { if (m instanceof ManifestWasmBytes) { ManifestWasmBytes mwb = (ManifestWasmBytes) m; return Parser.parse(mwb.bytes); diff --git a/src/main/java/org/extism/chicory/sdk/DependencyGraph.java b/src/main/java/org/extism/chicory/sdk/DependencyGraph.java index 89d736e..a84032b 100644 --- a/src/main/java/org/extism/chicory/sdk/DependencyGraph.java +++ b/src/main/java/org/extism/chicory/sdk/DependencyGraph.java @@ -4,12 +4,11 @@ import com.dylibso.chicory.runtime.ExportFunction; import com.dylibso.chicory.runtime.HostFunction; import com.dylibso.chicory.runtime.ImportFunction; -import com.dylibso.chicory.runtime.ImportValue; import com.dylibso.chicory.runtime.ImportValues; import com.dylibso.chicory.runtime.Instance; import com.dylibso.chicory.runtime.Store; import com.dylibso.chicory.runtime.WasmFunctionHandle; -import com.dylibso.chicory.wasm.Module; +import com.dylibso.chicory.wasm.WasmModule; import com.dylibso.chicory.wasm.types.Export; import com.dylibso.chicory.wasm.types.ExportSection; import com.dylibso.chicory.wasm.types.ExternalType; @@ -17,7 +16,6 @@ import com.dylibso.chicory.wasm.types.FunctionType; import com.dylibso.chicory.wasm.types.Import; import com.dylibso.chicory.wasm.types.ImportSection; -import com.dylibso.chicory.wasm.types.Value; import java.util.ArrayList; import java.util.HashMap; @@ -36,7 +34,7 @@ class DependencyGraph { private final Logger logger; private final Map> registeredSymbols = new HashMap<>(); - private final Map modules = new HashMap<>(); + private final Map modules = new HashMap<>(); private final Set hostModules = new HashSet<>(); private final Map instances = new HashMap<>(); private final Map trampolines = new HashMap<>(); @@ -93,7 +91,7 @@ private void checkCollision(String moduleName, String symbol) { /** * Register a Module with the given name. */ - public void registerModule(String name, Module m) { + public void registerModule(String name, WasmModule m) { checkCollision(name, null); ExportSection exportSection = m.exportSection(); @@ -113,7 +111,7 @@ public void registerSymbol(String name, String symbol) { public boolean validate() { boolean valid = true; for (var kv : modules.entrySet()) { - Module m = kv.getValue(); + WasmModule m = kv.getValue(); ImportSection imports = m.importSection(); for (int i = 0; i < imports.importCount(); i++) { @@ -156,7 +154,7 @@ public Instance instantiate() { while (!unresolved.isEmpty()) { String moduleId = unresolved.peek(); - Module m = this.modules.get(moduleId); + WasmModule m = this.modules.get(moduleId); boolean satisfied = true; List trampolines = new ArrayList<>(); ImportSection imports = m.importSection(); @@ -217,7 +215,7 @@ public Instance instantiate() { } private Instance instantiate(String moduleId, List moreHostFunctions) { - Module m = this.modules.get(moduleId); + WasmModule m = this.modules.get(moduleId); Objects.requireNonNull(m); ImportValues importValues = @@ -253,7 +251,7 @@ private ImportValues mergeImportValues(ImportValues hostImports, List pair. // Trampolines are not registered into the store, as they are not "real" functions. // They are instead kept separately and passed explicitly to the instance. diff --git a/src/test/java/org/extism/chicory/sdk/DependencyGraphTest.java b/src/test/java/org/extism/chicory/sdk/DependencyGraphTest.java index 6537e5d..359dceb 100644 --- a/src/test/java/org/extism/chicory/sdk/DependencyGraphTest.java +++ b/src/test/java/org/extism/chicory/sdk/DependencyGraphTest.java @@ -3,7 +3,7 @@ import com.dylibso.chicory.log.SystemLogger; import com.dylibso.chicory.runtime.Instance; import com.dylibso.chicory.wasi.WasiPreview1; -import com.dylibso.chicory.wasm.Module; +import com.dylibso.chicory.wasm.WasmModule; import junit.framework.TestCase; import java.io.IOException; @@ -38,10 +38,10 @@ public void testCircularDepsMore() throws IOException { InputStream mainBytes = this.getClass().getResourceAsStream("/circular-import-more/circular-import-main.wasm"); - Module add = parse(addBytes); - Module sub = parse(subBytes); - Module expr = parse(exprBytes); - Module main = parse(mainBytes); + WasmModule add = parse(addBytes); + WasmModule sub = parse(subBytes); + WasmModule expr = parse(exprBytes); + WasmModule main = parse(mainBytes); { DependencyGraph dg = new DependencyGraph(new SystemLogger()); @@ -74,7 +74,7 @@ public void testCircularDepsMore() throws IOException { public void testHostFunctionDeps() throws IOException { InputStream requireWasi = this.getClass().getResourceAsStream("/host-functions/import-wasi.wasm"); - Module requireWasiM = parse(requireWasi); + WasmModule requireWasiM = parse(requireWasi); DependencyGraph dg = new DependencyGraph(new SystemLogger()); dg.registerFunctions(wasiPreview1().toHostFunctions()); @@ -88,7 +88,7 @@ public void testHostFunctionDeps() throws IOException { public void testInstantiate() throws IOException { InputStream requireWasi = this.getClass().getResourceAsStream("/host-functions/import-wasi.wasm"); - Module requireWasiM = parse(requireWasi); + WasmModule requireWasiM = parse(requireWasi); DependencyGraph dg = new DependencyGraph(new SystemLogger()); dg.registerFunctions(wasiPreview1().toHostFunctions());