* src/misc/freelist.hh (free_list::remove, free_list::insert): New
methods. * src/misc/freelist.cc (free_list::register_n, free_list::releases_n): Rewrite using free_list::remove and free_list::insert. (free_list::remove, free_list::insert): New methods. * src/tgba/bdddict.hh (bdd_dict::register_anonymous_variables): New method. (bdd_dict::annon_free_list): New subclass. (bdd_dict::free_annonymous_list_of_type_of): New attribute. * src/tgba/bdddict.cc (bdd_dict::register_all_variables_of, bdd_dict::unregister_all_my_variables): Handle anonymous variables too. (bdd_dict::register_anonymous_variables, bdd_dict::annon_free_list::annon_free_list, bdd_dict::annon_free_list::extend): New methods.
This commit is contained in:
parent
aba2dc75d7
commit
784ccafb1b
5 changed files with 213 additions and 33 deletions
|
|
@ -32,6 +32,7 @@ namespace spot
|
|||
next_to_now(bdd_newpair()),
|
||||
now_to_next(bdd_newpair())
|
||||
{
|
||||
free_annonymous_list_of[0] = annon_free_list(this);
|
||||
}
|
||||
|
||||
bdd_dict::~bdd_dict()
|
||||
|
|
@ -138,6 +139,25 @@ namespace spot
|
|||
}
|
||||
|
||||
|
||||
int
|
||||
bdd_dict::register_anonymous_variables(int n, const void* for_me)
|
||||
{
|
||||
free_annonymous_list_of_type::iterator i =
|
||||
free_annonymous_list_of.find(for_me);
|
||||
|
||||
if (i == free_annonymous_list_of.end())
|
||||
{
|
||||
typedef free_annonymous_list_of_type fal;
|
||||
i = (free_annonymous_list_of.insert
|
||||
(fal::value_type(for_me, free_annonymous_list_of[0]))).first;
|
||||
}
|
||||
int res = i->second.register_n(n);
|
||||
while (n--)
|
||||
var_refs[res + n].insert(for_me);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bdd_dict::register_all_variables_of(const void* from_other,
|
||||
const void* for_me)
|
||||
|
|
@ -149,6 +169,7 @@ namespace spot
|
|||
if (s.find(from_other) != s.end())
|
||||
s.insert(for_me);
|
||||
}
|
||||
free_annonymous_list_of[for_me] = free_annonymous_list_of[from_other];
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -196,10 +217,19 @@ namespace spot
|
|||
else
|
||||
{
|
||||
vi = acc_formula_map.find(var);
|
||||
f = vi->second;
|
||||
assert(vi != now_formula_map.end());
|
||||
acc_map.erase(f);
|
||||
acc_formula_map.erase(vi);
|
||||
if (vi != acc_formula_map.end())
|
||||
{
|
||||
f = vi->second;
|
||||
acc_map.erase(f);
|
||||
acc_formula_map.erase(vi);
|
||||
}
|
||||
else
|
||||
{
|
||||
free_annonymous_list_of_type::iterator i;
|
||||
for (i = free_annonymous_list_of.begin();
|
||||
i != free_annonymous_list_of.end(); ++i)
|
||||
i->second.remove(var, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Actually release the associated BDD variables, and the
|
||||
|
|
@ -208,6 +238,7 @@ namespace spot
|
|||
ltl::destroy(f);
|
||||
var_refs.erase(cur);
|
||||
}
|
||||
free_annonymous_list_of.erase(me);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -319,4 +350,25 @@ namespace spot
|
|||
dump(std::cerr);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
|
||||
bdd_dict::annon_free_list::annon_free_list(bdd_dict* d)
|
||||
: dict_(d)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
bdd_dict::annon_free_list::extend(int n)
|
||||
{
|
||||
assert(dict_);
|
||||
int b = dict_->allocate_variables(n);
|
||||
|
||||
free_annonymous_list_of_type::iterator i;
|
||||
for (i = dict_->free_annonymous_list_of.begin();
|
||||
i != dict_->free_annonymous_list_of.end(); ++i)
|
||||
if (&i->second != this)
|
||||
i->second.insert(b, n);
|
||||
return b;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2003 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
// et Marie Curie.
|
||||
//
|
||||
|
|
@ -118,6 +118,15 @@ namespace spot
|
|||
/// automaton).
|
||||
void register_acceptance_variables(bdd f, const void* for_me);
|
||||
|
||||
/// \brief Register anonymous BDD variables.
|
||||
///
|
||||
/// Return (and maybe allocate) \a n consecutive BDD variables which
|
||||
/// will be used only by \a for_me.
|
||||
///
|
||||
/// \return The variable number. Use bdd_ithvar() or bdd_nithvar()
|
||||
/// to convert this to a BDD.
|
||||
int register_anonymous_variables(int n, const void* for_me);
|
||||
|
||||
/// \brief Duplicate the variable usage of another object.
|
||||
///
|
||||
/// This tells this dictionary that the \a for_me object
|
||||
|
|
@ -136,7 +145,7 @@ namespace spot
|
|||
bool is_registered_proposition(const ltl::formula* f, const void* by_me);
|
||||
bool is_registered_state(const ltl::formula* f, const void* by_me);
|
||||
bool is_registered_acceptance_variable(const ltl::formula* f,
|
||||
const void* by_me);
|
||||
const void* by_me);
|
||||
/// @}
|
||||
|
||||
/// \brief Dump all variables for debugging.
|
||||
|
|
@ -155,6 +164,24 @@ namespace spot
|
|||
typedef Sgi::hash_map<int, ref_set> vr_map;
|
||||
vr_map var_refs;
|
||||
|
||||
|
||||
class annon_free_list : public spot::free_list
|
||||
{
|
||||
public:
|
||||
// WARNING: We need a default constructor so this can be used in
|
||||
// a hash; but we should ensure that no object in the hash is
|
||||
// constructed with d==0.
|
||||
annon_free_list(bdd_dict* d = 0);
|
||||
virtual int extend(int n);
|
||||
private:
|
||||
bdd_dict* dict_;
|
||||
};
|
||||
|
||||
/// List of unused anonymous variable number for each automaton.
|
||||
typedef Sgi::hash_map<const void*, annon_free_list,
|
||||
ptr_hash<void> > free_annonymous_list_of_type;
|
||||
free_annonymous_list_of_type free_annonymous_list_of;
|
||||
|
||||
private:
|
||||
// Disallow copy.
|
||||
bdd_dict(const bdd_dict& other);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue