MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
direct.h
Go to the documentation of this file.
1#pragma once
2
3#include <mim/rewrite.h>
4
6
8
9/// @name %%direct.cps2ds_dep
10/// ```
11/// let k: Cn [t: T, Cn U t] = ...;
12/// let f: [t: T] → U = %direct.cps2ds_dep (T, lm (t': T): * = [t → t']U) k;
13/// ```
14///@{
15inline const Def* op_cps2ds_dep(const Def* k) {
16 auto& w = k->world();
17 auto K = Pi::isa_cn(k->type());
18 auto T = K->dom(2, 0);
19 auto U = Pi::isa_cn(K->dom(2, 1))->dom();
20 auto l = w.mut_lam(T, w.type())->set("Uf");
21 auto body = U;
22
23 if (auto dom = K->dom()->isa_mut<Sigma>())
24 if (auto var = dom->has_var())
25 body = VarRewriter(var, l->var()).rewrite(U); // TODO typeof(dom->var()) != typeof(l->var())
26 l->set(true, body);
27
28 return w.app(w.app(w.annex<direct::cps2ds_dep>(), {T, l}), k);
29}
30///@}
31
32} // namespace mim::plug::direct
Base class for all Defs.
Definition def.h:198
World & world() const noexcept
Definition def.cpp:413
const Def * type() const noexcept
Yields the "raw" type of this Def (maybe nullptr).
Definition def.h:242
static const Pi * isa_cn(const Def *d)
Is this a continuation - i.e. is the Pi::codom mim::Bottom?
Definition lam.h:44
const Def * dom() const
Definition lam.h:32
virtual const Def * rewrite(const Def *)
Definition rewrite.cpp:11
A dependent tuple type.
Definition tuple.h:9
The direct style Plugin
Definition direct.h:7
const Def * op_cps2ds_dep(const Def *k)
Definition direct.h:15