void visit(expr const & e) { switch (e.kind()) { case expr_kind::Sort: return; case expr_kind::Macro: visit_macro(e); return; case expr_kind::Constant: visit_constant(e); return; case expr_kind::Var: lean_unreachable(); case expr_kind::Meta: lean_unreachable(); case expr_kind::Local: return; case expr_kind::App: visit_app(e); return; case expr_kind::Lambda: visit_binding(e); return; case expr_kind::Pi: visit_binding(e); return; case expr_kind::Let: visit_let(e); return; } }
expr visit(expr const & e) { switch (e.kind()) { case expr_kind::Sort: case expr_kind::Constant: case expr_kind::Var: case expr_kind::Meta: case expr_kind::Local: return e; default: break; } check_system("unfold macros"); auto it = m_cache.find(e); if (it != m_cache.end()) return it->second; switch (e.kind()) { case expr_kind::Sort: case expr_kind::Constant: case expr_kind::Var: case expr_kind::Meta: case expr_kind::Local: lean_unreachable(); case expr_kind::Macro: return save_result(e, visit_macro(e)); case expr_kind::App: return save_result(e, visit_app(e)); case expr_kind::Lambda: case expr_kind::Pi: return save_result(e, visit_binding(e)); } lean_unreachable(); }
expr replace_visitor::visit_pi(expr const & e) { return visit_binding(e); }