diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2020-03-26 16:33:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-26 16:33:35 -0700 |
commit | 9101f65c7b18ab607c472a3d50b52db66497402f (patch) | |
tree | 9ffa1174a01162e750966ba39e7a3ca86c2e18ec /test/example/c-api-kitchen-sink.c | |
parent | ce6ae49863d7d2da54aabf9637ee299659f4bd0c (diff) | |
download | binaryen-9101f65c7b18ab607c472a3d50b52db66497402f.tar.gz binaryen-9101f65c7b18ab607c472a3d50b52db66497402f.tar.bz2 binaryen-9101f65c7b18ab607c472a3d50b52db66497402f.zip |
Tuple operations in C and JS APIs (#2711)
Adds functions for creating and inspecting tuple.make and
tuple.extract expressions in the C and JS APIs.
Diffstat (limited to 'test/example/c-api-kitchen-sink.c')
-rw-r--r-- | test/example/c-api-kitchen-sink.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index 883d1ff75..0158bd73d 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -272,6 +272,14 @@ void test_core() { BinaryenExpressionRef callOperands2[] = { makeInt32(module, 13), makeFloat64(module, 3.7) }; BinaryenExpressionRef callOperands4[] = { makeInt32(module, 13), makeInt64(module, 37), makeFloat32(module, 1.3f), makeFloat64(module, 3.7) }; BinaryenExpressionRef callOperands4b[] = { makeInt32(module, 13), makeInt64(module, 37), makeFloat32(module, 1.3f), makeFloat64(module, 3.7) }; + BinaryenExpressionRef tupleElements4a[] = {makeInt32(module, 13), + makeInt64(module, 37), + makeFloat32(module, 1.3f), + makeFloat64(module, 3.7)}; + BinaryenExpressionRef tupleElements4b[] = {makeInt32(module, 13), + makeInt64(module, 37), + makeFloat32(module, 1.3f), + makeFloat64(module, 3.7)}; BinaryenType iIfF_[4] = {BinaryenTypeInt32(), BinaryenTypeInt64(), @@ -714,6 +722,10 @@ void test_core() { BinaryenAtomicWait(module, temp6, temp6, temp16, BinaryenTypeInt32())), BinaryenDrop(module, BinaryenAtomicNotify(module, temp6, temp6)), BinaryenAtomicFence(module), + // Tuples + BinaryenTupleMake(module, tupleElements4a, 4), + BinaryenTupleExtract( + module, BinaryenTupleMake(module, tupleElements4b, 4), 2), // Push and pop BinaryenPush(module, BinaryenPop(module, BinaryenTypeInt32())), BinaryenPush(module, BinaryenPop(module, BinaryenTypeInt64())), @@ -735,11 +747,17 @@ void test_core() { BinaryenExpressionPrint(valueList[3]); // test printing a standalone expression // Make the main body of the function. and one block with a return value, one without - BinaryenExpressionRef value = BinaryenBlock(module, "the-value", valueList, sizeof(valueList) / sizeof(BinaryenExpressionRef), -1); + BinaryenExpressionRef value = + BinaryenBlock(module, + "the-value", + valueList, + sizeof(valueList) / sizeof(BinaryenExpressionRef), + BinaryenTypeAuto()); BinaryenExpressionRef droppedValue = BinaryenDrop(module, value); BinaryenExpressionRef nothing = BinaryenBlock(module, "the-nothing", &droppedValue, 1, -1); BinaryenExpressionRef bodyList[] = { nothing, makeInt32(module, 42) }; - BinaryenExpressionRef body = BinaryenBlock(module, "the-body", bodyList, 2, -1); + BinaryenExpressionRef body = + BinaryenBlock(module, "the-body", bodyList, 2, BinaryenTypeAuto()); // Create the function BinaryenType localTypes[] = {BinaryenTypeInt32(), BinaryenTypeExnref()}; |