summaryrefslogtreecommitdiff
path: root/src/tools/wasm2c-wrapper.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-04-28 11:35:23 -0700
committerGitHub <noreply@github.com>2020-04-28 11:35:23 -0700
commit1cd20951895a8e54ab52bdbf011296c666b0630f (patch)
tree028e90b90f3e09a4452e41c87cabb94271ad7140 /src/tools/wasm2c-wrapper.h
parent1d54be44e4ea261a457ea56bc9c444161ff4d89b (diff)
downloadbinaryen-1cd20951895a8e54ab52bdbf011296c666b0630f.tar.gz
binaryen-1cd20951895a8e54ab52bdbf011296c666b0630f.tar.bz2
binaryen-1cd20951895a8e54ab52bdbf011296c666b0630f.zip
Fix wasm2c loop (#2816)
The refactoring of the loop in #2812 was wrong - we need to loop over all the exports and ignore the non-function ones. Rewrote it to stress that part.
Diffstat (limited to 'src/tools/wasm2c-wrapper.h')
-rw-r--r--src/tools/wasm2c-wrapper.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/tools/wasm2c-wrapper.h b/src/tools/wasm2c-wrapper.h
index 74ae21202..fb0658ef0 100644
--- a/src/tools/wasm2c-wrapper.h
+++ b/src/tools/wasm2c-wrapper.h
@@ -96,15 +96,16 @@ int main(int argc, char** argv) {
switch(curr) {
)";
- // For each export in the wasm, emit code to call it and log its result,
- // similar to the other wrappers.
- for (size_t i = 0; i < wasm.exports.size(); i++) {
- auto& exp = wasm.exports[i];
+ // For each function export in the wasm, emit code to call it and log its
+ // result, similar to the other wrappers.
+ size_t functionExportIndex = 0;
+
+ for (auto& exp : wasm.exports) {
if (exp->kind != ExternalKind::Function) {
continue;
}
- ret += " case " + std::to_string(i) + ":\n";
+ ret += " case " + std::to_string(functionExportIndex++) + ":\n";
auto* func = wasm.getFunction(exp->value);