summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm-validator.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/wasm-validator.h b/src/wasm-validator.h
index 39eaca572..5e7b60498 100644
--- a/src/wasm-validator.h
+++ b/src/wasm-validator.h
@@ -93,23 +93,26 @@ public:
shouldBeTrue(curr->condition->type == unreachable || curr->condition->type == i32, curr, "br_table condition must be i32");
}
void visitCall(Call *curr) {
- auto* target = getModule()->getFunction(curr->target);
- shouldBeTrue(curr->operands.size() == target->params.size(), curr, "call param number must match");
+ auto* target = getModule()->checkFunction(curr->target);
+ if (!shouldBeTrue(!!target, curr, "call target must exist")) return;
+ if (!shouldBeTrue(curr->operands.size() == target->params.size(), curr, "call param number must match")) return;
for (size_t i = 0; i < curr->operands.size(); i++) {
shouldBeEqualOrFirstIsUnreachable(curr->operands[i]->type, target->params[i], curr, "call param types must match");
}
}
void visitCallImport(CallImport *curr) {
- auto* target = getModule()->getImport(curr->target)->type;
- shouldBeTrue(curr->operands.size() == target->params.size(), curr, "call param number must match");
+ auto* import = getModule()->checkImport(curr->target);
+ if (!shouldBeTrue(!!import, curr, "call_import target must exist")) return;
+ auto* type = import->type;
+ if (!shouldBeTrue(curr->operands.size() == type->params.size(), curr, "call param number must match")) return;
for (size_t i = 0; i < curr->operands.size(); i++) {
- shouldBeEqualOrFirstIsUnreachable(curr->operands[i]->type, target->params[i], curr, "call param types must match");
+ shouldBeEqualOrFirstIsUnreachable(curr->operands[i]->type, type->params[i], curr, "call param types must match");
}
}
void visitCallIndirect(CallIndirect *curr) {
auto* type = curr->fullType;
shouldBeEqualOrFirstIsUnreachable(curr->target->type, i32, curr, "indirect call target must be an i32");
- shouldBeTrue(curr->operands.size() == type->params.size(), curr, "call param number must match");
+ if (!shouldBeTrue(curr->operands.size() == type->params.size(), curr, "call param number must match")) return;
for (size_t i = 0; i < curr->operands.size(); i++) {
shouldBeEqualOrFirstIsUnreachable(curr->operands[i]->type, type->params[i], curr, "call param types must match");
}