Commit b09c293f authored by Maximilien Colange's avatar Maximilien Colange
Browse files

Clean the usage of spot::acc_cond::mark_t

spot::acc_cond::mark_t is implemented as a bit vector using a single
unsigned, and implicit conversions between mark_t and unsigned may be
confusing. We try to use the proper interface.

* bin/autfilt.cc, bin/ltlsynt.cc, spot/kripke/kripke.cc,
  spot/misc/game.hh, spot/parseaut/parseaut.yy, spot/priv/accmap.hh,
  spot/ta/ta.cc, spot/ta/taexplicit.cc, spot/ta/taproduct.cc,
  spot/taalgos/emptinessta.cc, spot/taalgos/tgba2ta.cc, spot/twa/acc.cc,
  spot/twa/acc.hh, spot/twa/taatgba.cc, spot/twa/taatgba.hh,
  spot/twa/twagraph.hh, spot/twaalgos/alternation.cc,
  spot/twaalgos/cleanacc.cc, spot/twaalgos/cobuchi.cc,
  spot/twaalgos/complete.cc, spot/twaalgos/couvreurnew.cc,
  spot/twaalgos/degen.cc, spot/twaalgos/dot.cc,
  spot/twaalgos/dtwasat.cc, spot/twaalgos/dualize.cc,
  spot/twaalgos/emptiness.cc, spot/twaalgos/gtec/ce.cc,
  spot/twaalgos/gtec/gtec.cc, spot/twaalgos/gtec/sccstack.cc,
  spot/twaalgos/gv04.cc, spot/twaalgos/hoa.cc, spot/twaalgos/lbtt.cc,
  spot/twaalgos/ltl2tgba_fm.cc, spot/twaalgos/magic.cc,
  spot/twaalgos/ndfs_result.hxx, spot/twaalgos/rabin2parity.cc,
  spot/twaalgos/randomgraph.cc, spot/twaalgos/remfin.cc,
  spot/twaalgos/sbacc.cc, spot/twaalgos/sccfilter.cc,
  spot/twaalgos/sccinfo.cc, spot/twaalgos/sccinfo.hh,
  spot/twaalgos/se05.cc, spot/twaalgos/sepsets.cc,
  spot/twaalgos/simulation.cc, spot/twaalgos/strength.cc,
  spot/twaalgos/stripacc.cc, spot/twaalgos/stutter.cc,
  spot/twaalgos/sum.cc, spot/twaalgos/tau03.cc,
  spot/twaalgos/tau03opt.cc, spot/twaalgos/totgba.cc,
  spot/twaalgos/toweak.cc, python/spot/impl.i, tests/core/acc.cc,
  tests/core/twagraph.cc: do not confuse mark_t and unsigned
