summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
authorMax Graey <maxgraey@gmail.com>2021-10-09 05:26:08 +0300
committerGitHub <noreply@github.com>2021-10-08 19:26:08 -0700
commitef686a4d932b9b86edc34a3b9b15926f943f6f7b (patch)
tree38a89d5b555d4501b7d504a66c7aec409e45e9b1 /src/wasm/wasm-validator.cpp
parent53c5e3e62db25fe3522a1fa615a1f53c4cefdf06 (diff)
downloadbinaryen-ef686a4d932b9b86edc34a3b9b15926f943f6f7b.tar.gz
binaryen-ef686a4d932b9b86edc34a3b9b15926f943f6f7b.tar.bz2
binaryen-ef686a4d932b9b86edc34a3b9b15926f943f6f7b.zip
Add table.size operation (#4224)
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index 0e362df9c..0271884a4 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -366,6 +366,7 @@ public:
void visitRefEq(RefEq* curr);
void visitTableGet(TableGet* curr);
void visitTableSet(TableSet* curr);
+ void visitTableSize(TableSize* curr);
void noteDelegate(Name name, Expression* curr);
void noteRethrow(Name name, Expression* curr);
void visitTry(Try* curr);
@@ -2063,6 +2064,14 @@ void FunctionValidator::visitTableSet(TableSet* curr) {
}
}
+void FunctionValidator::visitTableSize(TableSize* curr) {
+ shouldBeTrue(getModule()->features.hasReferenceTypes(),
+ curr,
+ "table.size requires reference types to be enabled");
+ auto* table = getModule()->getTableOrNull(curr->table);
+ shouldBeTrue(!!table, curr, "table.size table must exist");
+}
+
void FunctionValidator::noteDelegate(Name name, Expression* curr) {
if (name != DELEGATE_CALLER_TARGET) {
shouldBeTrue(delegateTargetNames.count(name) != 0,