summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-binary.cpp
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2021-03-24 21:01:55 -0700
committerGitHub <noreply@github.com>2021-03-24 21:01:55 -0700
commit4506ffba7da377044e5a4a6d9385591ff730221c (patch)
tree66da23d3c146688e07214e3fb45161e33bcb448d /src/wasm/wasm-binary.cpp
parent78de694ceb1b642076050d75c26ce4c1bf996b31 (diff)
downloadbinaryen-4506ffba7da377044e5a4a6d9385591ff730221c.tar.gz
binaryen-4506ffba7da377044e5a4a6d9385591ff730221c.tar.bz2
binaryen-4506ffba7da377044e5a4a6d9385591ff730221c.zip
Refactor TypeBuilder (#3728)
Makes TypeBuilders growable, adds a `getTempHeapType` method, allows the `getTemp*Type` methods to take arbitrary temporary or canonical HeapTypes rather than just an index, and allows BasicHeapTypes to be assigned to TypeBuilder slots. All of these changes are necessary for the upcoming re-implementation of equirecursive LUB calculation. Also adds a new utility to TypeBuilder for using `operator[]` as an intuitive and readable wrapper around the `getTempHeapType` and `setHeapType` methods.
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r--src/wasm/wasm-binary.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 5fff58045..5bd368e17 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -1816,7 +1816,7 @@ void WasmBinaryBuilder::readTypes() {
if (size_t(htCode) >= numTypes) {
throwError("invalid type index: " + std::to_string(htCode));
}
- return builder.getTempRefType(size_t(htCode), nullability);
+ return builder.getTempRefType(builder[size_t(htCode)], nullability);
}
case BinaryConsts::EncodedType::rtt_n:
case BinaryConsts::EncodedType::rtt: {
@@ -1826,7 +1826,7 @@ void WasmBinaryBuilder::readTypes() {
if (size_t(htCode) >= numTypes) {
throwError("invalid type index: " + std::to_string(htCode));
}
- return builder.getTempRttType(htCode, depth);
+ return builder.getTempRttType(Rtt(depth, builder[htCode]));
}
default:
throwError("unexpected type index: " + std::to_string(typeCode));
@@ -1896,11 +1896,11 @@ void WasmBinaryBuilder::readTypes() {
BYN_TRACE("read one\n");
auto form = getS32LEB();
if (form == BinaryConsts::EncodedType::Func) {
- builder.setHeapType(i, readSignatureDef());
+ builder[i] = readSignatureDef();
} else if (form == BinaryConsts::EncodedType::Struct) {
- builder.setHeapType(i, readStructDef());
+ builder[i] = readStructDef();
} else if (form == BinaryConsts::EncodedType::Array) {
- builder.setHeapType(i, Array(readFieldDef()));
+ builder[i] = Array(readFieldDef());
} else {
throwError("bad type form " + std::to_string(form));
}