MCPcopy Create free account
hub / github.com/bluejekyll/wasmtime-java / WasmLinker

Class WasmLinker

src/main/java/net/bluejekyll/wasmtime/WasmLinker.java:8–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6import net.bluejekyll.wasmtime.proxy.WasmFunctionDef;
7
8public class WasmLinker extends AbstractOpaquePtr {
9 WasmLinker(long ptr) {
10 super(ptr, WasmLinker::freeLinker);
11 }
12
13 private static native void freeLinker(long ptr);
14
15 private static native void defineFunc(long ptr, String module, String name, long func_ptr);
16
17 private static native long instantiateNtv(long linker_ptr, long store_ptr, long module_ptr)
18 throws WasmtimeException;
19
20 /**
21 * @param module name of the module in which this function should be defined
22 * (like a class)
23 * @param name for the function to use
24 */
25 public void defineFunction(String module, String name, WasmFunction function) throws WasmtimeException {
26 WasmLinker.defineFunc(this.getPtr(), module, name, function.getPtr());
27 }
28
29 public void defineFunctions(WasmStore store, WasmExportable exportable) throws WasmtimeException {
30 List<WasmFunctionDef> functions = exportable.defineWasmFunctions(store);
31
32 for (WasmFunctionDef function : functions) {
33 this.defineFunction(function.getModuleName(), function.getFunctionName(), function.getFunction());
34 }
35 }
36
37 public WasmInstance instantiate(WasmStore store, WasmModule module) throws WasmtimeException {
38 return new WasmInstance(WasmLinker.instantiateNtv(this.getPtr(), store.getPtr(), module.getPtr()));
39 }
40}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…