@@ -729,14 +729,17 @@ void BinaryenSetFunctionTable(BinaryenModuleRef module, BinaryenFunctionRef* fun
729
729
}
730
730
731
731
auto * wasm = (Module*)module ;
732
+ Table::Segment segment (wasm->allocator .alloc <Const>()->set (Literal (int32_t (0 ))));
732
733
for (BinaryenIndex i = 0 ; i < numFuncs; i++) {
733
- wasm-> table . names .push_back (((Function*)funcs[i])->name );
734
+ segment. data .push_back (((Function*)funcs[i])->name );
734
735
}
736
+ wasm->table .segments .push_back (segment);
737
+ wasm->table .initial = wasm->table .max = numFuncs;
735
738
}
736
739
737
740
// Memory. One per module
738
741
739
- void BinaryenSetMemory (BinaryenModuleRef module , BinaryenIndex initial, BinaryenIndex maximum, const char * exportName, const char **segments, BinaryenIndex * segmentOffsets, BinaryenIndex* segmentSizes, BinaryenIndex numSegments) {
742
+ void BinaryenSetMemory (BinaryenModuleRef module , BinaryenIndex initial, BinaryenIndex maximum, const char * exportName, const char **segments, BinaryenExpressionRef * segmentOffsets, BinaryenIndex* segmentSizes, BinaryenIndex numSegments) {
740
743
if (tracing) {
741
744
std::cout << " {\n " ;
742
745
for (BinaryenIndex i = 0 ; i < numSegments; i++) {
@@ -754,10 +757,10 @@ void BinaryenSetMemory(BinaryenModuleRef module, BinaryenIndex initial, Binaryen
754
757
}
755
758
if (numSegments == 0 ) std::cout << " 0" ; // ensure the array is not empty, otherwise a compiler error on VS
756
759
std::cout << " };\n " ;
757
- std::cout << " BinaryenIndex segmentOffsets[] = { " ;
760
+ std::cout << " BinaryenExpressionRef segmentOffsets[] = { " ;
758
761
for (BinaryenIndex i = 0 ; i < numSegments; i++) {
759
762
if (i > 0 ) std::cout << " , " ;
760
- std::cout << segmentOffsets[i];
763
+ std::cout << " expressions[ " << expressions[ segmentOffsets[i]] << " ] " ;
761
764
}
762
765
if (numSegments == 0 ) std::cout << " 0" ; // ensure the array is not empty, otherwise a compiler error on VS
763
766
std::cout << " };\n " ;
@@ -779,7 +782,7 @@ void BinaryenSetMemory(BinaryenModuleRef module, BinaryenIndex initial, Binaryen
779
782
wasm->memory .max = maximum;
780
783
if (exportName) wasm->memory .exportName = exportName;
781
784
for (BinaryenIndex i = 0 ; i < numSegments; i++) {
782
- wasm->memory .segments .emplace_back (segmentOffsets[i], segments[i], segmentSizes[i]);
785
+ wasm->memory .segments .emplace_back ((Expression*) segmentOffsets[i], segments[i], segmentSizes[i]);
783
786
}
784
787
}
785
788
0 commit comments