summaryrefslogtreecommitdiff
path: root/src/wasm/wasm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm.cpp')
-rw-r--r--src/wasm/wasm.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index 8ff2dc978..6589ca069 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -900,6 +900,47 @@ void Throw::finalize() { type = Type::unreachable; }
void Rethrow::finalize() { type = Type::unreachable; }
+void ThrowRef::finalize() { type = Type::unreachable; }
+
+bool TryTable::hasCatchAll() const {
+ return std::any_of(
+ catchTags.begin(), catchTags.end(), [](Name t) { return !t; });
+}
+
+static void populateTryTableSentTypes(TryTable* curr, Module* wasm) {
+ if (!wasm) {
+ return;
+ }
+ curr->sentTypes.clear();
+ Type exnref = Type(HeapType::exn, Nullable);
+ for (Index i = 0; i < curr->catchTags.size(); i++) {
+ auto tagName = curr->catchTags[i];
+ std::vector<Type> sentType;
+ if (tagName) {
+ for (auto t : wasm->getTag(tagName)->sig.params) {
+ sentType.push_back(t);
+ }
+ }
+ if (curr->catchRefs[i]) {
+ sentType.push_back(exnref);
+ }
+ curr->sentTypes.push_back(sentType.empty() ? Type::none : Type(sentType));
+ }
+}
+
+void TryTable::finalize(Module* wasm) {
+ type = body->type;
+ populateTryTableSentTypes(this, wasm);
+}
+
+void TryTable::finalize(Type type_, Module* wasm) {
+ type = type_;
+ if (type == Type::none && body->type == Type::unreachable) {
+ type = Type::unreachable;
+ }
+ populateTryTableSentTypes(this, wasm);
+}
+
void TupleMake::finalize() {
std::vector<Type> types;
types.reserve(operands.size());