40 static std::tuple<const Axiom*, u8, u8>
get(
const Def* def);
57 template<
class T>
struct Match {
69template<
class Id,
class D>
class Match {
70 static_assert(
Annex::Num<Id> != size_t(-1),
"invalid number of sub tags");
83 operator const D*()
const {
return def_; }
84 explicit operator bool() {
return axiom_ !=
nullptr; }
94 auto id()
const {
return Id(
axiom()->flags()); }
98 const Axiom* axiom_ =
nullptr;
99 const D* def_ =
nullptr;
105template<
class Id,
bool DynCast = true>
auto match(
Ref def) {
111 assert(cond &&
"assumed to be correct axiom");
115template<
class Id,
bool DynCast = true>
auto match(Id
id,
Ref def) {
118 bool cond = axiom && curry == 0 && axiom->flags() == (
flags_t)
id;
121 assert(cond &&
"assumed to be correct axiom");
126template<
class Id>
auto force(
Ref def) {
return match<Id, false>( def); }
127template<
class Id>
auto force(Id
id,
Ref def) {
return match<Id, false>(
id, def); }
NormalizeFn normalizer() const
static constexpr u8 Trip_End
static std::tuple< const Axiom *, u8, u8 > get(const Def *def)
Yields currying counter of def.
static std::pair< u8, u8 > infer_curry_and_trip(const Def *type)
const Def * type() const
Yields the raw type of this Def, i.e. maybe nullptr.
Match(const Axiom *axiom, const D *def)
const D * operator->() const
const Axiom * axiom() const
auto id() const
Axiom::flags cast to Id.
Helper class to retrieve Infer::arg if present.
#define THORIN_DEF_MIXIN(T)
Ref(*)(Ref, Ref, Ref) NormalizeFn
constexpr bool is_associative(Id id)
constexpr bool is_commutative(Id)
static tag_t flags2tag(flags_t f)
Yields the tag part of the name as integer.
static sub_t flags2sub(flags_t f)
Yields the sub part of the name as integer.
static plugin_t flags2plugin(flags_t f)
Yields the plugin part of the name as integer.
static flags_t flags2base(flags_t f)
Includes Axiom::plugin() and Axiom::tag() but not Axiom::sub.
static constexpr flags_t Base