mCRL2
Loading...
Searching...
No Matches
assignment.h
Go to the documentation of this file.
1// Author(s): Jeroen Keiren
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_ASSIGNMENT_H
13#define MCRL2_DATA_ASSIGNMENT_H
14
17
18namespace mcrl2
19{
20
21namespace data
22{
23
24//--- start generated classes ---//
27{
28 public:
31 : atermpp::aterm_appl(core::detail::default_values::WhrDecl)
32 {}
33
37 : atermpp::aterm_appl(term)
38 {
40 }
41
43 assignment_expression(const assignment_expression&) noexcept = default;
45 assignment_expression& operator=(const assignment_expression&) noexcept = default;
46 assignment_expression& operator=(assignment_expression&&) noexcept = default;
47};
48
51
54
55// prototypes
56inline bool is_assignment(const atermpp::aterm_appl& x);
57inline bool is_untyped_identifier_assignment(const atermpp::aterm_appl& x);
58
62inline
63bool is_assignment_expression(const atermpp::aterm_appl& x)
64{
65 return data::is_assignment(x) ||
67}
68
69// prototype declaration
70std::string pp(const assignment_expression& x);
71
76inline
77std::ostream& operator<<(std::ostream& out, const assignment_expression& x)
78{
79 return out << data::pp(x);
80}
81
84{
85 t1.swap(t2);
86}
87
88
91{
92 public:
95 : assignment_expression(core::detail::default_values::DataVarIdInit)
96 {}
97
100 explicit assignment(const atermpp::aterm& term)
102 {
103 assert(core::detail::check_term_DataVarIdInit(*this));
104 }
105
107 assignment(const variable& lhs, const data_expression& rhs)
108 : assignment_expression(atermpp::aterm_appl(core::detail::function_symbol_DataVarIdInit(), lhs, rhs))
109 {}
110
112 assignment(const assignment&) noexcept = default;
113 assignment(assignment&&) noexcept = default;
114 assignment& operator=(const assignment&) noexcept = default;
115 assignment& operator=(assignment&&) noexcept = default;
116
117 const variable& lhs() const
118 {
119 return atermpp::down_cast<variable>((*this)[0]);
120 }
121
122 const data_expression& rhs() const
123 {
124 return atermpp::down_cast<data_expression>((*this)[1]);
125 }
126//--- start user section assignment ---//
130 const data_expression& operator()(const variable& x) const
131 {
132 return x == lhs() ? rhs() : x;
133 }
134//--- end user section assignment ---//
135};
136
139template <class... ARGUMENTS>
140inline void make_assignment(atermpp::aterm_appl& t, const ARGUMENTS&... args)
141{
143}
144
147
149typedef std::vector<assignment> assignment_vector;
150
154inline
156{
158}
159
160// prototype declaration
161std::string pp(const assignment& x);
162
167inline
168std::ostream& operator<<(std::ostream& out, const assignment& x)
169{
170 return out << data::pp(x);
171}
172
174inline void swap(assignment& t1, assignment& t2)
175{
176 t1.swap(t2);
177}
178
179
182{
183 public:
186 : assignment_expression(core::detail::default_values::UntypedIdentifierAssignment)
187 {}
188
193 {
194 assert(core::detail::check_term_UntypedIdentifierAssignment(*this));
195 }
196
199 : assignment_expression(atermpp::aterm_appl(core::detail::function_symbol_UntypedIdentifierAssignment(), lhs, rhs))
200 {}
201
203 untyped_identifier_assignment(const std::string& lhs, const data_expression& rhs)
204 : assignment_expression(atermpp::aterm_appl(core::detail::function_symbol_UntypedIdentifierAssignment(), core::identifier_string(lhs), rhs))
205 {}
206
212
213 const core::identifier_string& lhs() const
214 {
215 return atermpp::down_cast<core::identifier_string>((*this)[0]);
216 }
217
218 const data_expression& rhs() const
219 {
220 return atermpp::down_cast<data_expression>((*this)[1]);
221 }
222//--- start user section untyped_identifier_assignment ---//
227 {
228 return x == lhs() ? rhs() : data_expression(x);
229 }
230//--- end user section untyped_identifier_assignment ---//
231};
232
235template <class... ARGUMENTS>
236inline void make_untyped_identifier_assignment(atermpp::aterm_appl& t, const ARGUMENTS&... args)
237{
239}
240
243
245typedef std::vector<untyped_identifier_assignment> untyped_identifier_assignment_vector;
246
250inline
252{
254}
255
256// prototype declaration
257std::string pp(const untyped_identifier_assignment& x);
258
263inline
264std::ostream& operator<<(std::ostream& out, const untyped_identifier_assignment& x)
265{
266 return out << data::pp(x);
267}
268
271{
272 t1.swap(t2);
273}
274//--- end generated classes ---//
275
280template < typename VariableSequence, typename ExpressionSequence >
281assignment_vector make_assignment_vector(VariableSequence const& variables, ExpressionSequence const& expressions)
282{
283 std::vector<assignment> result;
284 typename ExpressionSequence::const_iterator j=expressions.begin();
285 for(typename VariableSequence::const_iterator i=variables.begin(); i!=variables.end(); ++i, ++j)
286 {
287 assert(j!=expressions.end());
288 result.push_back(assignment(*i,*j));
289 }
290 assert(j==expressions.end());
291 return result;
292}
293
300template < typename VariableSequence, typename ExpressionSequence >
301assignment_list make_assignment_list(const VariableSequence& variables, const ExpressionSequence& expressions)
302{
303 std::vector<assignment> result(make_assignment_vector(variables,expressions));
304 return assignment_list(result.begin(),result.end());
305}
306
309inline
311{
312 return variable_list(x.begin(), x.end(), [](const assignment& a) { return a.lhs(); });
313}
314
317inline
319{
320 return data_expression_list(x.begin(), x.end(), [](const assignment& a) { return a.rhs(); });
321}
322
323// template function overloads
324std::string pp(const assignment_list& x);
325std::string pp(const assignment_vector& x);
326
327} // namespace data
328
329} // namespace mcrl2
330
331#endif // MCRL2_DATA_ASSIGNMENT_H
332
Term containing a string.
The aterm base class that provides protection of the underlying shared terms.
Definition aterm.h:186
const function_symbol & function() const
Returns the function symbol belonging to an aterm_appl.
Definition aterm_appl.h:174
A list of aterm objects.
Definition aterm_list.h:23
const_iterator end() const
Returns a const_iterator pointing to the end of the term_list.
Definition aterm_list.h:281
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the term_list.
Definition aterm_list.h:274
void swap(unprotected_aterm &t) noexcept
Swaps this term with its argument.
Definition aterm.h:156
\brief Assignment expression
Definition assignment.h:27
assignment_expression(assignment_expression &&) noexcept=default
assignment_expression()
\brief Default constructor.
Definition assignment.h:30
assignment_expression(const assignment_expression &) noexcept=default
Move semantics.
assignment_expression(const atermpp::aterm &term)
Definition assignment.h:36
\brief Assignment of a data expression to a variable
Definition assignment.h:91
assignment(const variable &lhs, const data_expression &rhs)
\brief Constructor.
Definition assignment.h:107
const data_expression & rhs() const
Definition assignment.h:122
assignment(const atermpp::aterm &term)
Definition assignment.h:100
assignment(assignment &&) noexcept=default
assignment(const assignment &) noexcept=default
Move semantics.
assignment()
\brief Default constructor.
Definition assignment.h:94
const data_expression & operator()(const variable &x) const
Applies the assignment to a variable.
Definition assignment.h:130
\brief Assignment of a data expression to a string
Definition assignment.h:182
untyped_identifier_assignment(const std::string &lhs, const data_expression &rhs)
\brief Constructor.
Definition assignment.h:203
untyped_identifier_assignment(const atermpp::aterm &term)
Definition assignment.h:191
untyped_identifier_assignment()
\brief Default constructor.
Definition assignment.h:185
const data_expression & rhs() const
Definition assignment.h:218
untyped_identifier_assignment(const core::identifier_string &lhs, const data_expression &rhs)
\brief Constructor.
Definition assignment.h:198
untyped_identifier_assignment(untyped_identifier_assignment &&) noexcept=default
untyped_identifier_assignment(const untyped_identifier_assignment &) noexcept=default
Move semantics.
data_expression operator()(const untyped_identifier &x) const
Applies the assignment to a variable.
Definition assignment.h:226
\brief An untyped identifier
\brief A data variable
Definition variable.h:28
The main namespace for the aterm++ library.
Definition algorithm.h:21
void make_term_appl(Term &target, const function_symbol &sym, ForwardIterator begin, ForwardIterator end)
Constructor an aterm_appl in a variable based on a function symbol and an forward iterator providing ...
Definition aterm_appl.h:239
bool check_rule_WhrDecl(const Term &t)
const atermpp::function_symbol & function_symbol_UntypedIdentifierAssignment()
const atermpp::function_symbol & function_symbol_DataVarIdInit()
std::vector< assignment > assignment_vector
\brief vector of assignments
Definition assignment.h:149
bool is_assignment_expression(const atermpp::aterm_appl &x)
Definition assignment.h:63
void swap(abstraction &t1, abstraction &t2)
\brief swap overload
bool is_untyped_identifier_assignment(const atermpp::aterm_appl &x)
Definition assignment.h:251
void make_assignment(atermpp::aterm_appl &t, const ARGUMENTS &... args)
Definition assignment.h:140
std::vector< untyped_identifier_assignment > untyped_identifier_assignment_vector
\brief vector of untyped_identifier_assignments
Definition assignment.h:245
std::string pp(const abstraction &x)
Definition data.cpp:39
void make_untyped_identifier_assignment(atermpp::aterm_appl &t, const ARGUMENTS &... args)
Definition assignment.h:236
variable_list left_hand_sides(const assignment_list &x)
Returns the left hand sides of an assignment list.
Definition assignment.h:310
atermpp::term_list< data_expression > data_expression_list
\brief list of data_expressions
std::vector< assignment_expression > assignment_expression_vector
\brief vector of assignment_expressions
Definition assignment.h:53
atermpp::term_list< variable > variable_list
\brief list of variables
assignment_vector make_assignment_vector(VariableSequence const &variables, ExpressionSequence const &expressions)
Constructs an assignment_list by pairwise combining a variable and expression.
Definition assignment.h:281
atermpp::term_list< assignment > assignment_list
\brief list of assignments
Definition assignment.h:146
data_expression_list right_hand_sides(const assignment_list &x)
Returns the right hand sides of an assignment list.
Definition assignment.h:318
assignment_list make_assignment_list(const VariableSequence &variables, const ExpressionSequence &expressions)
Converts an iterator range to data_expression_list.
Definition assignment.h:301
atermpp::term_list< untyped_identifier_assignment > untyped_identifier_assignment_list
\brief list of untyped_identifier_assignments
Definition assignment.h:242
bool is_assignment(const atermpp::aterm_appl &x)
Definition assignment.h:155
std::ostream & operator<<(std::ostream &out, const abstraction &x)
Definition abstraction.h:94
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
STL namespace.
static const atermpp::function_symbol DataVarIdInit
static const atermpp::function_symbol UntypedIdentifierAssignment
add your file description here.
add your file description here.