diff options
author | Abbas Mashayekh <martianboy2005@gmail.com> | 2021-03-24 21:43:45 +0430 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-24 10:13:45 -0700 |
commit | ffac06650507ac413d60d72aadc1e33fb1f91ccf (patch) | |
tree | f581d02da66df8db2a775fc731d39baf15d96c82 /src/ir/module-utils.h | |
parent | 683c31381f5798016f683a6b42e2a8fad0f871cb (diff) | |
download | binaryen-ffac06650507ac413d60d72aadc1e33fb1f91ccf.tar.gz binaryen-ffac06650507ac413d60d72aadc1e33fb1f91ccf.tar.bz2 binaryen-ffac06650507ac413d60d72aadc1e33fb1f91ccf.zip |
[RT] Support expressions in element segments (#3666)
This PR adds support for `ref.null t` as a valid element segment
item. The abbreviated format of `(elem ... func $f $g...)` is kept in
both printing and binary emitting if all items are `ref.func`s. Public
APIs aren't updated in this PR.
Diffstat (limited to 'src/ir/module-utils.h')
-rw-r--r-- | src/ir/module-utils.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h index 9b1682b91..a87daee9e 100644 --- a/src/ir/module-utils.h +++ b/src/ir/module-utils.h @@ -17,6 +17,7 @@ #ifndef wasm_ir_module_h #define wasm_ir_module_h +#include "ir/element-utils.h" #include "ir/find_all.h" #include "ir/manipulation.h" #include "ir/properties.h" @@ -75,7 +76,10 @@ inline ElementSegment* copyElementSegment(const ElementSegment* segment, auto copy = [&](std::unique_ptr<ElementSegment>&& ret) { ret->name = segment->name; ret->hasExplicitName = segment->hasExplicitName; - ret->data = segment->data; + ret->data.reserve(segment->data.size()); + for (auto* item : segment->data) { + ret->data.push_back(ExpressionManipulator::copy(item, out)); + } return out.addElementSegment(std::move(ret)); }; @@ -161,11 +165,7 @@ template<typename T> inline void renameFunctions(Module& wasm, T& map) { } }; maybeUpdate(wasm.start); - for (auto& segment : wasm.elementSegments) { - for (auto& name : segment->data) { - maybeUpdate(name); - } - } + ElementUtils::iterAllElementFunctionNames(&wasm, maybeUpdate); for (auto& exp : wasm.exports) { if (exp->kind == ExternalKind::Function) { maybeUpdate(exp->value); |