summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
authorMax Graey <maxgraey@gmail.com>2021-10-07 22:43:30 +0300
committerGitHub <noreply@github.com>2021-10-07 12:43:30 -0700
commit2dff27c086e8f2a9913096ebf3dc93e97051d85a (patch)
tree3d689a659ad2339639fc4b2e73753b51e6d9295c /src/wasm/wasm-validator.cpp
parentff68bca64cd669aff59c7e1cc0a6677d267a410f (diff)
downloadbinaryen-2dff27c086e8f2a9913096ebf3dc93e97051d85a.tar.gz
binaryen-2dff27c086e8f2a9913096ebf3dc93e97051d85a.tar.bz2
binaryen-2dff27c086e8f2a9913096ebf3dc93e97051d85a.zip
Add table.set operation (#4215)
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index fae95980f..0e362df9c 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -365,6 +365,7 @@ public:
void visitRefFunc(RefFunc* curr);
void visitRefEq(RefEq* curr);
void visitTableGet(TableGet* curr);
+ void visitTableSet(TableSet* curr);
void noteDelegate(Name name, Expression* curr);
void noteRethrow(Name name, Expression* curr);
void visitTry(Try* curr);
@@ -2046,6 +2047,22 @@ void FunctionValidator::visitTableGet(TableGet* curr) {
}
}
+void FunctionValidator::visitTableSet(TableSet* curr) {
+ shouldBeTrue(getModule()->features.hasReferenceTypes(),
+ curr,
+ "table.set requires reference types to be enabled");
+ shouldBeEqualOrFirstIsUnreachable(
+ curr->index->type, Type(Type::i32), curr, "table.set index must be an i32");
+ auto* table = getModule()->getTableOrNull(curr->table);
+ if (shouldBeTrue(!!table, curr, "table.set table must exist") &&
+ curr->type != Type::unreachable) {
+ shouldBeSubType(curr->value->type,
+ table->type,
+ curr,
+ "table.set value must have right type");
+ }
+}
+
void FunctionValidator::noteDelegate(Name name, Expression* curr) {
if (name != DELEGATE_CALLER_TARGET) {
shouldBeTrue(delegateTargetNames.count(name) != 0,