tgbabddtranslatefactory.cc 2.4 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "tgbabddtranslatefactory.hh"
#include "dictunion.hh"

namespace spot
{
  tgba_bdd_translate_factory::tgba_bdd_translate_factory
  (const tgba_bdd_concrete& from, const tgba_bdd_dict& to)
    : dict_(to)
  {
    bddPair* rewrite = compute_pairs(from.get_dict());

    const tgba_bdd_core_data& in = from.get_core_data();

    data_.relation = bdd_replace(in.relation, rewrite);
    data_.now_set = bdd_replace(in.now_set, rewrite);
    data_.negnow_set = bdd_replace(in.negnow_set, rewrite);
    data_.notnow_set = bdd_replace(in.notnow_set, rewrite);
    data_.notvar_set = bdd_replace(in.notvar_set, rewrite);
    data_.notprom_set = bdd_replace(in.notprom_set, rewrite);

21
    init_ = bdd_replace(from.get_init_bdd(), rewrite);
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

    bdd_freepair(rewrite);
  }

  tgba_bdd_translate_factory::~tgba_bdd_translate_factory()
  {
  }

  bddPair*
  tgba_bdd_translate_factory::compute_pairs(const tgba_bdd_dict& from)
  {
    bddPair* rewrite = bdd_newpair();

    tgba_bdd_dict::fv_map::const_iterator i_from;
    tgba_bdd_dict::fv_map::const_iterator i_to;

    for (i_from = from.now_map.begin(); i_from != from.now_map.end(); ++i_from)
      {
	i_to = dict_.now_map.find(i_from->first);
	assert(i_to != dict_.now_map.end());

	bdd_setpair(rewrite, i_from->second, i_to->second);
	bdd_setpair(rewrite, i_from->second + 1, i_to->second + 1);
	bdd_setpair(data_.next_to_now, i_to->second + 1, i_to->second);
      }
    for (i_from = from.var_map.begin(); i_from != from.var_map.end(); ++i_from)
      {
	i_to = dict_.var_map.find(i_from->first);
	assert(i_to != dict_.var_map.end());
	bdd_setpair(rewrite, i_from->second, i_to->second);
      }
    for (i_from = from.prom_map.begin();
	 i_from != from.prom_map.end();
	 ++i_from)
      {
	i_to = dict_.prom_map.find(i_from->first);
	assert(i_to != dict_.prom_map.end());
	bdd_setpair(rewrite, i_from->second, i_to->second);
      }
    return rewrite;
  }

  const tgba_bdd_core_data&
  tgba_bdd_translate_factory::get_core_data() const
  {
    return data_;
  }

  const tgba_bdd_dict&
  tgba_bdd_translate_factory::get_dict() const
  {
    return dict_;
  }

  bdd
  tgba_bdd_translate_factory::get_init_state() const
  {
    return init_;
  }


  tgba_bdd_concrete
  defrag(const tgba_bdd_concrete& a)
  {
    const tgba_bdd_dict& ad = a.get_dict();
    tgba_bdd_dict u = tgba_bdd_dict_union(ad, ad);
    tgba_bdd_translate_factory f(a, u);
    return tgba_bdd_concrete(f, f.get_init_state());
  }
}