Check trivial multop equality at build time. The makes the
equal visitor useless, since two equals formulae will now share the same address. * src/ltlast/multop.hh (add_sorted): New function. (paircmp): New comparison functor. (map): Use paircmp, we want to compare the vectors' contents, not their addresses. * src/ltlast/multop.cc (add_sorted): New function. (add): Use it. * src/ltltest/equals.cc, src/ltltest/tostring.cc: Compare pointers instead of calling equal. * src/ltlvisit/equals.cc, src/ltlvisit/equals.hh: Delete. * src/ltlvisit/Makefile.am (libltlvisit_la_SOURCES): Remove equals.cc and equals.hh. * wrap/spot.i: Do not include equals.hh.
This commit is contained in:
parent
9123e56ff9
commit
1cdfea31b0
10 changed files with 65 additions and 197 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include <utility>
|
||||
#include "multop.hh"
|
||||
#include "visitor.hh"
|
||||
#include "ltlvisit/destroy.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
|
|
@ -107,6 +108,27 @@ namespace spot
|
|||
return instance(op, v);
|
||||
}
|
||||
|
||||
void
|
||||
multop::add_sorted(vec* v, formula* f)
|
||||
{
|
||||
// Keep V sorted. When adding a new multop, iterate over all
|
||||
// element until we find either an identicalle element, or the
|
||||
// place where the new one should be inserted.
|
||||
vec::iterator i;
|
||||
for (i = v->begin(); i != v->end(); ++i)
|
||||
{
|
||||
if (*i > f)
|
||||
break;
|
||||
if (*i == f)
|
||||
{
|
||||
// F is arleady a child. Drop it.
|
||||
destroy(f);
|
||||
return;
|
||||
}
|
||||
}
|
||||
v->insert(i, f);
|
||||
}
|
||||
|
||||
multop::vec*
|
||||
multop::add(type op, vec* v, formula* f)
|
||||
{
|
||||
|
|
@ -117,13 +139,15 @@ namespace spot
|
|||
{
|
||||
unsigned ps = p->size();
|
||||
for (unsigned i = 0; i < ps; ++i)
|
||||
v->push_back(p->nth(i));
|
||||
// that sub-formula is now useless
|
||||
add_sorted(v, p->nth(i));
|
||||
// That sub-formula is now useless, drop it.
|
||||
// Note that we use unref(), not destroy(), because we've
|
||||
// adopted its children and don't want to destroy these.
|
||||
formula::unref(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
v->push_back(f);
|
||||
add_sorted(v, f);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,14 +65,28 @@ namespace spot
|
|||
static unsigned instance_count();
|
||||
|
||||
protected:
|
||||
// Sorted list of formulae. (Sorted by pointer comparison.)
|
||||
typedef std::vector<formula*> vec;
|
||||
|
||||
|
||||
typedef std::pair<type, vec*> pair;
|
||||
typedef std::map<pair, formula*> map;
|
||||
struct paircmp
|
||||
{
|
||||
bool
|
||||
operator () (const pair& p1, const pair& p2) const
|
||||
{
|
||||
if (p1.first != p2.first)
|
||||
return p1.first < p2.first;
|
||||
return *p1.second < *p2.second;
|
||||
}
|
||||
};
|
||||
typedef std::map<pair, formula*, paircmp> map;
|
||||
static map instances;
|
||||
|
||||
multop(type op, vec* v);
|
||||
static multop* instance(type op, vec* v);
|
||||
static vec* multop::add(type op, vec* v, formula* f);
|
||||
static void multop::add_sorted(vec* v, formula* f);
|
||||
|
||||
virtual ~multop();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue