diff options
-rw-r--r-- | src/passes/Print.cpp | 2 | ||||
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 2 | ||||
-rw-r--r-- | test/exception-handling.wast | 16 | ||||
-rw-r--r-- | test/exception-handling.wast.from-wast | 21 | ||||
-rw-r--r-- | test/exception-handling.wast.fromBinary | 8 | ||||
-rw-r--r-- | test/exception-handling.wast.fromBinary.noDebugInfo | 6 | ||||
-rw-r--r-- | test/try-body-multiple-insts.wasm | bin | 0 -> 49 bytes | |||
-rw-r--r-- | test/try-body-multiple-insts.wasm.fromBinary | 26 |
8 files changed, 77 insertions, 4 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index a5b5e3c2b..95c6a0568 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -1768,7 +1768,7 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> { o << '('; PrintExpressionContents(currFunction, o).visit(curr); incIndent(); - maybePrintImplicitBlock(curr->body, true); + maybePrintImplicitBlock(curr->body, false); doIndent(o, indent); o << "(catch"; incIndent(); diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 72d262e63..f666abc25 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -1792,7 +1792,7 @@ Expression* SExpressionWasmBuilder::makeTry(Element& s) { ret->body = parseExpression(*s[i++]); } if (!elementStartsWith(*s[i], "catch")) { - throw ParseException("catch clause does not exist"); + throw ParseException("catch clause does not exist", s[i]->line, s[i]->col); } ret->catchBody = makeCatch(*s[i++]); ret->finalize(type); diff --git a/test/exception-handling.wast b/test/exception-handling.wast index cb3aee0d9..275350c61 100644 --- a/test/exception-handling.wast +++ b/test/exception-handling.wast @@ -5,6 +5,9 @@ (local.get $0) ) + (func $foo) + (func $bar) + (func $eh_test (local $exn exnref) (try (throw $e0 (i32.const 0)) @@ -36,5 +39,18 @@ (drop (exnref.pop)) ) ) + + ;; Multiple instructions within try and catch bodies + (try + (block + (call $foo) + (call $bar) + ) + (catch + (drop (exnref.pop)) + (call $foo) + (call $bar) + ) + ) ) ) diff --git a/test/exception-handling.wast.from-wast b/test/exception-handling.wast.from-wast index 7c431a89f..e3209518e 100644 --- a/test/exception-handling.wast.from-wast +++ b/test/exception-handling.wast.from-wast @@ -6,7 +6,13 @@ (func $exnref_test (; 0 ;) (type $FUNCSIG$ee) (param $0 exnref) (result exnref) (local.get $0) ) - (func $eh_test (; 1 ;) (type $FUNCSIG$v) + (func $foo (; 1 ;) (type $FUNCSIG$v) + (nop) + ) + (func $bar (; 2 ;) (type $FUNCSIG$v) + (nop) + ) + (func $eh_test (; 3 ;) (type $FUNCSIG$v) (local $exn exnref) (try (throw $e0 @@ -43,5 +49,18 @@ ) ) ) + (try + (block $block + (call $foo) + (call $bar) + ) + (catch + (drop + (exnref.pop) + ) + (call $foo) + (call $bar) + ) + ) ) ) diff --git a/test/exception-handling.wast.fromBinary b/test/exception-handling.wast.fromBinary index 1cff3d215..3151d1ea8 100644 --- a/test/exception-handling.wast.fromBinary +++ b/test/exception-handling.wast.fromBinary @@ -6,7 +6,13 @@ (func $exnref_test (; 0 ;) (type $0) (param $0 exnref) (result exnref) (local.get $0) ) - (func $eh_test (; 1 ;) (type $1) + (func $foo (; 1 ;) (type $1) + (nop) + ) + (func $bar (; 2 ;) (type $1) + (nop) + ) + (func $eh_test (; 3 ;) (type $1) (local $0 exnref) (try (throw $event$0 diff --git a/test/exception-handling.wast.fromBinary.noDebugInfo b/test/exception-handling.wast.fromBinary.noDebugInfo index 23ba7946c..3ef95033c 100644 --- a/test/exception-handling.wast.fromBinary.noDebugInfo +++ b/test/exception-handling.wast.fromBinary.noDebugInfo @@ -7,6 +7,12 @@ (local.get $0) ) (func $1 (; 1 ;) (type $1) + (nop) + ) + (func $2 (; 2 ;) (type $1) + (nop) + ) + (func $3 (; 3 ;) (type $1) (local $0 exnref) (try (throw $event$0 diff --git a/test/try-body-multiple-insts.wasm b/test/try-body-multiple-insts.wasm Binary files differnew file mode 100644 index 000000000..dd67f3e52 --- /dev/null +++ b/test/try-body-multiple-insts.wasm diff --git a/test/try-body-multiple-insts.wasm.fromBinary b/test/try-body-multiple-insts.wasm.fromBinary new file mode 100644 index 000000000..f52a1a3dc --- /dev/null +++ b/test/try-body-multiple-insts.wasm.fromBinary @@ -0,0 +1,26 @@ +(module + (type $0 (func)) + (func $0 (; 0 ;) (type $0) + (nop) + ) + (func $1 (; 1 ;) (type $0) + (nop) + ) + (func $2 (; 2 ;) (type $0) + (local $0 exnref) + (try + (block + (call $0) + (call $1) + ) + (catch + (drop + (exnref.pop) + ) + (call $0) + (call $1) + ) + ) + ) +) + |