mCRL2
Loading...
Searching...
No Matches
rewrite.h
Go to the documentation of this file.
1// Author(s): Wieger Wesselink
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
11
12#ifndef MCRL2_DATA_REWRITE_H
13#define MCRL2_DATA_REWRITE_H
14
15#include "mcrl2/data/builder.h"
16
17namespace mcrl2 {
18
19namespace data {
20
21namespace detail
22{
23
24template <template <class> class Builder, class Rewriter>
25struct rewrite_data_expressions_builder: public Builder<rewrite_data_expressions_builder<Builder, Rewriter> >
26{
27 typedef Builder<rewrite_data_expressions_builder<Builder, Rewriter> > super;
28 using super::enter;
29 using super::leave;
30 using super::apply;
31 using super::update;
32
34
36 : R(R_)
37 {}
38
39 template <class T>
40 void apply(T& result, const data_expression& x)
41 {
42 result = R(x);
43 }
44};
45
46template <template <class> class Builder, class Rewriter>
47rewrite_data_expressions_builder<Builder, Rewriter>
49{
51}
52
53template <template <class> class Builder, class Rewriter, class Substitution>
54struct rewrite_data_expressions_with_substitution_builder: public Builder<rewrite_data_expressions_with_substitution_builder<Builder, Rewriter, Substitution> >
55{
56 typedef Builder<rewrite_data_expressions_with_substitution_builder<Builder, Rewriter, Substitution> > super;
57 using super::enter;
58 using super::leave;
59 using super::apply;
60 using super::update;
61
63 Substitution sigma;
64
66 : R(R_),
67 sigma(sigma_)
68 {}
69
70 template <class T>
71 void apply(T& result, const data_expression& x)
72 {
73 result = R(x, sigma);
74 }
75};
76
77template <template <class> class Builder, class Rewriter, class Substitution>
78rewrite_data_expressions_with_substitution_builder<Builder, Rewriter, Substitution>
80{
82}
83
84} // namespace detail
85
86//--- start generated data rewrite code ---//
90template <typename T, typename Rewriter>
91void rewrite(T& x,
92 Rewriter R,
93 typename std::enable_if<!std::is_base_of<atermpp::aterm, T>::value>::type* = nullptr
94 )
95{
96 data::detail::make_rewrite_data_expressions_builder<data::data_expression_builder>(R).update(x);
97}
98
103template <typename T, typename Rewriter>
104T rewrite(const T& x,
105 Rewriter R,
106 typename std::enable_if<std::is_base_of<atermpp::aterm, T>::value>::type* = nullptr
107 )
108{
109 T result;
110 data::detail::make_rewrite_data_expressions_builder<data::data_expression_builder>(R).apply(result, x);
111 return result;
112}
113
118template <typename T, typename Rewriter, typename Substitution>
119void rewrite(T& x,
120 Rewriter R,
121 const Substitution& sigma,
122 typename std::enable_if<!std::is_base_of<atermpp::aterm, T>::value>::type* = nullptr
123 )
124{
125 data::detail::make_rewrite_data_expressions_with_substitution_builder<data::data_expression_builder>(R, sigma).update(x);
126}
127
133template <typename T, typename Rewriter, typename Substitution>
134T rewrite(const T& x,
135 Rewriter R,
136 const Substitution& sigma,
137 typename std::enable_if<std::is_base_of<atermpp::aterm, T>::value>::type* = nullptr
138 )
139{
140 T result;
141 data::detail::make_rewrite_data_expressions_with_substitution_builder<data::data_expression_builder>(R, sigma).apply(result, x);
142 return result;
143}
144//--- end generated data rewrite code ---//
145
146} // namespace data
147
148} // namespace mcrl2
149
150#endif // MCRL2_DATA_REWRITE_H
Rewriter interface class.
Definition rewrite.h:42
add your file description here.
static RewriterCompilingJitty::substitution_type & sigma(RewriterCompilingJitty *this_rewriter)
rewrite_data_expressions_with_substitution_builder< Builder, Rewriter, Substitution > make_rewrite_data_expressions_with_substitution_builder(Rewriter R, Substitution sigma)
Definition rewrite.h:79
rewrite_data_expressions_builder< Builder, Rewriter > make_rewrite_data_expressions_builder(Rewriter R)
Definition rewrite.h:48
void rewrite(T &x, Rewriter R, typename std::enable_if<!std::is_base_of< atermpp::aterm, T >::value >::type *=nullptr)
Definition rewrite.h:91
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
Builder< rewrite_data_expressions_builder< Builder, Rewriter > > super
Definition rewrite.h:27
void apply(T &result, const data_expression &x)
Definition rewrite.h:40
Builder< rewrite_data_expressions_with_substitution_builder< Builder, Rewriter, Substitution > > super
Definition rewrite.h:56
rewrite_data_expressions_with_substitution_builder(Rewriter R_, Substitution sigma_)
Definition rewrite.h:65