z3-z3-4.13.0.src.ast.ast_trail.h Maven / Gradle / Ivy
The newest version!
/*++
Copyright (c) 2006 Microsoft Corporation
Module Name:
ast_trail.h
Abstract:
Author:
Leonardo de Moura (leonardo) 2008-06-02.
Revision History:
Extracted AST specific features from trail.h
nbjorner 2014-9-28
--*/
#pragma once
#include "ast/ast.h"
#include "util/trail.h"
template
class ast2ast_trailmap {
ref_vector m_domain;
ref_vector m_range;
obj_map m_map;
public:
ast2ast_trailmap(ast_manager& m):
m_domain(m),
m_range(m),
m_map()
{}
bool find(S* s, T*& t) {
return m_map.find(s,t);
}
void insert(S* s, T* t) {
SASSERT(!m_map.contains(s));
m_domain.push_back(s);
m_range.push_back(t);
m_map.insert(s,t);
}
void pop() {
SASSERT(!m_domain.empty());
m_map.remove(m_domain.back());
m_domain.pop_back();
m_range.pop_back();
}
};
template
class ast2ast_trail : public trail {
ast2ast_trailmap& m_map;
public:
ast2ast_trail(ast2ast_trailmap& m, S* s, T* t) :
m_map(m) {
m.insert(s,t);
}
void undo() override {
m_map.pop();
}
};