From ea3855acd041594dcfd01951cb58da35d863084f Mon Sep 17 00:00:00 2001 From: Guannan Wei Date: Fri, 18 Oct 2024 19:40:22 +0200 Subject: [PATCH] some clean up --- src/main/scala/wasm/MiniWasm.scala | 14 ++++---------- src/main/scala/wasm/Parser.scala | 8 -------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/main/scala/wasm/MiniWasm.scala b/src/main/scala/wasm/MiniWasm.scala index d91e64c6..e691ec3e 100644 --- a/src/main/scala/wasm/MiniWasm.scala +++ b/src/main/scala/wasm/MiniWasm.scala @@ -186,7 +186,7 @@ object Evaluator { def getFuncType(module: ModuleInstance, ty: BlockType): FuncType = { ty match { - case VarBlockType(_, None) => ??? // TODO: fill this branch until we handle type index correctly + case VarBlockType(_, None) => ??? // TODO: fill this branch until we handle type index correctly case VarBlockType(_, Some(tipe)) => tipe case ValBlockType(Some(tipe)) => FuncType(List(), List(), List(tipe)) case ValBlockType(None) => FuncType(List(), List(), List()) @@ -299,12 +299,8 @@ object Evaluator { val (inputs, restStack) = stack.splitAt(funcTy.inps.size) val restK: Cont[Ans] = (retStack) => eval(rest, retStack.take(funcTy.out.size) ++ restStack, frame, kont, trail, ret) - - def loop(retStack: List[Value]): Ans = { - val k: Cont[Ans] = (retStack) => loop(retStack) // k is just same as loop - eval(inner, retStack.take(funcTy.inps.size), frame, restK, k :: trail, ret + 1) - } - + def loop(retStack: List[Value]): Ans = + eval(inner, retStack.take(funcTy.inps.size), frame, restK, loop _ :: trail, ret + 1) loop(inputs) case If(ty, thn, els) => val funcTy = getFuncType(frame.module, ty) @@ -378,9 +374,7 @@ object Evaluator { }) } - if (instrs.isEmpty) { - println("Warning: nothing is executed") - } + if (instrs.isEmpty) println("Warning: nothing is executed") val types = List() val funcs = module.definitions diff --git a/src/main/scala/wasm/Parser.scala b/src/main/scala/wasm/Parser.scala index b6155e39..e0139fb1 100644 --- a/src/main/scala/wasm/Parser.scala +++ b/src/main/scala/wasm/Parser.scala @@ -21,8 +21,6 @@ class GSWasmVisitor extends WatParserBaseVisitor[WIR] { /* Some helper functions */ - // TODO: see TODO in 2o1u-no-label.wat - val fnMap: HashMap[String, Int] = HashMap() // Note: we construct a mapping from indices to function-like definitions, which helps @@ -392,12 +390,6 @@ class GSWasmVisitor extends WatParserBaseVisitor[WIR] { } } - // override def visitCallInstrInstr(ctx: CallInstrInstrContext): WIR = { - // println(s"unimplemented parser for: ${ctx.getText}") - // ??? - // } - - override def visitBlockType(ctx: BlockTypeContext): BlockType = { if (ctx.typeUse != null) { // TODO: explicit type use