3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-15 21:38:44 +00:00

Replace rule API

This commit is contained in:
Arie Gurfinkel 2018-07-12 22:38:29 +03:00
parent 0035d9b8cb
commit 3a01fd791b
2 changed files with 46 additions and 26 deletions

View file

@ -358,6 +358,23 @@ namespace datalog {
DEL_VECTOR(m_rules); DEL_VECTOR(m_rules);
} }
void rule_set::replace_rule(rule * r, rule * other) {
TRACE("dl", r->display(m_context, tout << "replace:"););
func_decl* d = r->get_decl();
rule_vector* rules = m_head2rules.find(d);
#define REPLACE_VECTOR(_v) \
for (unsigned i = (_v).size(); i > 0; ) { \
--i; \
if ((_v)[i] == r) { \
(_v)[i] = other; \
break; \
} \
} \
REPLACE_VECTOR(*rules);
REPLACE_VECTOR(m_rules);
}
void rule_set::ensure_closed() { void rule_set::ensure_closed() {
if (!is_closed()) { if (!is_closed()) {
VERIFY(close()); VERIFY(close());

View file

@ -203,6 +203,10 @@ namespace datalog {
\brief Remove rule \c r from the rule set. \brief Remove rule \c r from the rule set.
*/ */
void del_rule(rule * r); void del_rule(rule * r);
/**
\brief Replace a rule \c r with the rule \c other
*/
void replace_rule(rule * r, rule * other);
/** /**
\brief Add all rules from a different rule_set. \brief Add all rules from a different rule_set.
@ -280,4 +284,3 @@ namespace datalog {
}; };
#endif /* DL_RULE_SET_H_ */ #endif /* DL_RULE_SET_H_ */