clone.cc 2.3 KB
Newer Older
1
// -*- coding: utf-8 -*-
2
// Copyright (C) 2009, 2010, 2012, 2013, 2014 Laboratoire de Recherche et
3
// Développement de l'Epita (LRDE).
Guillaume Sadegh's avatar
Guillaume Sadegh committed
4
// Copyright (C) 2003 Laboratoire d'Informatique de Paris 6 (LIP6),
5
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
6
7
8
9
10
11
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
12
// the Free Software Foundation; either version 3 of the License, or
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
13
14
15
16
17
18
19
20
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
21
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
22

23
#include "ltlast/allnodes.hh"
24
25
#include "clone.hh"

26
namespace spot
27
28
29
30
31
32
33
34
35
36
37
{
  namespace ltl
  {
    clone_visitor::clone_visitor()
    {
    }

    clone_visitor::~clone_visitor()
    {
    }

38
    const formula*
39
40
41
42
    clone_visitor::result() const
    {
      return result_;
    }
43
44

    void
45
    clone_visitor::visit(const atomic_prop* ap)
46
    {
47
      result_ = ap->clone();
48
49
    }

50
    void
51
    clone_visitor::visit(const constant* c)
52
    {
53
      result_ = c->clone();
54
55
    }

56
    void
57
    clone_visitor::visit(const bunop* bo)
58
59
60
61
62
    {
      result_ = bunop::instance(bo->op(), recurse(bo->child()),
				bo->min(), bo->max());
    }

63
    void
64
    clone_visitor::visit(const unop* uo)
65
    {
66
      result_ = unop::instance(uo->op(), recurse(uo->child()));
67
    }
68
69

    void
70
    clone_visitor::visit(const binop* bo)
71
    {
72
      const formula* first = recurse(bo->first());
73
      result_ = binop::instance(bo->op(),
74
				first, recurse(bo->second()));
75
    }
76
77

    void
78
    clone_visitor::visit(const multop* mo)
79
    {
80
      multop::vec* res = new multop::vec;
81
      unsigned mos = mo->size();
82
      res->reserve(mos);
83
      for (unsigned i = 0; i < mos; ++i)
84
85
	res->push_back(recurse(mo->nth(i)));
      result_ = multop::instance(mo->op(), res);
86
87
    }

88
89
    const formula*
    clone_visitor::recurse(const formula* f)
90
    {
91
92
      f->accept(*this);
      return result_;
93
94
95
    }
  }
}