summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2019-10-09 13:40:06 -0700
committerGitHub <noreply@github.com>2019-10-09 13:40:06 -0700
commit13725e54f845ec84947130aaa888b4c11e53f9af (patch)
tree37284c425c6e2bf62d112b3fb299c03e3e7f73e2 /src
parentd0f538ef24853e88d97f9f1aee3baa6414ac2b13 (diff)
downloadbinaryen-13725e54f845ec84947130aaa888b4c11e53f9af.tar.gz
binaryen-13725e54f845ec84947130aaa888b4c11e53f9af.tar.bz2
binaryen-13725e54f845ec84947130aaa888b4c11e53f9af.zip
Make try body with multiple instructions roundtrip (#2374)
Previously we didn't print an additional block when there are multiple instructions within a `try` body, so those wast files cannot be parsed correctly, because the wast parser assumes there are two bodies within a `try` scope: a try body and a catch body. We don't need to print an additional block for a `catch` body because `(catch ...)` itself serves as a scope.
Diffstat (limited to 'src')
-rw-r--r--src/passes/Print.cpp2
-rw-r--r--src/wasm/wasm-s-parser.cpp2
2 files changed, 2 insertions, 2 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);