9 visit(def, Lattice::Known);
15 if (
auto [_, ins] = analyzed_.emplace(def); !ins)
return;
16 if (def->isa<
Var>())
return;
18 if (
auto app = def->isa<
App>()) {
20 visit(app->callee(), Lattice::Known);
23 for (
auto d : def->
deps())
28void EtaExpPhase::visit(
const Def* def, Lattice l) {
29 if (
auto lam = def->isa_mut<
Lam>()) join(lam, l);
34 auto new_mut = rewrite_no_eta(old_mut)->as_mut();
35 if (old_mut->
is_external()) new_mut->make_external();
39 if (
auto lam = old_def->isa<
Lam>(); lam && lattice(lam) == Both) {
40 auto [i, ins] = lam2eta_.emplace(lam,
nullptr);
42 DLOG(
"eta-expand: `{}` → `{}`", lam, i->second);
50 auto callee = rewrite_no_eta(app->
callee());
const Def * callee() const
Defs deps() const noexcept
bool is_external() const noexcept
const Def * rewrite(const Def *) final
const Def * rewrite_imm_Var(const Var *) final
const Def * rewrite_imm_App(const App *) final
void rewrite_external(Def *) final
bool analyze() final
You can do an optional fixed-point loop on the RWPhase::old_world before rewriting.
static Lam * eta_expand(Filter, const Def *f)
World & new_world()
Create new Defs into this.
World & old_world()
Get old Defs from here.
virtual const Def * rewrite(const Def *)
A variable introduced by a binder (mutable).
const Def * app(const Def *callee, const Def *arg)
const Def * var(Def *mut)
#define DLOG(...)
Vaporizes to nothingness in Debug build.
bool visit(IndexSet< Indexer, Key > &set, const Key &key)