All Downloads are FREE. Search and download functionalities are using the official Maven repository.

z3-z3-4.13.0.src.ast.recurse_expr.h Maven / Gradle / Ivy

The newest version!
/*++
Copyright (c) 2006 Microsoft Corporation

Module Name:

    recurse_expr.h

Abstract:

    Traverse an expression applying a visitor.

Author:

    Leonardo de Moura (leonardo) 2008-01-11.

Revision History:

--*/
#pragma once

#include "ast/ast.h"
#include "util/obj_hashtable.h"

template
class recurse_expr : public Visitor {
    obj_map                          m_cache;
    ptr_vector                          m_todo;
    vector                m_results1;
    vector                m_results2;

    bool is_cached(expr * n) const { T c; return m_cache.find(n, c); }
    T get_cached(expr * n) const { return m_cache.find(n); }
    void cache_result(expr * n, T c) { m_cache.insert(n, c); }
    
    void visit(expr * n, bool & visited);
    bool visit_children(expr * n);
    void process(expr * n);
    
public:
    recurse_expr(Visitor const & v = Visitor()):Visitor(v) {}
    T operator()(expr * n);
    void reset() { m_cache.reset(); m_todo.reset(); }
    void finalize() { m_cache.finalize(); m_todo.finalize(); }
};





© 2015 - 2024 Weber Informatics LLC | Privacy Policy