* tests/python/acc_cond.ipynb: warn about possible change of the API
parent cfcc18e6
Pipeline #980 passed with stages
in 134 minutes and 17 seconds
...@@ -599,7 +599,7 @@ static bool opt_complement = false; ...@@ -599,7 +599,7 @@ static bool opt_complement = false;
static bool opt_complement_acc = false; static bool opt_complement_acc = false;
static char* opt_decompose_scc = nullptr; static char* opt_decompose_scc = nullptr;
static bool opt_dualize = false; static bool opt_dualize = false;
static spot::acc_cond::mark_t opt_mask_acc = 0U; static spot::acc_cond::mark_t opt_mask_acc = {};
static std::vector<bool> opt_keep_states = {}; static std::vector<bool> opt_keep_states = {};
static unsigned int opt_keep_states_initial = 0; static unsigned int opt_keep_states_initial = 0;
static bool opt_simpl_acc = false; static bool opt_simpl_acc = false;
......
// -*- coding: utf-8 -*- // -*- coding: utf-8 -*-
// Copyright (C) 2017 Laboratoire de Recherche et Développement // Copyright (C) 2017-2018 Laboratoire de Recherche et Développement
// de l'Epita (LRDE). // de l'Epita (LRDE).
// //
// This file is part of Spot, a model checking library. // This file is part of Spot, a model checking library.
...@@ -173,7 +173,7 @@ namespace ...@@ -173,7 +173,7 @@ namespace
unsigned q = split->new_state(); unsigned q = split->new_state();
bdd in = bdd_existcomp(cube, input_bdd); bdd in = bdd_existcomp(cube, input_bdd);
bdd out = bdd_exist(cube, input_bdd); bdd out = bdd_exist(cube, input_bdd);
split->new_edge(src, q, in, 0); split->new_edge(src, q, in, {});
split->new_edge(q, e.dst, out, e.acc); split->new_edge(q, e.dst, out, e.acc);
} }
} }
...@@ -264,7 +264,7 @@ namespace ...@@ -264,7 +264,7 @@ namespace
todo.push_back(e2.dst); todo.push_back(e2.dst);
} }
aut->new_edge(pg2aut[s], pg2aut[e2.dst], aut->new_edge(pg2aut[s], pg2aut[e2.dst],
(e1.cond & out), 0); (e1.cond & out), {});
break; break;
} }
++i; ++i;
......
...@@ -881,7 +881,7 @@ def state_is_accepting(self, src) -> "bool": ...@@ -881,7 +881,7 @@ def state_is_accepting(self, src) -> "bool":
%extend spot::twa_graph { %extend spot::twa_graph {
unsigned new_univ_edge(unsigned src, const std::vector<unsigned>& v, unsigned new_univ_edge(unsigned src, const std::vector<unsigned>& v,
bdd cond, acc_cond::mark_t acc = 0U) bdd cond, acc_cond::mark_t acc = {})
{ {
return self->new_univ_edge(src, v.begin(), v.end(), cond, acc); return self->new_univ_edge(src, v.begin(), v.end(), cond, acc);
} }
......
...@@ -40,7 +40,7 @@ namespace spot ...@@ -40,7 +40,7 @@ namespace spot
{ {
// Do not assert(!done()) here. It is OK to call // Do not assert(!done()) here. It is OK to call
// this function on a state without successor. // this function on a state without successor.
return 0U; return {};
} }
kripke::~kripke() kripke::~kripke()
...@@ -50,6 +50,6 @@ namespace spot ...@@ -50,6 +50,6 @@ namespace spot
acc_cond::mark_t acc_cond::mark_t
kripke::state_acceptance_mark(const state*) const kripke::state_acceptance_mark(const state*) const
{ {
return 0U; return {};
} }
} }
// -*- coding: utf-8 -*- // -*- coding: utf-8 -*-
// Copyright (C) 2017 Laboratoire de Recherche et Développement // Copyright (C) 2017-2018 Laboratoire de Recherche et Développement
// de l'Epita (LRDE). // de l'Epita (LRDE).
// //
// This file is part of Spot, a model checking library. // This file is part of Spot, a model checking library.
...@@ -265,7 +265,7 @@ public: ...@@ -265,7 +265,7 @@ public:
acc_cond::mark_t acc() const override acc_cond::mark_t acc() const override
{ {
return 0; return {};
} }
}; };
......
...@@ -115,8 +115,8 @@ extern "C" int strverscmp(const char *s1, const char *s2); ...@@ -115,8 +115,8 @@ extern "C" int strverscmp(const char *s1, const char *s2);
spot::location state_label_loc; spot::location state_label_loc;
spot::location accset_loc; spot::location accset_loc;
spot::acc_cond::mark_t acc_state; spot::acc_cond::mark_t acc_state;
spot::acc_cond::mark_t neg_acc_sets = 0U; spot::acc_cond::mark_t neg_acc_sets = {};
spot::acc_cond::mark_t pos_acc_sets = 0U; spot::acc_cond::mark_t pos_acc_sets = {};
int plus; int plus;
int minus; int minus;
std::vector<std::string>* state_names = nullptr; std::vector<std::string>* state_names = nullptr;
...@@ -1366,19 +1366,19 @@ acc-sig: '{' acc-sets '}' ...@@ -1366,19 +1366,19 @@ acc-sig: '{' acc-sets '}'
} }
acc-sets: acc-sets:
{ {
$$ = spot::acc_cond::mark_t(0U); $$ = spot::acc_cond::mark_t({});
} }
| acc-sets acc-set | acc-sets acc-set
{ {
if (res.ignore_acc || $2 == -1U) if (res.ignore_acc || $2 == -1U)
$$ = spot::acc_cond::mark_t(0U); $$ = spot::acc_cond::mark_t({});
else else
$$ = $1 | res.aut_or_ks->acc().mark($2); $$ = $1 | res.aut_or_ks->acc().mark($2);
} }
state-acc_opt: state-acc_opt:
{ {
$$ = spot::acc_cond::mark_t(0U); $$ = spot::acc_cond::mark_t({});
} }
| acc-sig | acc-sig
{ {
...@@ -1393,7 +1393,7 @@ state-acc_opt: ...@@ -1393,7 +1393,7 @@ state-acc_opt:
} }
trans-acc_opt: trans-acc_opt:
{ {
$$ = spot::acc_cond::mark_t(0U); $$ = spot::acc_cond::mark_t({});
} }
| acc-sig | acc-sig
{ {
...@@ -1686,7 +1686,7 @@ sign: '+' { $$ = res.plus; } ...@@ -1686,7 +1686,7 @@ sign: '+' { $$ = res.plus; }
// Membership to a pair is represented as (+NUM,-NUM) // Membership to a pair is represented as (+NUM,-NUM)
dstar_accsigs: dstar_accsigs:
{ {
$$ = 0U; $$ = spot::acc_cond::mark_t({});
} }
| dstar_accsigs sign INT | dstar_accsigs sign INT
{ {
...@@ -1830,7 +1830,7 @@ nc-state: ...@@ -1830,7 +1830,7 @@ nc-state:
res.accept_all_seen = true; res.accept_all_seen = true;
auto acc = !strncmp("accept", $1->c_str(), 6) ? auto acc = !strncmp("accept", $1->c_str(), 6) ?
res.h->aut->acc().all_sets() : spot::acc_cond::mark_t(0U); res.h->aut->acc().all_sets() : spot::acc_cond::mark_t({});
res.namer->new_edge(*$1, *$1, bddtrue, acc); res.namer->new_edge(*$1, *$1, bddtrue, acc);
delete $1; delete $1;
} }
...@@ -1839,7 +1839,7 @@ nc-state: ...@@ -1839,7 +1839,7 @@ nc-state:
| nc-ident-list nc-transition-block | nc-ident-list nc-transition-block
{ {
auto acc = !strncmp("accept", $1->c_str(), 6) ? auto acc = !strncmp("accept", $1->c_str(), 6) ?
res.h->aut->acc().all_sets() : spot::acc_cond::mark_t(0U); res.h->aut->acc().all_sets() : spot::acc_cond::mark_t({});
for (auto& p: *$2) for (auto& p: *$2)
{ {
bdd c = bdd_from_int(p.first); bdd c = bdd_from_int(p.first);
...@@ -2041,7 +2041,7 @@ lbtt-state: STATE_NUM INT lbtt-acc ...@@ -2041,7 +2041,7 @@ lbtt-state: STATE_NUM INT lbtt-acc
std::vector<unsigned>{res.cur_state}); std::vector<unsigned>{res.cur_state});
res.acc_state = $3; res.acc_state = $3;
} }
lbtt-acc: { $$ = 0U; } lbtt-acc: { $$ = spot::acc_cond::mark_t({}); }
| lbtt-acc ACC | lbtt-acc ACC
{ {
$$ = $1; $$ = $1;
...@@ -2183,7 +2183,7 @@ fix_acceptance_aux(spot::acc_cond& acc, ...@@ -2183,7 +2183,7 @@ fix_acceptance_aux(spot::acc_cond& acc,
{ {
auto m = in[pos - 1].mark; auto m = in[pos - 1].mark;
auto c = acc.fin(onlyneg & m); auto c = acc.fin(onlyneg & m);
spot::acc_cond::mark_t tmp = 0U; spot::acc_cond::mark_t tmp = {};
for (auto i: both.sets()) for (auto i: both.sets())
{ {
if (m.has(i)) if (m.has(i))
...@@ -2198,7 +2198,7 @@ fix_acceptance_aux(spot::acc_cond& acc, ...@@ -2198,7 +2198,7 @@ fix_acceptance_aux(spot::acc_cond& acc,
{ {
auto m = in[pos - 1].mark; auto m = in[pos - 1].mark;
auto c = acc.inf(onlyneg & m); auto c = acc.inf(onlyneg & m);
spot::acc_cond::mark_t tmp = 0U; spot::acc_cond::mark_t tmp = {};
for (auto i: both.sets()) for (auto i: both.sets())
{ {
if (m.has(i)) if (m.has(i))
......
// -*- coding: utf-8 -*- // -*- coding: utf-8 -*-
// Copyright (C) 2014 Laboratoire de Recherche et Developpement de // Copyright (C) 2014, 2018 Laboratoire de Recherche et Developpement de
// l'Epita (LRDE). // l'Epita (LRDE).
// //
// This file is part of Spot, a model checking library. // This file is part of Spot, a model checking library.
...@@ -63,7 +63,7 @@ namespace spot ...@@ -63,7 +63,7 @@ namespace spot
{ {
auto p = map_.find(name); auto p = map_.find(name);
if (p == map_.end()) if (p == map_.end())
return std::make_pair(false, 0U); return std::make_pair(false, acc_cond::mark_t({}));
return std::make_pair(true, acc_cond::mark_t({p->second})); return std::make_pair(true, acc_cond::mark_t({p->second}));
} }
}; };
...@@ -85,7 +85,7 @@ namespace spot ...@@ -85,7 +85,7 @@ namespace spot
if (n < aut_->acc().num_sets()) if (n < aut_->acc().num_sets())
return std::make_pair(true, acc_cond::mark_t({n})); return std::make_pair(true, acc_cond::mark_t({n}));
else else
return std::make_pair(false, 0U); return std::make_pair(false, acc_cond::mark_t({}));
} }
}; };
...@@ -113,7 +113,7 @@ namespace spot ...@@ -113,7 +113,7 @@ namespace spot
map_[n] = res; map_[n] = res;
return std::make_pair(true, res); return std::make_pair(true, res);
} }
return std::make_pair(false, 0U); return std::make_pair(false, acc_cond::mark_t({}));
} }
}; };
} }
...@@ -29,7 +29,7 @@ namespace spot ...@@ -29,7 +29,7 @@ namespace spot
{ {
index = i; index = i;
is_accepting = false; is_accepting = false;
condition = 0U; condition = {};
} }
scc_stack_ta::connected_component& scc_stack_ta::connected_component&
......
...@@ -391,7 +391,7 @@ namespace spot ...@@ -391,7 +391,7 @@ namespace spot
{ {
auto i = auto i =
down_cast<state_ta_explicit*>(get_artificial_initial_state()); down_cast<state_ta_explicit*>(get_artificial_initial_state());
create_transition(i, condition, 0U, s); create_transition(i, condition, {}, s);
} }
} }
......
...@@ -184,7 +184,7 @@ namespace spot ...@@ -184,7 +184,7 @@ namespace spot
//if stuttering transition, the TA automata stays in the same state //if stuttering transition, the TA automata stays in the same state
current_state_ = new state_ta_product(source_->get_ta_state(), current_state_ = new state_ta_product(source_->get_ta_state(),
kripke_current_dest_state->clone()); kripke_current_dest_state->clone());
current_acceptance_conditions_ = 0U; current_acceptance_conditions_ = {};
return true; return true;
} }
......
...@@ -109,7 +109,7 @@ namespace spot ...@@ -109,7 +109,7 @@ namespace spot
} }
scc.push(++num); scc.push(++num);
arc.push(0U); arc.push({});
ta_succ_iterator_product* iter = a_->succ_iter(init); ta_succ_iterator_product* iter = a_->succ_iter(init);
iter->first(); iter->first();
......
...@@ -175,7 +175,7 @@ namespace spot ...@@ -175,7 +175,7 @@ namespace spot
} }
sscc.push(++num); sscc.push(++num);
arc.push(0U); arc.push({});
sscc.top().is_accepting sscc.top().is_accepting
= testing_aut->is_accepting_state(init); = testing_aut->is_accepting_state(init);
twa_succ_iterator* iter = testing_aut->succ_iter(init); twa_succ_iterator* iter = testing_aut->succ_iter(init);
...@@ -407,7 +407,7 @@ namespace spot ...@@ -407,7 +407,7 @@ namespace spot
twa_succ_iterator* it = tgba_->succ_iter(tgba_init_state); twa_succ_iterator* it = tgba_->succ_iter(tgba_init_state);
it->first(); it->first();
if (!it->done()) if (!it->done())
is_acc = it->acc() != 0U; is_acc = !!it->acc();
delete it; delete it;
} }
...@@ -459,7 +459,7 @@ namespace spot ...@@ -459,7 +459,7 @@ namespace spot
twa_succ_iterator* it = tgba_->succ_iter(tgba_state); twa_succ_iterator* it = tgba_->succ_iter(tgba_state);
it->first(); it->first();
if (!it->done()) if (!it->done())
is_acc = it->acc() != 0U; is_acc = !!it->acc();
delete it; delete it;
} }
...@@ -631,7 +631,7 @@ namespace spot ...@@ -631,7 +631,7 @@ namespace spot
if (state->compare(ta->get_artificial_initial_state())) if (state->compare(ta->get_artificial_initial_state()))
ta->create_transition(state, bdd_stutering_transition, ta->create_transition(state, bdd_stutering_transition,
0U, state); {}, state);
state->set_livelock_accepting_state(false); state->set_livelock_accepting_state(false);
state->set_accepting_state(false); state->set_accepting_state(false);
......
...@@ -34,13 +34,13 @@ namespace spot ...@@ -34,13 +34,13 @@ namespace spot
{ {
std::ostream& operator<<(std::ostream& os, spot::acc_cond::mark_t m) std::ostream& operator<<(std::ostream& os, spot::acc_cond::mark_t m)
{ {
auto a = m.id; auto a = m;
os << '{'; os << '{';
unsigned level = 0; unsigned level = 0;
const char* comma = ""; const char* comma = "";
while (a) while (a)
{ {
if (a & 1) if (a.has(0))
{ {
os << comma << level; os << comma << level;
comma = ","; comma = ",";
...@@ -129,8 +129,8 @@ namespace spot ...@@ -129,8 +129,8 @@ namespace spot
SPOT_FALLTHROUGH; SPOT_FALLTHROUGH;
case acc_cond::acc_op::Inf: case acc_cond::acc_op::Inf:
{ {
auto a = code[pos - 1].mark.id; auto a = code[pos - 1].mark;
if (a == 0U) if (!a)
{ {
if (style == LATEX) if (style == LATEX)
os << "\\mathsf{t}"; os << "\\mathsf{t}";
...@@ -164,7 +164,7 @@ namespace spot ...@@ -164,7 +164,7 @@ namespace spot
const char* inf_ = (style == LATEX) ? "\\mathsf{Inf}(" : "Inf("; const char* inf_ = (style == LATEX) ? "\\mathsf{Inf}(" : "Inf(";
while (a) while (a)
{ {
if (a & 1) if (a.has(0))
{ {
os << and_ << inf_ << negated_pre; os << and_ << inf_ << negated_pre;
set_printer(os, level); set_printer(os, level);
...@@ -184,8 +184,8 @@ namespace spot ...@@ -184,8 +184,8 @@ namespace spot
SPOT_FALLTHROUGH; SPOT_FALLTHROUGH;
case acc_cond::acc_op::Fin: case acc_cond::acc_op::Fin:
{ {
auto a = code[pos - 1].mark.id; auto a = code[pos - 1].mark;
if (a == 0U) if (!a)
{ {
if (style == LATEX) if (style == LATEX)
os << "\\mathsf{f}"; os << "\\mathsf{f}";
...@@ -204,7 +204,7 @@ namespace spot ...@@ -204,7 +204,7 @@ namespace spot
const char* fin_ = (style == LATEX) ? "\\mathsf{Fin}(" : "Fin("; const char* fin_ = (style == LATEX) ? "\\mathsf{Fin}(" : "Fin(";
while (a) while (a)
{ {
if (a & 1) if (a.has(0))
{ {
os << or_ << fin_ << negated_pre; os << or_ << fin_ << negated_pre;
set_printer(os, level); set_printer(os, level);
...@@ -330,14 +330,14 @@ namespace spot ...@@ -330,14 +330,14 @@ namespace spot
case acc_cond::acc_op::And: case acc_cond::acc_op::And:
{ {
auto sub = pos - pos->sub.size; auto sub = pos - pos->sub.size;
acc_cond::mark_t m = 0U; acc_cond::mark_t m = {};
while (sub < pos) while (sub < pos)
{ {
--pos; --pos;
if (auto s = eval_sets(inf, pos)) if (auto s = eval_sets(inf, pos))
m |= s; m |= s;
else else
return 0U; return {};
pos -= pos->sub.size; pos -= pos->sub.size;
} }
return m; return m;
...@@ -352,20 +352,20 @@ namespace spot ...@@ -352,20 +352,20 @@ namespace spot
return s; return s;
pos -= pos->sub.size; pos -= pos->sub.size;
} }
return 0U; return {};
} }
case acc_cond::acc_op::Inf: case acc_cond::acc_op::Inf:
if ((pos[-1].mark & inf) == pos[-1].mark) if ((pos[-1].mark & inf) == pos[-1].mark)
return pos[-1].mark; return pos[-1].mark;
else else
return 0U; return {};
case acc_cond::acc_op::Fin: case acc_cond::acc_op::Fin:
case acc_cond::acc_op::FinNeg: case acc_cond::acc_op::FinNeg:
case acc_cond::acc_op::InfNeg: case acc_cond::acc_op::InfNeg:
SPOT_UNREACHABLE(); SPOT_UNREACHABLE();
} }
SPOT_UNREACHABLE(); SPOT_UNREACHABLE();
return 0U; return {};
} }
} }
...@@ -387,7 +387,7 @@ namespace spot ...@@ -387,7 +387,7 @@ namespace spot
bool acc_cond::acc_code::inf_satisfiable(mark_t inf) const bool acc_cond::acc_code::inf_satisfiable(mark_t inf) const
{ {
return !maybe_accepting(inf, 0U).is_false(); return !maybe_accepting(inf, {}).is_false();
} }
...@@ -397,7 +397,7 @@ namespace spot ...@@ -397,7 +397,7 @@ namespace spot
throw std::runtime_error throw std::runtime_error
("Fin acceptance is not supported by this code path."); ("Fin acceptance is not supported by this code path.");
if (code_.empty()) if (code_.empty())
return 0U; return {};
return eval_sets(inf, &code_.back()); return eval_sets(inf, &code_.back());
} }
...@@ -419,7 +419,7 @@ namespace spot ...@@ -419,7 +419,7 @@ namespace spot
pos -= 2; pos -= 2;
break; break;
case acc_cond::acc_op::Fin: case acc_cond::acc_op::Fin:
if (code_[pos - 2].mark == 0U) // f if (!code_[pos - 2].mark) // f
{ {
pos -= 2; pos -= 2;
break; break;
...@@ -458,8 +458,8 @@ namespace spot ...@@ -458,8 +458,8 @@ namespace spot
// Pretend we were in a unary highop. // Pretend we were in a unary highop.
s = 5; s = 5;
} }
acc_cond::mark_t seen_fin = 0U; acc_cond::mark_t seen_fin = {};
acc_cond::mark_t seen_inf = 0U; acc_cond::mark_t seen_inf = {};
while (s) while (s)
{ {
if (code[--s].sub.op != lowop) if (code[--s].sub.op != lowop)
...@@ -481,7 +481,7 @@ namespace spot ...@@ -481,7 +481,7 @@ namespace spot
if (o1 != acc_cond::acc_op::Fin if (o1 != acc_cond::acc_op::Fin
|| o2 != acc_cond::acc_op::Inf || o2 != acc_cond::acc_op::Inf
|| m1.count() != 1