Rename formula::ref and formula::unref as formula::clone
and formula::destroy. * src/ltlast/atomic_prop.cc, src/ltlast/automatop.cc, src/ltlast/binop.cc, src/ltlast/formula.hh, src/ltlast/formula.cc, src/ltlast/multop.cc, src/ltlast/unop.cc, src/ltlenv/declenv.cc, src/ltlvisit/basicreduce.cc, src/ltlvisit/clone.cc, src/ltlvisit/destroy.cc, src/ltlvisit/nenoform.cc, src/ltlvisit/randomltl.cc, src/ltlvisit/reduce.cc, src/tgbatest/randtgba.cc: Adjust.
This commit is contained in:
parent
8e4e692e7f
commit
b0888257f8
16 changed files with 63 additions and 54 deletions
13
ChangeLog
13
ChangeLog
|
|
@ -1,3 +1,16 @@
|
|||
2009-11-08 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
||||
|
||||
Rename formula::ref and formula::unref as formula::clone
|
||||
and formula::destroy.
|
||||
|
||||
* src/ltlast/atomic_prop.cc, src/ltlast/automatop.cc,
|
||||
src/ltlast/binop.cc, src/ltlast/formula.hh, src/ltlast/formula.cc,
|
||||
src/ltlast/multop.cc, src/ltlast/unop.cc, src/ltlenv/declenv.cc,
|
||||
src/ltlvisit/basicreduce.cc, src/ltlvisit/clone.cc,
|
||||
src/ltlvisit/destroy.cc, src/ltlvisit/nenoform.cc,
|
||||
src/ltlvisit/randomltl.cc, src/ltlvisit/reduce.cc,
|
||||
src/tgbatest/randtgba.cc: Adjust.
|
||||
|
||||
2009-11-07 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
||||
|
||||
Change the way references are counted to speedup cloning.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2003, 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// Copyright (C) 2003, 2004, 2005, 2009 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
// et Marie Curie.
|
||||
//
|
||||
|
|
@ -78,11 +78,11 @@ namespace spot
|
|||
map::iterator i = instances.find(p);
|
||||
if (i != instances.end())
|
||||
{
|
||||
return static_cast<atomic_prop*>(i->second->ref());
|
||||
return static_cast<atomic_prop*>(i->second->clone());
|
||||
}
|
||||
atomic_prop* ap = new atomic_prop(name, env);
|
||||
instances[p] = ap;
|
||||
return static_cast<atomic_prop*>(ap->ref());
|
||||
return static_cast<atomic_prop*>(ap->clone());
|
||||
}
|
||||
|
||||
unsigned
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ namespace spot
|
|||
|
||||
// Dereference children.
|
||||
for (unsigned n = 0; n < size(); ++n)
|
||||
formula::unref(nth(n));
|
||||
formula::destroy(nth(n));
|
||||
|
||||
delete children_;
|
||||
}
|
||||
|
|
@ -79,13 +79,13 @@ namespace spot
|
|||
{
|
||||
// The instance already exists.
|
||||
for (vec::iterator vi = v->begin(); vi != v->end(); ++vi)
|
||||
formula::unref(*vi);
|
||||
formula::destroy(*vi);
|
||||
delete v;
|
||||
return static_cast<automatop*>(i->second->ref());
|
||||
return static_cast<automatop*>(i->second->clone());
|
||||
}
|
||||
automatop* res = new automatop(nfa, v, negated);
|
||||
instances[p] = res;
|
||||
return static_cast<automatop*>(res->ref());
|
||||
return static_cast<automatop*>(res->clone());
|
||||
}
|
||||
|
||||
unsigned
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ namespace spot
|
|||
instances.erase(i);
|
||||
|
||||
// Dereference children.
|
||||
formula::unref(first());
|
||||
formula::unref(second());
|
||||
formula::destroy(first());
|
||||
formula::destroy(second());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -143,13 +143,13 @@ namespace spot
|
|||
if (i != instances.end())
|
||||
{
|
||||
// This instance already exists.
|
||||
formula::unref(first);
|
||||
formula::unref(second);
|
||||
return static_cast<binop*>(i->second->ref());
|
||||
formula::destroy(first);
|
||||
formula::destroy(second);
|
||||
return static_cast<binop*>(i->second->clone());
|
||||
}
|
||||
binop* ap = new binop(op, first, second);
|
||||
instances[p] = ap;
|
||||
return static_cast<binop*>(ap->ref());
|
||||
return static_cast<binop*>(ap->clone());
|
||||
}
|
||||
|
||||
unsigned
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2003, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// Copyright (C) 2003, 2005, 2009 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
// et Marie Curie.
|
||||
//
|
||||
|
|
@ -27,7 +27,7 @@ namespace spot
|
|||
namespace ltl
|
||||
{
|
||||
formula*
|
||||
formula::ref()
|
||||
formula::clone()
|
||||
{
|
||||
ref_();
|
||||
return this;
|
||||
|
|
@ -38,7 +38,7 @@ namespace spot
|
|||
}
|
||||
|
||||
void
|
||||
formula::unref(formula* f)
|
||||
formula::destroy(formula* f)
|
||||
{
|
||||
if (f->unref_())
|
||||
delete f;
|
||||
|
|
|
|||
|
|
@ -79,17 +79,13 @@ namespace spot
|
|||
/// \brief clone this node
|
||||
///
|
||||
/// This increments the reference counter of this node (if one is
|
||||
/// used). You should almost never use this method directly as
|
||||
/// it doesn't touch the children. If you want to clone a
|
||||
/// whole formula, use spot::ltl::clone() instead.
|
||||
formula* ref();
|
||||
/// used).
|
||||
formula* clone();
|
||||
/// \brief release this node
|
||||
///
|
||||
/// This decrements the reference counter of this node (if one is
|
||||
/// used) and can free the object. You should almost never use
|
||||
/// this method directly as it doesn't touch the children. If you
|
||||
/// want to release a whole formula, use spot::ltl::destroy() instead.
|
||||
static void unref(formula* f);
|
||||
/// used) and can free the object.
|
||||
static void destroy(formula* f);
|
||||
|
||||
/// Return a canonic representation of the formula
|
||||
const std::string& dump() const;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace spot
|
|||
|
||||
// Dereference children.
|
||||
for (unsigned n = 0; n < size(); ++n)
|
||||
formula::unref(nth(n));
|
||||
formula::destroy(nth(n));
|
||||
|
||||
delete children_;
|
||||
}
|
||||
|
|
@ -130,8 +130,8 @@ namespace spot
|
|||
{
|
||||
unsigned ps = p->size();
|
||||
for (unsigned n = 0; n < ps; ++n)
|
||||
inlined.push_back(p->nth(n)->ref());
|
||||
formula::unref(*i);
|
||||
inlined.push_back(p->nth(n)->clone());
|
||||
formula::destroy(*i);
|
||||
i = v->erase(i);
|
||||
}
|
||||
else
|
||||
|
|
@ -145,7 +145,7 @@ namespace spot
|
|||
std::sort(v->begin(), v->end(), formula_ptr_less_than());
|
||||
|
||||
// Remove duplicates. We can't use std::unique(), because we
|
||||
// must unref() any formula we drop.
|
||||
// must destroy() any formula we drop.
|
||||
{
|
||||
formula* last = 0;
|
||||
vec::iterator i = v->begin();
|
||||
|
|
@ -153,7 +153,7 @@ namespace spot
|
|||
{
|
||||
if (*i == last)
|
||||
{
|
||||
formula::unref(*i);
|
||||
formula::destroy(*i);
|
||||
i = v->erase(i);
|
||||
}
|
||||
else
|
||||
|
|
@ -193,9 +193,9 @@ namespace spot
|
|||
{
|
||||
// The instance already exists.
|
||||
for (vec::iterator vi = v->begin(); vi != v->end(); ++vi)
|
||||
formula::unref(*vi);
|
||||
formula::destroy(*vi);
|
||||
delete v;
|
||||
return static_cast<multop*>(i->second->ref());
|
||||
return static_cast<multop*>(i->second->clone());
|
||||
}
|
||||
|
||||
// This is the first instance of this formula.
|
||||
|
|
@ -203,7 +203,7 @@ namespace spot
|
|||
// Record the instance in the map,
|
||||
multop* ap = new multop(op, v);
|
||||
instances[p] = ap;
|
||||
return ap->ref();
|
||||
return ap->clone();
|
||||
}
|
||||
|
||||
formula*
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace spot
|
|||
instances.erase(i);
|
||||
|
||||
// Dereference child.
|
||||
formula::unref(child());
|
||||
formula::destroy(child());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -110,12 +110,12 @@ namespace spot
|
|||
if (i != instances.end())
|
||||
{
|
||||
// This instance already exists.
|
||||
formula::unref(child);
|
||||
return static_cast<unop*>(i->second->ref());
|
||||
formula::destroy(child);
|
||||
return static_cast<unop*>(i->second->clone());
|
||||
}
|
||||
unop* ap = new unop(op, child);
|
||||
instances[p] = ap;
|
||||
return static_cast<unop*>(ap->ref());
|
||||
return static_cast<unop*>(ap->clone());
|
||||
}
|
||||
|
||||
unsigned
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// Copyright (C) 2004, 2009 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
// et Marie Curie.
|
||||
//
|
||||
|
|
@ -51,8 +51,7 @@ namespace spot
|
|||
prop_map::iterator i = props_.find(prop_str);
|
||||
if (i == props_.end())
|
||||
return 0;
|
||||
// It's an atomic_prop, so we do not have to use the clone() visitor.
|
||||
return i->second->ref();
|
||||
return i->second->clone();
|
||||
}
|
||||
|
||||
const std::string&
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2004, 2007, 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// Copyright (C) 2004, 2007, 2008, 2009 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
// et Marie Curie.
|
||||
//
|
||||
|
|
@ -76,7 +76,7 @@ namespace spot
|
|||
void
|
||||
visit(atomic_prop* ap)
|
||||
{
|
||||
formula* f = ap->ref();
|
||||
formula* f = ap->clone();
|
||||
result_ = f;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,13 +43,13 @@ namespace spot
|
|||
void
|
||||
clone_visitor::visit(atomic_prop* ap)
|
||||
{
|
||||
result_ = ap->ref();
|
||||
result_ = ap->clone();
|
||||
}
|
||||
|
||||
void
|
||||
clone_visitor::visit(constant* c)
|
||||
{
|
||||
result_ = c->ref();
|
||||
result_ = c->clone();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -93,7 +93,7 @@ namespace spot
|
|||
formula*
|
||||
clone(const formula* f)
|
||||
{
|
||||
formula* res = const_cast<formula*>(f)->ref();
|
||||
formula* res = const_cast<formula*>(f)->clone();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace spot
|
|||
void
|
||||
destroy(const formula* f)
|
||||
{
|
||||
formula::unref(const_cast<formula*>(f));
|
||||
formula::destroy(const_cast<formula*>(f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// Copyright (C) 2003, 2004, 2009 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
// et Marie Curie.
|
||||
//
|
||||
|
|
@ -50,7 +50,7 @@ namespace spot
|
|||
void
|
||||
visit(atomic_prop* ap)
|
||||
{
|
||||
formula* f = ap->ref();
|
||||
formula* f = ap->clone();
|
||||
if (negated_)
|
||||
result_ = unop::instance(unop::Not, f);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2005, 2008 Laboratoire d'Informatique de Paris 6
|
||||
// Copyright (C) 2005, 2008, 2009 Laboratoire d'Informatique de Paris 6
|
||||
// (LIP6), département Systèmes Répartis Coopératifs (SRC), Université
|
||||
// Pierre et Marie Curie.
|
||||
//
|
||||
|
|
@ -40,7 +40,7 @@ namespace spot
|
|||
(void) n;
|
||||
atomic_prop_set::const_iterator i = rl->ap()->begin();
|
||||
std::advance(i, mrand(rl->ap()->size()));
|
||||
return (*i)->ref();
|
||||
return (*i)->clone();
|
||||
}
|
||||
|
||||
formula*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2004, 2006, 2007, 2008 Laboratoire d'Informatique de
|
||||
// Copyright (C) 2004, 2006, 2007, 2008, 2009 Laboratoire d'Informatique de
|
||||
// Paris 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
|
||||
// Université Pierre et Marie Curie.
|
||||
//
|
||||
|
|
@ -59,7 +59,7 @@ namespace spot
|
|||
void
|
||||
visit(atomic_prop* ap)
|
||||
{
|
||||
formula* f = ap->ref();
|
||||
formula* f = ap->clone();
|
||||
result_ = f;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2004, 2005, 2008 Laboratoire d'Informatique de Paris
|
||||
// Copyright (C) 2004, 2005, 2008, 2009 Laboratoire d'Informatique de Paris
|
||||
// 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
|
||||
// Université Pierre et Marie Curie.
|
||||
//
|
||||
|
|
@ -876,7 +876,8 @@ main(int argc, char** argv)
|
|||
spot::ltl::atomic_prop_collect(f);
|
||||
for (spot::ltl::atomic_prop_set::iterator i = tmp->begin();
|
||||
i != tmp->end(); ++i)
|
||||
apf->insert(dynamic_cast<spot::ltl::atomic_prop*>((*i)->ref()));
|
||||
apf->insert(dynamic_cast<spot::ltl::atomic_prop*>
|
||||
((*i)->clone()));
|
||||
spot::ltl::destroy(f);
|
||||
delete tmp;
|
||||
}
|
||||
|
|
@ -890,7 +891,7 @@ main(int argc, char** argv)
|
|||
|
||||
for (spot::ltl::atomic_prop_set::iterator i = ap->begin();
|
||||
i != ap->end(); ++i)
|
||||
apf->insert(dynamic_cast<spot::ltl::atomic_prop*>((*i)->ref()));
|
||||
apf->insert(dynamic_cast<spot::ltl::atomic_prop*>((*i)->clone()));
|
||||
|
||||
if (!opt_S)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue