| 6 | import net.bluejekyll.wasmtime.proxy.WasmFunctionDef; |
| 7 | |
| 8 | public 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…