summaryrefslogtreecommitdiff
path: root/src/passes/Print.cpp
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2022-10-18 13:19:22 -0500
committerGitHub <noreply@github.com>2022-10-18 13:19:22 -0500
commit6bef18672fae68ee4976a7b26f277f6caa32734f (patch)
treee2198250c704715bbe968a0684c9dc79235fdffd /src/passes/Print.cpp
parent43c62ee5a1506535fcb67b84723264ac4cec008a (diff)
downloadbinaryen-6bef18672fae68ee4976a7b26f277f6caa32734f.tar.gz
binaryen-6bef18672fae68ee4976a7b26f277f6caa32734f.tar.bz2
binaryen-6bef18672fae68ee4976a7b26f277f6caa32734f.zip
Implement `array` basic heap type (#5148)
`array` is the supertype of all defined array types and for now is a subtype of `data`. (Once `data` becomes `struct` this will no longer be true.) Update the binary and text parsing of `array.len` to ignore the obsolete type annotation and update the binary emitting to emit a zero in place of the old type annotation and the text printing to print an arbitrary heap type for the annotation. A follow-on PR will add support for the newer unannotated version of `array.len`.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r--src/passes/Print.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index ddd8f9cc1..0f4a314ae 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -108,6 +108,9 @@ bool maybePrintRefShorthand(std::ostream& o, Type type) {
case HeapType::data:
o << "dataref";
return true;
+ case HeapType::array:
+ o << "arrayref";
+ return true;
case HeapType::string:
o << "stringref";
return true;
@@ -2234,11 +2237,12 @@ struct PrintExpressionContents
TypeNamePrinter(o, wasm).print(curr->ref->type.getHeapType());
}
void visitArrayLen(ArrayLen* curr) {
- if (printUnreachableOrNullReplacement(curr->ref)) {
- return;
- }
printMedium(o, "array.len ");
- TypeNamePrinter(o, wasm).print(curr->ref->type.getHeapType());
+ if (curr->ref->type == Type::unreachable) {
+ TypeNamePrinter(o, wasm).print(HeapType::array);
+ } else {
+ TypeNamePrinter(o, wasm).print(curr->ref->type.getHeapType());
+ }
}
void visitArrayCopy(ArrayCopy* curr) {
if (printUnreachableOrNullReplacement(curr->srcRef) ||
@@ -2801,9 +2805,6 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
void visitArrayGet(ArrayGet* curr) {
maybePrintUnreachableOrNullReplacement(curr, curr->ref->type);
}
- void visitArrayLen(ArrayLen* curr) {
- maybePrintUnreachableOrNullReplacement(curr, curr->ref->type);
- }
// Module-level visitors
void printSupertypeOr(HeapType curr, std::string noSuper) {
if (auto super = curr.getSuperType()) {