Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
butterunderflow committed Dec 1, 2024
1 parent ab67f04 commit d0052b8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 32 deletions.
3 changes: 1 addition & 2 deletions src/main/scala/wasm/MiniWasmFX.scala
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,8 @@ case class EvaluatorFX(module: ModuleInstance) {

// resumable try-catch exception handling:
case TryCatch(es1, es2) =>
// push trail1 to join point
// put trail1 into join point
val join: MCont[Ans] = (newStack) => eval(rest, stack, frame, kont, trail1, mkont, trail2, h)
// todo: update comment here
// here we clear the trail2, to forbid breaking out of the try-catch block
val newHandler: Handler[Ans] = (newStack) => eval(es2, newStack, frame, init: Cont[Ans], List(), join, List(), h)
eval(es1, List(), frame, init: Cont[Ans], List(), join, List(), newHandler)
Expand Down
59 changes: 29 additions & 30 deletions src/test/scala/genwasym/TestFx.scala
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,39 @@ class TestFx extends FunSuite {
test("try-catch-block") {
testFileOutput("./benchmarks/wasm/trycatch/try_catch_block.wat", List(1, 2, 3, 4, 5))
}

test("try-catch-br2") {
testFileOutput("./benchmarks/wasm/trycatch/try_catch_br2.wat", List(1, 2, 6, 4, 5))
}

test("try-catch-br") {
// break out of try block is not allowed
assertThrows[IndexOutOfBoundsException] {
testFileOutput("./benchmarks/wasm/trycatch/try_catch_br.wat", List(1, 2, 6))
}
}

test("try-catch-throw-twice") {
testFileOutput("./benchmarks/wasm/trycatch/throw_twice.wat", List(1, 2, 6, 2, 3, 4, 4, 5))
}

// Note: the interaction between try-catch and block is not well-defined yet
test("try-catch-throw-twice2") {
testFileOutput("./benchmarks/wasm/trycatch/throw_twice2.wat", List(1, 2, 6, 2, 3, 4, 4, 5))
}

test("try-catch-br3") {
testFileOutput("./benchmarks/wasm/trycatch/try_catch_br3.wat", List(1, 2, 3, 4, 5))
}

test("try-catch-catch-br") {
testFileOutput("./benchmarks/wasm/trycatch/try_catch_catch_br.wat", List(1, 2, 6, 4, 6, 5))
}

/* REAL WASMFX STUFF */
// TODO: test after implemented cont_bind3
// test("simple script") {
// TestWastFile("./benchmarks/wasm/wasmfx/cont_bind3.bin.wast")
// }

test("cont") {
// testFile("./benchmarks/wasm/wasmfx/callcont.wast", None, ExpInt(11))
Expand Down Expand Up @@ -172,34 +200,5 @@ class TestFx extends FunSuite {
test("cont_bind_5") {
testWastFile("./benchmarks/wasm/wasmfx/cont_bind5.bin.wast")
}
// test("test_cont") {
// testFile("./benchmarks/wasm/wasmfx/test_cont-strip.wast")
// }

test("try-catch-br2") {
testFileOutput("./benchmarks/wasm/trycatch/try_catch_br2.wat", List(1, 2, 6, 4, 5))
}

test("try-catch-br") {
// break out of try block is not allowed
assertThrows[IndexOutOfBoundsException] {
testFileOutput("./benchmarks/wasm/trycatch/try_catch_br.wat", List(1, 2, 6))
}
}

test("try-catch-throw-twice") {
testFileOutput("./benchmarks/wasm/trycatch/throw_twice.wat", List(1, 2, 6, 2, 3, 4, 4, 5))
}

test("try-catch-throw-twice2") {
testFileOutput("./benchmarks/wasm/trycatch/throw_twice2.wat", List(1, 2, 6, 2, 3, 4, 4, 5))
}

test("try-catch-br3") {
testFileOutput("./benchmarks/wasm/trycatch/try_catch_br3.wat", List(1, 2, 3, 4, 5))
}

test("try-catch-catch-br") {
testFileOutput("./benchmarks/wasm/trycatch/try_catch_catch_br.wat", List(1, 2, 6, 4, 6, 5))
}
}

0 comments on commit d0052b8

Please sign in to comment.