20 if (
auto arr =
type()->isa<Arr>())
return arr->
arity();
42 if (
auto app = def->isa<
App>()) {
58 if (def ==
nullptr)
return {};
60 auto& w = def->
world();
61 auto res = std::string();
63 for (
size_t i = 0; i != *n; ++i) {
64 auto elem = def->
proj(*n, i);
65 if (elem->type() == w.type_i8()) {
83 res.reserve(a.size() + b.size());
84 res.insert(res.end(), a.begin(), a.end());
85 res.insert(res.end(), b.begin(), b.end());
92 for (
size_t i = 0, e = n; i != e; ++i)
93 defs.emplace_back(a->proj(e, i));
94 for (
size_t i = 0, e = m; i != e; ++i)
95 defs.emplace_back(b->
proj(e, i));
107 auto& world = t->world();
108 if (
auto sigma = t->isa<
Sigma>())
return world.tuple(sigma->ops());
109 if (
auto arr = t->isa<
Arr>())
return world.pack(arr->arity(), arr->body());
const Def * callee() const
A (possibly paramterized) Array.
const Def * callee() const
const Def * proj(nat_t a, nat_t i) const
Similar to World::extract while assuming an arity of a, but also works on Sigmas and Arrays.
World & world() const noexcept
T * isa_mut() const
If this is mutable, it will cast constness away and perform a dynamic_cast to T.
const Def * op(size_t i) const noexcept
const Def * type() const noexcept
Yields the "raw" type of this Def (maybe nullptr).
virtual const Def * arity() const
Number of elements available to Extract / Insert (may be dynamic).
constexpr size_t num_ops() const noexcept
const Def * callee() const
const Extract * extract() const
static std::optional< T > isa(const Def *def)
const Def * arity() const final
Number of elements available to Extract / Insert (may be dynamic).
Def(World *, Node, const Def *type, Defs ops, flags_t flags)
Constructor for an immutable Def.
const Extract * extract() const
Def(World *, Node, const Def *type, Defs ops, flags_t flags)
Constructor for an immutable Def.
const Def * arity() const final
Number of elements available to Extract / Insert (may be dynamic).
The World represents the whole program and manages creation of MimIR nodes (Defs).
const Def * sigma(Defs ops)
const Def * tuple(Defs ops)
const Lit * lit_nat(nat_t a)
Vector< const Def * > DefVec
const Def * cat_tuple(nat_t n, nat_t m, const Def *a, const Def *b)
bool is_unit(const Def *)
std::string tuple2str(const Def *)
const Def * cat_sigma(nat_t n, nat_t m, const Def *a, const Def *b)
const Def * tuple_of_types(const Def *t)