Skip to content

Commit 8ce24b2

Browse files
committed
chore: minor cleanup
1 parent 0832a06 commit 8ce24b2

File tree

1 file changed

+5
-5
lines changed
  • backend/jvm/src/main/kotlin/dev/suresh/wasm

1 file changed

+5
-5
lines changed

backend/jvm/src/main/kotlin/dev/suresh/wasm/Wasm.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dev.suresh.wasm
33
import com.dylibso.chicory.experimental.aot.AotMachine
44
import com.dylibso.chicory.runtime.HostFunction
55
import com.dylibso.chicory.runtime.Instance
6-
import com.dylibso.chicory.wasm.Module
76
import com.dylibso.chicory.wasm.Parser
87
import com.dylibso.chicory.wasm.types.ValueType
98
import 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

2323
fun 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")

0 commit comments

Comments
 (0)