summaryrefslogtreecommitdiff
path: root/test/example
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2021-02-13 21:23:47 +0900
committerGitHub <noreply@github.com>2021-02-13 21:23:47 +0900
commitc12cc3f50c0ef798b218739fc3de06237ea2c5d5 (patch)
tree512a69360c953ac88f257fb7340a35bf895c4b6d /test/example
parentac3188facecb78ebaea1eec6cd6e4723a1a161fe (diff)
downloadbinaryen-c12cc3f50c0ef798b218739fc3de06237ea2c5d5.tar.gz
binaryen-c12cc3f50c0ef798b218739fc3de06237ea2c5d5.tar.bz2
binaryen-c12cc3f50c0ef798b218739fc3de06237ea2c5d5.zip
[EH] Update C and binaryen.js API for delegate (#3565)
This updates C and binaryen.js API to match the new `Try` structure to support `delegate`, added in #3561. Now `try` can take a name (which can be null) like a block, and also has an additional `delegateTarget` field argument which should only be used for try-delegate and otherwise null. This also adds several more variant of `makeTry` methods in wasm-builder. Some are for making try-delegate and some are for try-catch(_all).
Diffstat (limited to 'test/example')
-rw-r--r--test/example/c-api-kitchen-sink.c33
-rw-r--r--test/example/c-api-kitchen-sink.txt15
2 files changed, 46 insertions, 2 deletions
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c
index b45039c69..359203e8b 100644
--- a/test/example/c-api-kitchen-sink.c
+++ b/test/example/c-api-kitchen-sink.c
@@ -336,8 +336,11 @@ void test_core() {
BinaryenExpressionRef catchBody =
BinaryenDrop(module, BinaryenPop(module, BinaryenTypeInt32()));
BinaryenExpressionRef catchAllBody = BinaryenNop(module);
- BinaryenExpressionRef catchBodies[] = {catchBody, catchAllBody};
const char* catchEvents[] = {"a-event"};
+ BinaryenExpressionRef catchBodies[] = {catchBody, catchAllBody};
+ const char* emptyCatchEvents[] = {};
+ BinaryenExpressionRef emptyCatchBodies[] = {};
+ BinaryenExpressionRef nopCatchBody[] = {BinaryenNop(module)};
BinaryenType i32 = BinaryenTypeInt32();
BinaryenType i64 = BinaryenTypeInt64();
@@ -727,7 +730,33 @@ void test_core() {
BinaryenRefNull(module, BinaryenTypeEqref()),
BinaryenRefNull(module, BinaryenTypeEqref())),
// Exception handling
- BinaryenTry(module, tryBody, catchEvents, 1, catchBodies, 2),
+ BinaryenTry(module, NULL, tryBody, catchEvents, 1, catchBodies, 2, NULL),
+ // (try $try_outer
+ // (do
+ // (try
+ // (do
+ // (throw $a-event (i32.const 0))
+ // )
+ // (delegate $try_outer)
+ // )
+ // )
+ // (catch_all)
+ // )
+ BinaryenTry(module,
+ "try_outer",
+ BinaryenTry(module,
+ NULL,
+ tryBody,
+ emptyCatchEvents,
+ 0,
+ emptyCatchBodies,
+ 0,
+ "try_outer"),
+ emptyCatchEvents,
+ 0,
+ nopCatchBody,
+ 1,
+ NULL),
// Atomics
BinaryenAtomicStore(
module,
diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt
index f03e4ec6c..c3226690e 100644
--- a/test/example/c-api-kitchen-sink.txt
+++ b/test/example/c-api-kitchen-sink.txt
@@ -1775,6 +1775,21 @@ BinaryenFeatureAll: 8191
(nop)
)
)
+ (try $try_outer
+ (do
+ (try
+ (do
+ (throw $a-event
+ (i32.const 0)
+ )
+ )
+ (delegate $try_outer)
+ )
+ )
+ (catch_all
+ (nop)
+ )
+ )
(i32.atomic.store
(i32.const 0)
(i32.atomic.load