diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/example/c-api-kitchen-sink.c | 11 | ||||
-rw-r--r-- | test/example/c-api-kitchen-sink.txt | 14 |
2 files changed, 25 insertions, 0 deletions
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index 4cbbb8fb5..84f04b45a 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -378,6 +378,17 @@ void test_relooper() { BinaryenFunctionRef sinker = BinaryenAddFunction(module, "nontrivial-loop-plus-phi-to-head", v, localTypes, 1, body); } + BinaryenFunctionTypeRef i = BinaryenAddFunctionType(module, "i", BinaryenInt32(), NULL, 0); + + { // return in a block + RelooperRef relooper = RelooperCreate(); + BinaryenExpressionRef listList[] = { makeInt32(module, 42), BinaryenReturn(module, makeInt32(module, 1337)) }; + BinaryenExpressionRef list = BinaryenBlock(module, "the-list", listList, 2); + RelooperBlockRef block = RelooperAddBlock(relooper, list); + BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, block, 0, module); + BinaryenFunctionRef sinker = BinaryenAddFunction(module, "return", i, localTypes, 1, body); + } + assert(BinaryenModuleValidate(module)); printf("raw:\n"); diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index a5fa729c8..e4973ba16 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -370,6 +370,7 @@ raw: (module (memory 0) (type $v (func)) + (type $i (func (result i32))) (func $just-one-block (type $v) (local $0 i32) (i32.const 1337) @@ -630,14 +631,27 @@ raw: ) ) ) + (func $return (type $i) (result i32) + (local $0 i32) + (block $the-list + (i32.const 42) + (return + (i32.const 1337) + ) + ) + ) ) optimized: (module (memory 0) (type $v (func)) + (type $i (func (result i32))) (func $just-one-block (type $v) (nop) ) + (func $return (type $i) (result i32) + (i32.const 1337) + ) ) module loaded from binary form: (module |