summaryrefslogtreecommitdiff
path: root/src/wasm-validator.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm-validator.h')
-rw-r--r--src/wasm-validator.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/wasm-validator.h b/src/wasm-validator.h
index 0c3acaf6d..ffdd2a2b7 100644
--- a/src/wasm-validator.h
+++ b/src/wasm-validator.h
@@ -347,10 +347,21 @@ public:
}
returnType = unreachable;
}
+
+ bool isConstant(Expression* curr) {
+ return curr->is<Const>();
+ }
+
void visitMemory(Memory *curr) {
shouldBeFalse(curr->initial > curr->max, "memory", "memory max >= initial");
shouldBeTrue(curr->max <= Memory::kMaxSize, "memory", "max memory must be <= 4GB");
}
+ void visitTable(Table* curr) {
+ for (auto& segment : curr->segments) {
+ shouldBeEqual(segment.offset->type, i32, segment.offset, "segment offset should be i32");
+ shouldBeTrue(isConstant(segment.offset), segment.offset, "segment offset should be constant");
+ }
+ }
void visitModule(Module *curr) {
// exports
std::set<Name> exportNames;