summaryrefslogtreecommitdiff
path: root/src/wasm2js.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-11-21 11:26:33 -0800
committerGitHub <noreply@github.com>2024-11-21 11:26:33 -0800
commit3342d56e4a13170c094a29138b32ff17cad4c01d (patch)
tree8a63abc6e8f0e9cdb01eef40ffbd9010bf009d8b /src/wasm2js.h
parentaf5f74aeb3c53081ffaedbde18a77bdede0a697e (diff)
downloadbinaryen-3342d56e4a13170c094a29138b32ff17cad4c01d.tar.gz
binaryen-3342d56e4a13170c094a29138b32ff17cad4c01d.tar.bz2
binaryen-3342d56e4a13170c094a29138b32ff17cad4c01d.zip
[wasm2js] Properly handle loops without labels (#7100)
When a loop has no name, the name does not matter, but we also cannot emit the same name for all such loops, as that is invalid JS. Just do not emit a while(){} at all in that case, as no continue can exist anyhow. Fixes #7099 Also fix two missing * in error reporting logic, that was printing pointers rather than the expression we wanted to print. I think we changed how iostream prints things years ago, and forgot to update these.
Diffstat (limited to 'src/wasm2js.h')
-rw-r--r--src/wasm2js.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/wasm2js.h b/src/wasm2js.h
index 15ae019ea..d965dcc0c 100644
--- a/src/wasm2js.h
+++ b/src/wasm2js.h
@@ -1181,6 +1181,11 @@ Ref Wasm2JSBuilder::processExpression(Expression* curr,
Ref visitLoop(Loop* curr) {
Name asmLabel = curr->name;
+ if (!asmLabel) {
+ // This loop has no label, so it cannot be continued to. We can just
+ // emit the body.
+ return visit(curr->body, result);
+ }
continueLabels.insert(asmLabel);
Ref body = visit(curr->body, result);
// if we can reach the end of the block, we must leave the while (1) loop
@@ -1779,7 +1784,7 @@ Ref Wasm2JSBuilder::processExpression(Expression* curr,
return ret;
}
default: {
- Fatal() << "Unhandled type in unary: " << curr;
+ Fatal() << "Unhandled type in unary: " << *curr;
}
}
}
@@ -1949,7 +1954,7 @@ Ref Wasm2JSBuilder::processExpression(Expression* curr,
}
return ret;
default:
- Fatal() << "Unhandled type in binary: " << curr;
+ Fatal() << "Unhandled type in binary: " << *curr;
}
return makeJsCoercion(ret, wasmToJsType(curr->type));
}