clone.cc 1.24 KB
Newer Older
1
2
3
#include "ltlast/allnodes.hh"
#include "clone.hh"

4
namespace spot
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
  namespace ltl
  {
    clone_visitor::clone_visitor()
    {
    }

    clone_visitor::~clone_visitor()
    {
    }

    formula*
    clone_visitor::result() const
    {
      return result_;
    }
21
22
23

    void
    clone_visitor::visit(atomic_prop* ap)
24
    {
25
      result_ = ap->ref();
26
27
    }

28
29
    void
    clone_visitor::visit(constant* c)
30
    {
31
      result_ = c->ref();
32
33
    }

34
35
    void
    clone_visitor::visit(unop* uo)
36
    {
37
      result_ = unop::instance(uo->op(), recurse(uo->child()));
38
    }
39
40
41

    void
    clone_visitor::visit(binop* bo)
42
    {
43
44
      result_ = binop::instance(bo->op(),
				recurse(bo->first()), recurse(bo->second()));
45
    }
46
47
48

    void
    clone_visitor::visit(multop* mo)
49
    {
50
      multop* res = multop::instance(mo->op());
51
52
53
      unsigned mos = mo->size();
      for (unsigned i = 0; i < mos; ++i)
	{
54
	  multop::add(&res, recurse(mo->nth(i)));
55
56
57
58
	}
      result_ = res;
    }

59
60
    formula*
    clone_visitor::recurse(formula* f)
61
62
63
64
    {
      return clone(f);
    }

65
66
    formula*
    clone(formula* f)
67
68
69
70
71
72
    {
      clone_visitor v;
      f->accept(v);
      return v.result();
    }

73
74
75
76
77
    formula*
    clone(const formula* f)
    {
      return clone(const_cast<formula*>(f));
    }
78
79
  }
}