diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-06-03 14:21:02 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-06-03 14:21:02 -0700 |
commit | b76818e23eab75876f1981800ef12d55ce2f579b (patch) | |
tree | d57a02368f8ee2cc4747f6805943623f290a3397 /src/wasm-validator.h | |
parent | 1826f4132d52a1c767f012fad5d1ab3e746e632b (diff) | |
parent | 74bc353d4fedd9fff308aecfae183b6b7525c7d3 (diff) | |
download | binaryen-b76818e23eab75876f1981800ef12d55ce2f579b.tar.gz binaryen-b76818e23eab75876f1981800ef12d55ce2f579b.tar.bz2 binaryen-b76818e23eab75876f1981800ef12d55ce2f579b.zip |
Merge pull request #567 from WebAssembly/spec-test-update
Misc fixes for new spec tests
Diffstat (limited to 'src/wasm-validator.h')
-rw-r--r-- | src/wasm-validator.h | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/wasm-validator.h b/src/wasm-validator.h index 39eaca572..2a11bf64f 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"); } @@ -245,7 +248,7 @@ public: } void visitMemory(Memory *curr) { shouldBeFalse(curr->initial > curr->max, "memory", "memory max >= initial"); - shouldBeTrue(curr->max <= Memory::kMaxSize, "memory", "total memory must be <= 4GB"); + shouldBeTrue(curr->max <= Memory::kMaxSize, "memory", "max memory must be <= 4GB"); size_t top = 0; for (auto& segment : curr->segments) { shouldBeFalse(segment.offset < top, "memory", "segment offset is small enough"); |