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

@ -28,13 +28,14 @@
#include <iostream>
#include "constant.hh"
#include "atomic_prop.hh"
#include "bunop.hh"
namespace spot
{
namespace ltl
{
unop::unop(type op, const formula* child)
: ref_formula(UnOp), op_(op), child_(child)
: formula(UnOp), op_(op), child_(child)
{
props = child->get_props();
switch (op)
@ -299,19 +300,18 @@ namespace spot
break;
}
const unop* res;
const formula* res;
auto ires = instances.emplace(key(op, child), nullptr);
if (!ires.second)
{
// This instance already exists.
child->destroy();
res = ires.first->second;
res = ires.first->second->clone();
}
else
{
res = ires.first->second = new unop(op, child);
}
res->clone();
return res;
}
@ -326,9 +326,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;
}