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///@{
11inline const Def* op_cps2ds_dep(const Def* f) {
12 auto& world = f->world();
13 // TODO: assert continuation
14 world.DLOG("f: {} : {}", f, f->type());
15 auto f_ty = f->type()->as<Pi>();
16 auto T = f_ty->dom(0);
17 auto U = f_ty->dom(1)->as<Pi>()->dom();
18 world.DLOG("T: {}", T);
19 world.DLOG("U: {}", U);
20
21 auto Uf = world.mut_lam(T, world.type())->set("Uf");
22 world.DLOG("Uf: {} : {}", Uf, Uf->type());
23
24 const Def* rewritten_codom;
25
26 if (auto f_ty_sig = f_ty->dom()->isa_mut<Sigma>()) {
27 auto dom_var = f_ty_sig->var((nat_t)0);
28 world.DLOG("dom_var: {}", dom_var);
29 auto closed_dom_var = Uf->var();
30 rewritten_codom = rewrite(U, f_ty_sig, closed_dom_var);
31 } else {
32 rewritten_codom = U;
33 }
34 Uf->set(true, rewritten_codom);
35
36 auto ax_app = world.app(world.annex<direct::cps2ds_dep>(), {T, Uf});
37
38 world.DLOG("axiom app: {} : {}", ax_app, ax_app->type());
39
40 return world.app(ax_app, f);
41}
42///@}
43
44} // namespace mim::plug::direct
Base class for all Defs.
Definition def.h:223
Def * set(size_t i, const Def *def)
Successively set from left to right.
Definition def.cpp:246
A dependent function type.
Definition lam.h:11
Ref dom() const
Definition lam.h:32
A dependent tuple type.
Definition tuple.h:9
The direct style Plugin
Definition direct.h:7
const Def * op_cps2ds_dep(const Def *f)
Definition direct.h:11
u64 nat_t
Definition types.h:43
DefVec rewrite(Def *mut, Ref arg)
Definition rewrite.cpp:45