diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2021-07-27 12:22:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-27 19:22:40 +0000 |
commit | b99bf3a230d9e4333cb1fdf5e4b760f549f04057 (patch) | |
tree | 8c97325c5491cf37aaeb6e6706d77a9445fd7330 | |
parent | b3375bc19f67838d80eaa9af011952bfdaae243f (diff) | |
download | binaryen-b99bf3a230d9e4333cb1fdf5e4b760f549f04057.tar.gz binaryen-b99bf3a230d9e4333cb1fdf5e4b760f549f04057.tar.bz2 binaryen-b99bf3a230d9e4333cb1fdf5e4b760f549f04057.zip |
Parse and print pops of compound types (#4030)
This is necessary when using GC and EH together, for instance.
-rw-r--r-- | src/passes/Print.cpp | 4 | ||||
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 2 | ||||
-rw-r--r-- | test/lit/gc-eh.wast | 42 |
3 files changed, 45 insertions, 3 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 491e44ca2..8c7b221fd 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -1860,8 +1860,8 @@ struct PrintExpressionContents void visitPop(Pop* curr) { prepareColor(o) << "pop"; for (auto type : curr->type) { - assert(type.isBasic() && "TODO: print and parse compound types"); - o << " " << type; + o << ' '; + printType(o, type, wasm); } restoreNormalColor(o); } diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 019049cb1..c9c8235e2 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -2159,7 +2159,7 @@ Expression* SExpressionWasmBuilder::makePop(Element& s) { auto ret = allocator.alloc<Pop>(); std::vector<Type> types; for (size_t i = 1; i < s.size(); ++i) { - types.push_back(stringToType(s[i]->str())); + types.push_back(elementToType(*s[i])); } ret->type = Type(types); ret->finalize(); diff --git a/test/lit/gc-eh.wast b/test/lit/gc-eh.wast new file mode 100644 index 000000000..808060df1 --- /dev/null +++ b/test/lit/gc-eh.wast @@ -0,0 +1,42 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. + +;; Check that pops of GC types work correctly. + +;; RUN: wasm-opt -all %s -S -o - | filecheck %s + +(module + ;; CHECK: (type $A (struct (field (mut i32)))) + (type $A (struct + (field (mut i32)) + )) + + ;; CHECK: (tag $tagA (param (ref $A))) + (tag $tagA (param (ref $A))) + + ;; CHECK: (func $foo (result (ref null $A)) + ;; CHECK-NEXT: (try $try + ;; CHECK-NEXT: (do + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (catch $tagA + ;; CHECK-NEXT: (return + ;; CHECK-NEXT: (pop (ref $A)) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (ref.null $A) + ;; CHECK-NEXT: ) + (func $foo (result (ref null $A)) + (try + (do + (nop) + ) + (catch $tagA + (return + (pop (ref $A)) + ) + ) + ) + (ref.null $A) + ) +) |