diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2021-04-29 16:04:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-29 16:04:30 -0700 |
commit | ea8ebefa551b8e6e2d4baa759df8c531cfd842d8 (patch) | |
tree | b066fd47d887a77beea872b9840827d7c3ba4abe /src/wasm-type.h | |
parent | b9c7497d1caae695ac5582590d73ad61abd7850f (diff) | |
download | binaryen-ea8ebefa551b8e6e2d4baa759df8c531cfd842d8.tar.gz binaryen-ea8ebefa551b8e6e2d4baa759df8c531cfd842d8.tar.bz2 binaryen-ea8ebefa551b8e6e2d4baa759df8c531cfd842d8.zip |
Use standard type traversal in module-utils.h (#3851)
Add new public `getHeapTypeChildren` methods to Type and HeapType, implemented
in using the standard machinery from #3844, and use them to simplify
`ModuleUtils::collectHeapTypes`.
Now that the type traversal code in wasm-type.cpp is not just used in
canonicalization, move it to a more appropriate place in the file. Also, since
the only users of `HeapTypePathWalker` were using it to visit top-level children
only, replace that with a more specialized `HeapTypeChildWalker` to reduce code
duplication.
Diffstat (limited to 'src/wasm-type.h')
-rw-r--r-- | src/wasm-type.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/wasm-type.h b/src/wasm-type.h index 1b7d389ca..41a89d4fe 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -204,6 +204,9 @@ public: // Returns true if left is a subtype of right. Subtype includes itself. static bool isSubType(Type left, Type right); + // Return the ordered HeapType children, looking through child Types. + std::vector<HeapType> getHeapTypeChildren(); + // Computes the least upper bound from the type lattice. // If one of the type is unreachable, the other type becomes the result. If // the common supertype does not exist, returns none, a poison value. @@ -361,10 +364,14 @@ public: // Order heap types by some notion of simplicity. bool operator<(const HeapType& other) const; - std::string toString() const; // Returns true if left is a subtype of right. Subtype includes itself. static bool isSubType(HeapType left, HeapType right); + + // Return the ordered HeapType children, looking through child Types. + std::vector<HeapType> getHeapTypeChildren(); + + std::string toString() const; }; typedef std::vector<Type> TypeList; |