mCRL2
Loading...
Searching...
No Matches
data_rewriter.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_REWRITERS_DATA_REWRITER_H
13#define MCRL2_DATA_REWRITERS_DATA_REWRITER_H
14
15#include "mcrl2/data/builder.h"
17
18namespace mcrl2 {
19
20namespace data {
21
22namespace detail {
23
24template <typename DataRewriter, typename SubstitutionFunction>
25data::data_expression data_rewrite(const data::data_expression& x, const DataRewriter& R, SubstitutionFunction& sigma)
26{
27 mCRL2log(log::trace) << "data_rewrite " << x << sigma << " -> " << R(x, sigma) << std::endl;
28 return R(x, sigma);
29}
30
31template <typename DataRewriter>
33{
34 mCRL2log(log::trace) << "data_rewrite " << x << "[]" << " -> " << R(x) << std::endl;
35 return R(x);
36}
37
39template <template <class> class Builder, class Derived, class DataRewriter, class SubstitutionFunction = data::no_substitution>
40struct add_data_rewriter: public Builder<Derived>
41{
42 typedef Builder<Derived> super;
43 using super::enter;
44 using super::leave;
45 using super::operator();
46
47 const DataRewriter& R;
48 SubstitutionFunction& sigma;
49
50 add_data_rewriter(const DataRewriter& R_, SubstitutionFunction& sigma_)
51 : R(R_), sigma(sigma_)
52 {}
53
55 {
56 return data_rewrite(x, R, sigma);
57 }
58
59 template <class T>
60 void apply(T& result, const data::data_expression& x)
61 {
62 result = data_rewrite(x, R, sigma);
63 }
64
65};
66
67template <typename Derived, typename DataRewriter, typename SubstitutionFunction>
68struct data_rewriter_builder: public add_data_rewriter<data::data_expression_builder, Derived, DataRewriter, SubstitutionFunction>
69{
71 using super::enter;
72 using super::leave;
73 using super::operator();
74
75 data_rewriter_builder(const DataRewriter& R, SubstitutionFunction& sigma)
76 : super(R, sigma)
77 {}
78};
79
80template <template <class, class, class> class Builder, class DataRewriter, class SubstitutionFunction>
81struct apply_rewriter_builder: public Builder<apply_rewriter_builder<Builder, DataRewriter, SubstitutionFunction>, DataRewriter, SubstitutionFunction>
82{
83 typedef Builder<apply_rewriter_builder<Builder, DataRewriter, SubstitutionFunction>, DataRewriter, SubstitutionFunction> super;
84 using super::enter;
85 using super::leave;
86 using super::operator();
87
88 apply_rewriter_builder(const DataRewriter& datar, SubstitutionFunction& sigma)
89 : super(datar, sigma)
90 {}
91
92#ifdef BOOST_MSVC
94#endif
95};
96
97template <template <class, class, class> class Builder, class DataRewriter, class SubstitutionFunction>
98apply_rewriter_builder<Builder, DataRewriter, SubstitutionFunction>
99make_apply_rewriter_builder(const DataRewriter& datar, SubstitutionFunction& sigma)
100{
102}
103
104} // namespace detail
105
107template <typename DataRewriter>
109{
112
113 const DataRewriter& R;
114
115 data_rewriter(const DataRewriter& R_)
116 : R(R_)
117 {}
118
120 {
122 return detail::make_apply_rewriter_builder<detail::data_rewriter_builder>(R, sigma)(x);
123 }
124
125 template <typename SubstitutionFunction>
126 data_expression operator()(const data_expression& x, SubstitutionFunction& sigma) const
127 {
128 return detail::make_apply_rewriter_builder<detail::data_rewriter_builder>(R, sigma)(x);
129 }
130};
131
132} // namespace data
133
134} // namespace mcrl2
135
136#endif // MCRL2_DATA_REWRITERS_DATA_REWRITER_H
137
\brief A data variable
Definition variable.h:28
add your file description here.
static RewriterCompilingJitty::substitution_type & sigma(RewriterCompilingJitty *this_rewriter)
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:391
apply_rewriter_builder< Builder, DataRewriter, SubstitutionFunction > make_apply_rewriter_builder(const DataRewriter &datar, SubstitutionFunction &sigma)
data::data_expression data_rewrite(const data::data_expression &x, const DataRewriter &R, SubstitutionFunction &sigma)
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
add your file description here.
A rewriter that applies a data rewriter to data expressions in a term.
data_rewriter(const DataRewriter &R_)
data_expression operator()(const data_expression &x, SubstitutionFunction &sigma) const
const DataRewriter & R
data_expression operator()(const data_expression &x) const
Applies a data rewriter to data expressions appearing in a term. It works both with and without a sub...
data_expression operator()(const data::data_expression &x)
add_data_rewriter(const DataRewriter &R_, SubstitutionFunction &sigma_)
void apply(T &result, const data::data_expression &x)
apply_rewriter_builder(const DataRewriter &datar, SubstitutionFunction &sigma)
Builder< apply_rewriter_builder< Builder, DataRewriter, SubstitutionFunction >, DataRewriter, SubstitutionFunction > super
data_rewriter_builder(const DataRewriter &R, SubstitutionFunction &sigma)
add_data_rewriter< data::data_expression_builder, Derived, DataRewriter, SubstitutionFunction > super
An empty struct that is used to denote the absence of a substitution. Used for rewriters.