diff options
author | Daniel Wirtz <dcode@dcode.io> | 2020-09-17 12:58:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-17 12:58:21 +0200 |
commit | 2841eddaabc7a5e24517e043a1aab8adc6d5c1e4 (patch) | |
tree | 17f8ed3d71237c4860fc07f7ba9bdc4d9691b76b /src/wasm/wasm-validator.cpp | |
parent | e1d74ef2acdd88f06b9e58f91f30bb56b9a26fe8 (diff) | |
download | binaryen-2841eddaabc7a5e24517e043a1aab8adc6d5c1e4.tar.gz binaryen-2841eddaabc7a5e24517e043a1aab8adc6d5c1e4.tar.bz2 binaryen-2841eddaabc7a5e24517e043a1aab8adc6d5c1e4.zip |
Refactor Host expression to MemorySize and MemoryGrow (#3137)
Aligns the internal representations of `memory.size` and `memory.grow` with other more recent memory instructions by removing the legacy `Host` expression class and adding separate expression classes for `MemorySize` and `MemoryGrow`. Simplifies related APIs, but is also a breaking API change.
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 15fb66926..c141fdd6f 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -326,7 +326,8 @@ public: void visitSelect(Select* curr); void visitDrop(Drop* curr); void visitReturn(Return* curr); - void visitHost(Host* curr); + void visitMemorySize(MemorySize* curr); + void visitMemoryGrow(MemoryGrow* curr); void visitRefIsNull(RefIsNull* curr); void visitRefFunc(RefFunc* curr); void visitTry(Try* curr); @@ -1897,24 +1898,18 @@ void FunctionValidator::visitReturn(Return* curr) { returnTypes.insert(curr->value ? curr->value->type : Type::none); } -void FunctionValidator::visitHost(Host* curr) { +void FunctionValidator::visitMemorySize(MemorySize* curr) { shouldBeTrue( getModule()->memory.exists, curr, "Memory operations require a memory"); - switch (curr->op) { - case MemoryGrow: { - shouldBeEqual(curr->operands.size(), - size_t(1), - curr, - "memory.grow must have 1 operand"); - shouldBeEqualOrFirstIsUnreachable(curr->operands[0]->type, - Type(Type::i32), - curr, - "memory.grow must have i32 operand"); - break; - } - case MemorySize: - break; - } +} + +void FunctionValidator::visitMemoryGrow(MemoryGrow* curr) { + shouldBeTrue( + getModule()->memory.exists, curr, "Memory operations require a memory"); + shouldBeEqualOrFirstIsUnreachable(curr->delta->type, + Type(Type::i32), + curr, + "memory.grow must have i32 operand"); } void FunctionValidator::visitRefIsNull(RefIsNull* curr) { |