diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/fuzzing.h | 8 | ||||
-rw-r--r-- | src/wasm-builder.h | 15 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h index 714e2c84b..f13b99c3d 100644 --- a/src/tools/fuzzing.h +++ b/src/tools/fuzzing.h @@ -2120,13 +2120,7 @@ private: return builder.makeRefFunc(func->name, type); } if (type.isRtt()) { - Expression* ret = builder.makeRttCanon(type.getHeapType()); - if (type.getRtt().hasDepth()) { - for (Index i = 0; i < type.getRtt().depth; i++) { - ret = builder.makeRttSub(type.getHeapType(), ret); - } - } - return ret; + return builder.makeRtt(type); } if (type.isTuple()) { std::vector<Expression*> operands; diff --git a/src/wasm-builder.h b/src/wasm-builder.h index 6fc5c4dda..3a4ae97c1 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -838,6 +838,9 @@ public: if (type.isFunction()) { return makeRefFunc(value.getFunc(), type); } + if (type.isRtt()) { + return makeRtt(value.type); + } TODO_SINGLE_COMPOUND(type); switch (type.getBasic()) { case Type::externref: @@ -865,6 +868,18 @@ public: } } + // Given a type, creates an RTT expression of that type, using a combination + // of rtt.canon and rtt.subs. + Expression* makeRtt(Type type) { + Expression* ret = makeRttCanon(type.getHeapType()); + if (type.getRtt().hasDepth()) { + for (Index i = 0; i < type.getRtt().depth; i++) { + ret = makeRttSub(type.getHeapType(), ret); + } + } + return ret; + } + // Additional utility functions for building on top of nodes // Convenient to have these on Builder, as it has allocation built in |