From 6ba0f3d282714fa60be2634fbdf48a8ab5a3997d Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Wed, 25 Oct 2023 21:30:31 +0200 Subject: [analysis] Add a FullLattice concept and Inverted lattice (#6038) The FullLattice concept extends the base Lattice with `getTop` and `meet` operations. The `Inverted` lattice uses these operations to reverse the order of an arbitrary full lattice, for example to create a lattice of integers ordered by `>` rather than by `<`. --- src/analysis/lattices/bool.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/analysis/lattices/bool.h') diff --git a/src/analysis/lattices/bool.h b/src/analysis/lattices/bool.h index 31094fb7d..c905d69f4 100644 --- a/src/analysis/lattices/bool.h +++ b/src/analysis/lattices/bool.h @@ -26,6 +26,7 @@ namespace wasm::analysis { struct Bool { using Element = bool; Element getBottom() const noexcept { return false; } + Element getTop() const noexcept { return true; } LatticeComparison compare(Element a, Element b) const noexcept { return a > b ? GREATER : a == b ? EQUAL : LESS; } @@ -36,6 +37,13 @@ struct Bool { } return false; } + bool meet(Element& self, Element other) const noexcept { + if (self && !other) { + self = other; + return true; + } + return false; + } }; #if __cplusplus >= 202002L -- cgit v1.2.3