Skip to content

Commit

Permalink
some clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Kraks committed Oct 18, 2024
1 parent d13e106 commit ea3855a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
14 changes: 4 additions & 10 deletions src/main/scala/wasm/MiniWasm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions src/main/scala/wasm/Parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ea3855a

Please sign in to comment.