File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
backend/jvm/src/main/kotlin/dev/suresh/wasm Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package dev.suresh.wasm
33import com.dylibso.chicory.experimental.aot.AotMachine
44import com.dylibso.chicory.runtime.HostFunction
55import com.dylibso.chicory.runtime.Instance
6- import com.dylibso.chicory.wasm.Module
76import com.dylibso.chicory.wasm.Parser
87import com.dylibso.chicory.wasm.types.ValueType
98import io.ktor.server.response.respondText
@@ -14,18 +13,19 @@ import io.ktor.server.routing.*
1413 * - [wasm-corpus](https://github.com/dylibso/chicory/tree/main/wasm-corpus/src/main/resources/compiled)
1514 * - [extism](https://github.com/extism/plugins/releases)
1615 */
17- val factWasmMod : Module by lazy {
16+ val factWasmInst : Instance by lazy {
1817 val wasmRes = Thread .currentThread().contextClassLoader.getResourceAsStream(" wasm/factorial.wasm" )
1918 // val wasmRes = object {}.javaClass.getResourceAsStream("wasm/factorial.wasm")
20- Parser .parse(wasmRes)
19+ val wasmMod = Parser .parse(wasmRes)
20+ Instance .builder(wasmMod).withMachineFactory(::AotMachine ).build()
2121}
2222
2323fun Routing.wasm () {
2424 route(" /wasm" ) {
2525 get(" fact" ) {
2626 val num = call.parameters[" num" ]?.toLongOrNull() ? : 5
27- val inst = Instance .builder(factWasmMod).withMachineFactory(:: AotMachine ).build()
28- val iterFact = inst .export(" iterFact" )
27+
28+ val iterFact = factWasmInst .export(" iterFact" )
2929 val fact = iterFact.apply (num)[0 ]
3030
3131 call.respondText(" WASM: Factorial($num ): $fact " )
You can’t perform that action at this time.
0 commit comments