#ifndef wasm_analysis_lattices_int_h
#define wasm_analysis_lattices_int_h
#include <cstdint>
#include <limits>
#include "../lattice.h"
namespace wasm::analysis {
#if __cplusplus >= 202002L
template<std::integral T>
#else
template<typename T>
#endif
struct Integer {
using Element = T;
Element getBottom() const noexcept { return std::numeric_limits<T>::min(); }
Element getTop() const noexcept { return std::numeric_limits<T>::max(); }
LatticeComparison compare(Element a, Element b) const noexcept {
return a > b ? GREATER : a == b ? EQUAL : LESS;
}
bool join(Element& joinee, Element joiner) const noexcept {
if (joinee < joiner) {
joinee = joiner;
return true;
}
return false;
}
bool meet(Element& meetee, Element meeter) const noexcept {
if (meetee > meeter) {
meetee = meeter;
return true;
}
return false;
}
};
using Int32 = Integer<int32_t>;
using UInt32 = Integer<uint32_t>;
using Int64 = Integer<int64_t>;
using UInt64 = Integer<uint64_t>;
#if __cplusplus >= 202002L
static_assert(FullLattice<Int32>);
static_assert(FullLattice<Int64>);
static_assert(FullLattice<UInt32>);
static_assert(FullLattice<UInt64>);
#endif
}
#endif