12 if (
auto [_, ins] = analyzed_.emplace(def); !ins)
return;
13 if (def->isa<
Var>())
return;
15 for (
auto d : def->
deps())
19void BetaRedPhase::visit(
const Def* def,
bool candidate) {
20 if (
auto lam = def->isa_mut<
Lam>()) {
21 if (
auto [i, ins] = candidates_.emplace(lam, candidate); !ins) i->second =
false;
28 DLOG(
"beta-reduce: `{}`", old_lam);
29 if (
auto var = old_lam->has_var()) {
35 return rewrite(old_lam->body());
38 return Rewriter::rewrite_imm_App(app);
const Def * callee() const
bool analyze() final
You can do an optional fixed-point loop on the RWPhase::old_world before rewriting.
const Def * rewrite_imm_App(const App *) final
bool is_set() const
Yields true if empty or the last op is set.
Defs deps() const noexcept
T * isa_mut() const
If this is mutable, it will cast constness away and perform a dynamic_cast to T.
bool todo_
Set to true to indicate that you want to rerun all Phasees in current your fixed-point PhaseMan.
World & old_world()
Get old Defs from here.
virtual const Def * map(const Def *old_def, const Def *new_def)
virtual const Def * rewrite(const Def *)
A variable introduced by a binder (mutable).
#define DLOG(...)
Vaporizes to nothingness in Debug build.
bool visit(IndexSet< Indexer, Key > &set, const Key &key)