lean2/src/kernel/replace_visitor.h
Leonardo de Moura 5ce134e24e chore(kernel): binder => binding where appropriate
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-17 11:37:27 -07:00

39 lines
1.2 KiB
C++

/*
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#pragma once
#include "kernel/expr_maps.h"
namespace lean {
/**
\brief Base class for implementing operations that apply modifications
on expressions.
The default behavior is a NOOP, users must create subclasses and
redefine the visit_* methods.
*/
class replace_visitor {
protected:
typedef expr_map<expr> cache;
cache m_cache;
expr save_result(expr const & e, expr && r, bool shared);
virtual expr visit_sort(expr const &);
virtual expr visit_macro(expr const &);
virtual expr visit_constant(expr const &);
virtual expr visit_var(expr const &);
virtual expr visit_mlocal(expr const &);
virtual expr visit_meta(expr const &);
virtual expr visit_local(expr const &);
virtual expr visit_app(expr const &);
virtual expr visit_binding(expr const &);
virtual expr visit_lambda(expr const &);
virtual expr visit_pi(expr const &);
virtual expr visit_let(expr const &);
virtual expr visit(expr const &);
public:
expr operator()(expr const & e) { return visit(e); }
void clear() { m_cache.clear(); }
};
}