Skip to content

Commit 648f424

Browse files
committed
Attempt to fix failing test case
While the additional type argument to BinaryenBlock does not break JS, it breaks the C API, of course.
1 parent d846db3 commit 648f424

5 files changed

+34
-34
lines changed

src/binaryen-c.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ BinaryenExpressionRef BinaryenBlock(BinaryenModuleRef module, const char* name,
320320
auto id = noteExpression(ret);
321321
std::cout << " expressions[" << id << "] = BinaryenBlock(the_module, ";
322322
traceNameOrNULL(name);
323-
std::cout << ", children, " << numChildren << ");\n";
323+
std::cout << ", children, " << numChildren << ", " << type << ");\n";
324324
std::cout << " }\n";
325325
}
326326

test/example/c-api-kitchen-sink.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ void test_core() {
182182
makeBinary(module, BinaryenGtFloat64(), 4),
183183
makeBinary(module, BinaryenGeFloat32(), 3),
184184
// All the rest
185-
BinaryenBlock(module, NULL, NULL, 0), // block with no name
185+
BinaryenBlock(module, NULL, NULL, 0, 0), // block with no name and no type
186186
BinaryenIf(module, temp1, temp2, temp3),
187187
BinaryenIf(module, temp4, temp5, NULL),
188188
BinaryenLoop(module, "in", makeInt32(module, 0)),
@@ -224,11 +224,11 @@ void test_core() {
224224
BinaryenExpressionPrint(valueList[3]); // test printing a standalone expression
225225

226226
// Make the main body of the function. and one block with a return value, one without
227-
BinaryenExpressionRef value = BinaryenBlock(module, "the-value", valueList, sizeof(valueList) / sizeof(BinaryenExpressionRef));
227+
BinaryenExpressionRef value = BinaryenBlock(module, "the-value", valueList, sizeof(valueList) / sizeof(BinaryenExpressionRef), 0);
228228
BinaryenExpressionRef droppedValue = BinaryenDrop(module, value);
229-
BinaryenExpressionRef nothing = BinaryenBlock(module, "the-nothing", &droppedValue, 1);
229+
BinaryenExpressionRef nothing = BinaryenBlock(module, "the-nothing", &droppedValue, 1, 0);
230230
BinaryenExpressionRef bodyList[] = { nothing, makeInt32(module, 42) };
231-
BinaryenExpressionRef body = BinaryenBlock(module, "the-body", bodyList, 2);
231+
BinaryenExpressionRef body = BinaryenBlock(module, "the-body", bodyList, 2, 0);
232232

233233
// Create the function
234234
BinaryenType localTypes[] = { BinaryenInt32() };
@@ -460,7 +460,7 @@ void test_relooper() {
460460
{ // return in a block
461461
RelooperRef relooper = RelooperCreate();
462462
BinaryenExpressionRef listList[] = { makeCallCheck(module, 42), BinaryenReturn(module, makeInt32(module, 1337)) };
463-
BinaryenExpressionRef list = BinaryenBlock(module, "the-list", listList, 2);
463+
BinaryenExpressionRef list = BinaryenBlock(module, "the-list", listList, 2, 0);
464464
RelooperBlockRef block = RelooperAddBlock(relooper, list);
465465
BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, block, 0, module);
466466
BinaryenFunctionRef sinker = BinaryenAddFunction(module, "return", i, localTypes, 1, body);

test/example/c-api-kitchen-sink.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,7 @@ int main() {
12801280
expressions[196] = BinaryenBinary(the_module, 62, expressions[195], expressions[194]);
12811281
{
12821282
BinaryenExpressionRef children[] = { 0 };
1283-
expressions[197] = BinaryenBlock(the_module, NULL, children, 0);
1283+
expressions[197] = BinaryenBlock(the_module, NULL, children, 0, 0);
12841284
}
12851285
expressions[198] = BinaryenIf(the_module, expressions[13], expressions[14], expressions[15]);
12861286
expressions[199] = BinaryenIf(the_module, expressions[16], expressions[17], expressions[0]);
@@ -1348,17 +1348,17 @@ int main() {
13481348
)
13491349
{
13501350
BinaryenExpressionRef children[] = { expressions[30], expressions[32], expressions[34], expressions[36], expressions[38], expressions[40], expressions[42], expressions[44], expressions[46], expressions[48], expressions[50], expressions[52], expressions[54], expressions[56], expressions[58], expressions[60], expressions[62], expressions[64], expressions[66], expressions[68], expressions[70], expressions[72], expressions[74], expressions[76], expressions[78], expressions[80], expressions[82], expressions[84], expressions[86], expressions[88], expressions[90], expressions[92], expressions[94], expressions[96], expressions[98], expressions[100], expressions[103], expressions[106], expressions[109], expressions[112], expressions[115], expressions[118], expressions[121], expressions[124], expressions[127], expressions[130], expressions[133], expressions[136], expressions[139], expressions[142], expressions[145], expressions[148], expressions[151], expressions[154], expressions[157], expressions[160], expressions[163], expressions[166], expressions[169], expressions[172], expressions[175], expressions[178], expressions[181], expressions[184], expressions[187], expressions[190], expressions[193], expressions[196], expressions[197], expressions[198], expressions[199], expressions[201], expressions[203], expressions[204], expressions[206], expressions[208], expressions[209], expressions[210], expressions[212], expressions[214], expressions[217], expressions[220], expressions[222], expressions[224], expressions[227], expressions[229], expressions[231], expressions[233], expressions[235], expressions[236], expressions[237], expressions[238], expressions[240], expressions[241], expressions[242] };
1351-
expressions[243] = BinaryenBlock(the_module, "the-value", children, 95);
1351+
expressions[243] = BinaryenBlock(the_module, "the-value", children, 95, 0);
13521352
}
13531353
expressions[244] = BinaryenDrop(the_module, expressions[243]);
13541354
{
13551355
BinaryenExpressionRef children[] = { expressions[244] };
1356-
expressions[245] = BinaryenBlock(the_module, "the-nothing", children, 1);
1356+
expressions[245] = BinaryenBlock(the_module, "the-nothing", children, 1, 0);
13571357
}
13581358
expressions[246] = BinaryenConst(the_module, BinaryenLiteralInt32(42));
13591359
{
13601360
BinaryenExpressionRef children[] = { expressions[245], expressions[246] };
1361-
expressions[247] = BinaryenBlock(the_module, "the-body", children, 2);
1361+
expressions[247] = BinaryenBlock(the_module, "the-body", children, 2, 0);
13621362
}
13631363
{
13641364
BinaryenType varTypes[] = { 1 };
@@ -2380,7 +2380,7 @@ int main() {
23802380
expressions[139] = BinaryenReturn(the_module, expressions[138]);
23812381
{
23822382
BinaryenExpressionRef children[] = { expressions[137], expressions[139] };
2383-
expressions[140] = BinaryenBlock(the_module, "the-list", children, 2);
2383+
expressions[140] = BinaryenBlock(the_module, "the-list", children, 2, 0);
23842384
}
23852385
relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[140]);
23862386
expressions[141] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module);

test/example/c-api-relooper-unreachable-if.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int main() {
2525
expressions[4] = BinaryenReturn(the_module, expressions[0]);
2626
{
2727
BinaryenExpressionRef children[] = { expressions[3], expressions[4] };
28-
expressions[5] = BinaryenBlock(the_module, "bb0", children, 2);
28+
expressions[5] = BinaryenBlock(the_module, "bb0", children, 2, 0);
2929
}
3030
relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[5]);
3131
{
@@ -50,7 +50,7 @@ int main() {
5050
expressions[13] = BinaryenReturn(the_module, expressions[0]);
5151
{
5252
BinaryenExpressionRef children[] = { expressions[12], expressions[13] };
53-
expressions[14] = BinaryenBlock(the_module, "bb0", children, 2);
53+
expressions[14] = BinaryenBlock(the_module, "bb0", children, 2, 0);
5454
}
5555
relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[14]);
5656
expressions[15] = BinaryenConst(the_module, BinaryenLiteralInt32(0));
@@ -67,12 +67,12 @@ int main() {
6767
the_relooper = RelooperCreate();
6868
{
6969
BinaryenExpressionRef children[] = { 0 };
70-
expressions[19] = BinaryenBlock(the_module, "bb0", children, 0);
70+
expressions[19] = BinaryenBlock(the_module, "bb0", children, 0, 0);
7171
}
7272
relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[19]);
7373
{
7474
BinaryenExpressionRef children[] = { 0 };
75-
expressions[20] = BinaryenBlock(the_module, "bb1", children, 0);
75+
expressions[20] = BinaryenBlock(the_module, "bb1", children, 0, 0);
7676
}
7777
relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[20]);
7878
RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[0]);
@@ -99,7 +99,7 @@ int main() {
9999
expressions[28] = BinaryenReturn(the_module, expressions[0]);
100100
{
101101
BinaryenExpressionRef children[] = { expressions[27], expressions[28] };
102-
expressions[29] = BinaryenBlock(the_module, "bb0", children, 2);
102+
expressions[29] = BinaryenBlock(the_module, "bb0", children, 2, 0);
103103
}
104104
relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[29]);
105105
expressions[30] = BinaryenConst(the_module, BinaryenLiteralInt32(0));
@@ -120,7 +120,7 @@ int main() {
120120
expressions[37] = BinaryenReturn(the_module, expressions[0]);
121121
{
122122
BinaryenExpressionRef children[] = { expressions[36], expressions[37] };
123-
expressions[38] = BinaryenBlock(the_module, "bb0", children, 2);
123+
expressions[38] = BinaryenBlock(the_module, "bb0", children, 2, 0);
124124
}
125125
relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[38]);
126126
expressions[39] = BinaryenConst(the_module, BinaryenLiteralInt32(0));
@@ -151,7 +151,7 @@ int main() {
151151
}
152152
{
153153
BinaryenExpressionRef children[] = { expressions[44], expressions[46], expressions[48] };
154-
expressions[49] = BinaryenBlock(the_module, "bb0", children, 3);
154+
expressions[49] = BinaryenBlock(the_module, "bb0", children, 3, 0);
155155
}
156156
relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[49]);
157157
expressions[50] = BinaryenGetLocal(the_module, 3, 1);
@@ -160,7 +160,7 @@ int main() {
160160
expressions[53] = BinaryenReturn(the_module, expressions[0]);
161161
{
162162
BinaryenExpressionRef children[] = { expressions[52], expressions[53] };
163-
expressions[54] = BinaryenBlock(the_module, "bb1", children, 2);
163+
expressions[54] = BinaryenBlock(the_module, "bb1", children, 2, 0);
164164
}
165165
relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[54]);
166166
RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[0]);
@@ -207,7 +207,7 @@ int main() {
207207
expressions[83] = BinaryenStore(the_module, 4, 4, 0, expressions[81], expressions[74], 1);
208208
{
209209
BinaryenExpressionRef children[] = { expressions[60], expressions[62], expressions[68], expressions[80], expressions[82], expressions[83] };
210-
expressions[84] = BinaryenBlock(the_module, "bb0", children, 6);
210+
expressions[84] = BinaryenBlock(the_module, "bb0", children, 6, 0);
211211
}
212212
relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[84]);
213213
expressions[85] = BinaryenGetLocal(the_module, 3, 1);
@@ -224,7 +224,7 @@ int main() {
224224
expressions[96] = BinaryenReturn(the_module, expressions[95]);
225225
{
226226
BinaryenExpressionRef children[] = { expressions[87], expressions[89], expressions[91], expressions[94], expressions[96] };
227-
expressions[97] = BinaryenBlock(the_module, "bb1", children, 5);
227+
expressions[97] = BinaryenBlock(the_module, "bb1", children, 5, 0);
228228
}
229229
relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[97]);
230230
expressions[98] = BinaryenGetLocal(the_module, 3, 1);
@@ -258,7 +258,7 @@ int main() {
258258
expressions[108] = BinaryenSetLocal(the_module, 4, expressions[107]);
259259
{
260260
BinaryenExpressionRef children[] = { expressions[106], expressions[108] };
261-
expressions[109] = BinaryenBlock(the_module, "bb0", children, 2);
261+
expressions[109] = BinaryenBlock(the_module, "bb0", children, 2, 0);
262262
}
263263
relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[109]);
264264
expressions[110] = BinaryenGetLocal(the_module, 4, 1);
@@ -284,7 +284,7 @@ int main() {
284284
expressions[130] = BinaryenStore(the_module, 4, 4, 0, expressions[128], expressions[121], 1);
285285
{
286286
BinaryenExpressionRef children[] = { expressions[115], expressions[127], expressions[129], expressions[130] };
287-
expressions[131] = BinaryenBlock(the_module, "bb1", children, 4);
287+
expressions[131] = BinaryenBlock(the_module, "bb1", children, 4, 0);
288288
}
289289
relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[131]);
290290
expressions[132] = BinaryenGetLocal(the_module, 5, 1);
@@ -299,7 +299,7 @@ int main() {
299299
}
300300
{
301301
BinaryenExpressionRef children[] = { expressions[134], expressions[136], expressions[138] };
302-
expressions[139] = BinaryenBlock(the_module, "bb2", children, 3);
302+
expressions[139] = BinaryenBlock(the_module, "bb2", children, 3, 0);
303303
}
304304
relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[139]);
305305
expressions[140] = BinaryenGetLocal(the_module, 3, 1);
@@ -313,7 +313,7 @@ int main() {
313313
expressions[148] = BinaryenReturn(the_module, expressions[147]);
314314
{
315315
BinaryenExpressionRef children[] = { expressions[141], expressions[143], expressions[146], expressions[148] };
316-
expressions[149] = BinaryenBlock(the_module, "bb3", children, 4);
316+
expressions[149] = BinaryenBlock(the_module, "bb3", children, 4, 0);
317317
}
318318
relooperBlocks[3] = RelooperAddBlock(the_relooper, expressions[149]);
319319
RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[0]);
@@ -361,7 +361,7 @@ int main() {
361361
expressions[163] = BinaryenDrop(the_module, expressions[162]);
362362
{
363363
BinaryenExpressionRef children[] = { expressions[159], expressions[163] };
364-
expressions[164] = BinaryenBlock(the_module, NULL, children, 2);
364+
expressions[164] = BinaryenBlock(the_module, NULL, children, 2, 0);
365365
}
366366
BinaryenAddExport(the_module, "__wasm_start", "rust_entry");
367367
{
@@ -401,7 +401,7 @@ int main() {
401401
expressions[193] = BinaryenStore(the_module, 4, 4, 0, expressions[191], expressions[184], 1);
402402
{
403403
BinaryenExpressionRef children[] = { expressions[166], expressions[168], expressions[170], expressions[172], expressions[178], expressions[190], expressions[192], expressions[193] };
404-
expressions[194] = BinaryenBlock(the_module, "bb0", children, 8);
404+
expressions[194] = BinaryenBlock(the_module, "bb0", children, 8, 0);
405405
}
406406
relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[194]);
407407
expressions[195] = BinaryenGetLocal(the_module, 6, 1);
@@ -414,7 +414,7 @@ int main() {
414414
expressions[202] = BinaryenReturn(the_module, expressions[201]);
415415
{
416416
BinaryenExpressionRef children[] = { expressions[197], expressions[200], expressions[202] };
417-
expressions[203] = BinaryenBlock(the_module, "bb1", children, 3);
417+
expressions[203] = BinaryenBlock(the_module, "bb1", children, 3, 0);
418418
}
419419
relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[203]);
420420
expressions[204] = BinaryenGetLocal(the_module, 6, 1);
@@ -453,7 +453,7 @@ int main() {
453453
expressions[222] = BinaryenReturn(the_module, expressions[221]);
454454
{
455455
BinaryenExpressionRef children[] = { expressions[212], expressions[214], expressions[217], expressions[220], expressions[222] };
456-
expressions[223] = BinaryenBlock(the_module, "bb0", children, 5);
456+
expressions[223] = BinaryenBlock(the_module, "bb0", children, 5, 0);
457457
}
458458
relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[223]);
459459
{
@@ -491,7 +491,7 @@ int main() {
491491
expressions[244] = BinaryenReturn(the_module, expressions[243]);
492492
{
493493
BinaryenExpressionRef children[] = { expressions[229], expressions[231], expressions[233], expressions[235], expressions[239], expressions[242], expressions[244] };
494-
expressions[245] = BinaryenBlock(the_module, "bb0", children, 7);
494+
expressions[245] = BinaryenBlock(the_module, "bb0", children, 7, 0);
495495
}
496496
relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[245]);
497497
{
@@ -529,7 +529,7 @@ int main() {
529529
expressions[266] = BinaryenReturn(the_module, expressions[265]);
530530
{
531531
BinaryenExpressionRef children[] = { expressions[251], expressions[253], expressions[255], expressions[257], expressions[261], expressions[264], expressions[266] };
532-
expressions[267] = BinaryenBlock(the_module, "bb0", children, 7);
532+
expressions[267] = BinaryenBlock(the_module, "bb0", children, 7, 0);
533533
}
534534
relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[267]);
535535
{

test/example/c-api-unused-mem.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ int main() {
2222
the_relooper = RelooperCreate();
2323
{
2424
BinaryenExpressionRef children[] = { 0 };
25-
expressions[1] = BinaryenBlock(the_module, "bb0", children, 0);
25+
expressions[1] = BinaryenBlock(the_module, "bb0", children, 0, 0);
2626
}
2727
relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[1]);
2828
expressions[2] = BinaryenGetLocal(the_module, 0, 1);
@@ -31,7 +31,7 @@ int main() {
3131
expressions[5] = BinaryenReturn(the_module, expressions[0]);
3232
{
3333
BinaryenExpressionRef children[] = { expressions[4], expressions[5] };
34-
expressions[6] = BinaryenBlock(the_module, "bb1", children, 2);
34+
expressions[6] = BinaryenBlock(the_module, "bb1", children, 2, 0);
3535
}
3636
relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[6]);
3737
RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[0]);
@@ -69,7 +69,7 @@ int main() {
6969
}
7070
{
7171
BinaryenExpressionRef children[] = { expressions[13], expressions[14] };
72-
expressions[15] = BinaryenBlock(the_module, NULL, children, 2);
72+
expressions[15] = BinaryenBlock(the_module, NULL, children, 2, 0);
7373
}
7474
BinaryenAddExport(the_module, "__wasm_start", "rust_entry");
7575
{

0 commit comments

Comments
 (0)