19        return def_->type()->isa<
Sigma>();
 
 
   33    explicit operator bool()
 const { 
return def_ != 
nullptr; }
 
   34    operator const Tuple*() { 
return def_; }
 
 
   68std::tuple<const Def*, const Def*, const Def*> 
clos_unpack(
const Def* c);
 
   73    auto& w = closure->
world();
 
 
   79template<
class N> std::tuple<const Extract*, N*> 
ca_isa_var(
const Def* def) {
 
   80    if (
auto proj = def->isa<
Extract>()) {
 
   81        if (
auto var = proj->tuple()->isa<
Var>(); var && var->
mut()->isa<N>())
 
   82            return std::tuple(proj, var->mut()->as<N>());
 
   84    return {
nullptr, 
nullptr};
 
 
  124    auto& w      = tup_or_sig->
world();
 
  125    auto new_ops = 
DefVec(tup_or_sig->
num_projs() + 1, [&](
auto i) { return clos_insert_env(i, env, tup_or_sig); });
 
  126    return (tup_or_sig->isa<
Sigma>()) ? w.sigma(new_ops) : w.tuple(new_ops);
 
 
  134    auto& w      = tup_or_sig->
world();
 
  135    auto new_ops = 
DefVec(tup_or_sig->
num_projs() - 1, [&](
auto i) { return clos_remove_env(i, tup_or_sig); });
 
  136    return (tup_or_sig->isa<
Sigma>()) ? w.sigma(new_ops) : w.tuple(new_ops);
 
 
 
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
 
const Def * refine(size_t i, const Def *new_op) const
 
const Def * type() const noexcept
Yields the "raw" type of this Def (maybe nullptr).
 
nat_t num_projs() const
Yields Def::arity(), if it is a Lit, or 1 otherwise.
 
const Def * ret_var()
Yields the Lam::var of the Lam::ret_pi.
 
A dependent function type.
 
static const Pi * isa_basicblock(const Def *d)
Is this a continuation (Pi::isa_cn) that is not Pi::isa_returning?
 
static const Pi * isa_returning(const Def *d)
Is this a continuation (Pi::isa_cn) which has a Pi::ret_pi?
 
Data constructor for a Sigma.
 
A variable introduced by a binder (mutable).
 
The World represents the whole program and manages creation of MimIR nodes (Defs).
 
Wrapper around a Def that can be used to match closures (see isa_clos_lit).
 
const Tuple * operator->()
 
friend ClosLit isa_clos_lit(const Def *, bool)
Tries to match a closure literal.
 
attr get()
Clos annotation. These should appear in front of the code-part.
 
ClosLit isa_clos_lit(const Def *def, bool fn_isa_lam=true)
Tries to match a closure literal.
 
std::tuple< const Extract *, N * > ca_isa_var(const Def *def)
Checks is def is the variable of a mut of type N.
 
Sigma * clos_type(const Pi *pi)
Creates a typed closure type from pi.
 
size_t shift_env(size_t i)
 
const Def * clos_remove_env(size_t i, std::function< const Def *(size_t)> f)
 
const Def * clos_insert_env(size_t i, const Def *env, std::function< const Def *(size_t)> f)
 
const Def * ctype(World &w, Defs doms, const Def *env_type=nullptr)
 
static constexpr size_t Clos_Env_Param
Describes where the environment is placed in the argument list.
 
const Pi * clos_type_to_pi(const Def *ct, const Def *new_env_type=nullptr)
Convert a closure type to a Pi, where the environment type has been removed or replaced by new_env_ty...
 
const Def * apply_closure(const Def *closure, Defs args)
 
std::tuple< const Def *, const Def *, const Def * > clos_unpack(const Def *c)
Deconstruct a closure into (env_type, function, env).
 
const Def * clos_sub_env(const Def *tup_or_sig, const Def *new_env)
 
size_t skip_env(size_t i)
 
const Def * clos_pack(const Def *env, const Def *fn, const Def *ct=nullptr)
Pack a typed closure. This assumes that fn expects the environment as its Clos_Env_Paramth argument.
 
const Def * clos_apply(const Def *closure, const Def *args)
Apply a closure to arguments.
 
const Sigma * isa_clos_type(const Def *def)
 
Vector< const Def * > DefVec