38 auto add_fvs(
const Def* def) {
40 return fvs.emplace(def);
44 using NodeQueue = std::queue<Node*>;
46 bool is_bot(
Node* node)
const {
return node->pass == 0; }
47 bool is_done(
Node* node)
const {
return !is_bot(node) && node->pass < cur_pass_; }
48 void mark(Node* node) { node->pass = cur_pass_; }
52 void classify(Node* node,
const Def* fd,
bool& spawned_pred, NodeQueue& worklist);
54 std::pair<Node*, bool> build_node(Def* mut, NodeQueue& worklist);
55 void propagate(NodeQueue& worklist);
57 World& world() {
return world_; }
60 unsigned cur_pass_ = 1;
99 void start()
override;
114 Stub make_stub(
const DefSet& fvs,
Lam* old_lam);
115 Stub make_stub(
Lam* old_lam);
116 void rewrite_body(
const Stub&);
119 const Def* clos_type_of(
const Pi* pi,
const Def* env_type =
nullptr);
121 const Pi* rewrite_ret_cn(
const Pi*);
130 std::queue<Lam*> body_worklist_;
131 bool converting_ =
false;
static auto isa(const Def *def)
const Def * type() const noexcept
Yields the "raw" type of this Def (maybe nullptr).
A dependent function type.
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
World & world()=delete
Hides both and forbids direct access.
This is a thin wrapper for absl::InlinedVector<T, N, A> which is a drop-in replacement for std::vecto...
The World represents the whole program and manages creation of MimIR nodes (Defs).
const Def * rewrite_mut_Global(Global *) final
const Def * rewrite_imm_Extract(const Extract *) final
const Def * rewrite_mut_Pi(Pi *) final
ClosConv(World &world, flags_t annex)
const Def * rewrite_imm_App(const App *) final
const Def * rewrite_imm_Pi(const Pi *) final
const Def * rewrite_mut_Lam(Lam *) final
void start() override
Actual entry.
const DefSet & run(Lam *lam)
Returns the free defs lam has to capture; see the class description.
DefMap< const Def * > Def2Def
Vector< const Def * > DefVec
GIDMap< const Def *, To > DefMap
GIDSet< const Def * > DefSet