summaryrefslogtreecommitdiff
path: root/src/passes/Print.cpp
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2020-05-11 10:51:07 -0700
committerGitHub <noreply@github.com>2020-05-11 10:51:07 -0700
commit3de8c98b682e1347e5c50c58eaddc4b01f3e26ab (patch)
treec068fef90f72839106f6f15f48f34c12d526ef99 /src/passes/Print.cpp
parent91ec2ee5bedefc4736fcda78ae39298846aeeb41 (diff)
downloadbinaryen-3de8c98b682e1347e5c50c58eaddc4b01f3e26ab.tar.gz
binaryen-3de8c98b682e1347e5c50c58eaddc4b01f3e26ab.tar.bz2
binaryen-3de8c98b682e1347e5c50c58eaddc4b01f3e26ab.zip
Make try body start with 'do' (#2846)
In WebAssembly/exception-handling#52, We decided to put `try` bodies in a `do` clause to be more consistent with `catch`. - Before ```wast (try ... (catch ... ) ) ``` - After ```wast (try (do ... ) (catch ... ) ) ``` Another upside of this change is when there are multiple instructions within a `try` body, we no longer need to wrap them in a `block`.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r--src/passes/Print.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index a87eae325..0839b3feb 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -1930,9 +1930,11 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
}
// try-catch-end is written in the folded wat format as
// (try
+ // (do
// ...
+ // )
// (catch
- // ...
+ // ...
// )
// )
// The parenthesis wrapping 'catch' is just a syntax and does not affect
@@ -1941,7 +1943,12 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
o << '(';
PrintExpressionContents(currFunction, o).visit(curr);
incIndent();
- maybePrintImplicitBlock(curr->body, false);
+ doIndent(o, indent);
+ o << "(do";
+ incIndent();
+ maybePrintImplicitBlock(curr->body, true);
+ decIndent();
+ o << "\n";
doIndent(o, indent);
o << "(catch";
incIndent();