ltl: get rid of ltl::ref_formula

Instead, manage all reference counting from ltl::formula.
It ridance of virtual calls to clone() and destroy() easily compensate
the extra test in destroy() to not delete constant nodes.

* src/ltlast/refformula.cc, src/ltlast/refformula.hh: Delete.
* src/ltlast/Makefile.am, wrap/python/spot.i: Adjust.
* src/ltlast/atomic_prop.cc, src/ltlast/atomic_prop.hh,
src/ltlast/binop.cc, src/ltlast/binop.hh, src/ltlast/bunop.cc,
src/ltlast/bunop.hh, src/ltlast/formula.cc, src/ltlast/formula.hh,
src/ltlast/multop.cc, src/ltlast/multop.hh, src/ltlast/unop.cc,
src/ltlast/unop.hh: Ajust the reference counting code.
This commit is contained in:
Alexandre Duret-Lutz 2014-10-25 16:47:44 +02:00
parent d79da2e941
commit 8d947a8782
16 changed files with 70 additions and 210 deletions

View file

@ -36,7 +36,7 @@ namespace spot
namespace ltl
{
multop::multop(type op, vec* v)
: ref_formula(MultOp), op_(op), children_(v)
: formula(MultOp), op_(op), children_(v)
{
unsigned s = v->size();
assert(s > 1);
@ -592,7 +592,7 @@ namespace spot
v->insert(v->begin(), constant::true_instance());
}
const multop* res;
const formula* res;
// Insert the key with the dummy nullptr just
// to check if p already exists.
auto ires = instances.emplace(key(op, v), nullptr);
@ -602,14 +602,13 @@ namespace spot
for (auto f: *v)
f->destroy();
delete v;
res = ires.first->second;
res = ires.first->second->clone();
}
else
{
// The instance did not already exist.
res = ires.first->second = new multop(op, v);
}
res->clone();
return res;
}
@ -633,9 +632,9 @@ namespace spot
{
for (const auto& i: instances)
os << i.second << " = "
<< i.second->ref_count_() << " * "
<< 1 + i.second->refs_ << " * "
<< i.second->dump()
<< std::endl;
<< '\n';
return os;
}