forked from SRI-CSL/sally
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathterm_ops.h
More file actions
262 lines (227 loc) · 4.89 KB
/
Copy pathterm_ops.h
File metadata and controls
262 lines (227 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
/**
* This file is part of sally.
* Copyright (C) 2015 SRI International.
*
* Sally is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Sally 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
* along with sally. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <iosfwd>
#include "expr/rational.h"
#include "expr/bitvector.h"
#include "utils/allocator_types.h"
#include "utils/string.h"
namespace sally {
namespace expr {
/**
* Enumeration of all term kinds. For each term kind, there is an associated
* term_op_traits instantiation that defines the content of the specific kind
* of term.
*/
enum term_op {
// Types
TYPE_TYPE, // Type of types
TYPE_BOOL,
TYPE_INTEGER,
TYPE_REAL,
TYPE_STRING,
TYPE_BITVECTOR,
TYPE_STRUCT,
TYPE_TUPLE,
TYPE_ENUM,
TYPE_RECORD,
TYPE_FUNCTION,
TYPE_ARRAY,
TYPE_PREDICATE_SUBTYPE,
// Variables
VARIABLE,
// ITE
TERM_ITE,
// Equality
TERM_EQ,
// Boolean terms
CONST_BOOL,
TERM_AND,
TERM_OR,
TERM_NOT,
TERM_IMPLIES,
TERM_XOR,
// Arithmetic terms
CONST_RATIONAL,
TERM_ADD,
TERM_SUB,
TERM_MUL,
TERM_DIV,
TERM_MOD,
TERM_LEQ,
TERM_LT,
TERM_GEQ,
TERM_GT,
TERM_TO_INT,
TERM_TO_REAL,
TERM_IS_INT,
// Bit-vector terms
CONST_BITVECTOR,
TERM_BV_ADD,
TERM_BV_SUB,
TERM_BV_MUL,
TERM_BV_UDIV, // NOTE: semantics of division is x/0 = 111...111
TERM_BV_SDIV,
TERM_BV_UREM,
TERM_BV_SREM,
TERM_BV_SMOD,
TERM_BV_XOR,
TERM_BV_SHL,
TERM_BV_LSHR,
TERM_BV_ASHR,
TERM_BV_NOT,
TERM_BV_AND,
TERM_BV_OR,
TERM_BV_NAND,
TERM_BV_NOR,
TERM_BV_XNOR,
TERM_BV_CONCAT,
TERM_BV_EXTRACT,
TERM_BV_ULEQ,
TERM_BV_SLEQ,
TERM_BV_ULT,
TERM_BV_SLT,
TERM_BV_UGEQ,
TERM_BV_SGEQ,
TERM_BV_UGT,
TERM_BV_SGT,
TERM_BV_SGN_EXTEND,
TERM_BV_NEG,
TERM_BV_EXTEND,
TERM_BV_ROR,
TERM_BV_ROL,
// Arrays
TERM_ARRAY_READ,
TERM_ARRAY_WRITE,
TERM_ARRAY_LAMBDA,
// Tuples
TERM_TUPLE_CONSTRUCT,
TERM_TUPLE_READ,
TERM_TUPLE_WRITE,
// Enum constants
CONST_ENUM,
// Records
TERM_RECORD_CONSTRUCT,
TERM_RECORD_READ,
TERM_RECORD_WRITE,
// Abstractions
TERM_LAMBDA,
TERM_EXISTS,
TERM_FORALL,
// Function application
TERM_FUN_APP,
// Constant strings
CONST_STRING,
// Marker for the last
OP_LAST
};
/** Output operator */
std::ostream& operator << (std::ostream& out, term_op op);
/**
* The traits class contains an instantiation for each term kind. Any payload
* types need to have an associated utils::hash specialization, copy constructors
* and the operator ==.
*
* If the term has a payload it should define the payload_type to be of that
* type, or otherwise define it to be alloc::empty_type.
*/
template <term_op op>
struct term_op_traits {
/** Default terms have no payload, so we use the alloc::empty type. */
typedef alloc::empty_type payload_type;
};
/**
* Bitvector types have a payload of type size_t > 0.
*/
template<>
struct term_op_traits<TYPE_BITVECTOR> {
typedef size_t payload_type;
};
/**
* Bitvector extract.
*/
template<>
struct term_op_traits<TERM_BV_EXTRACT> {
typedef expr::bitvector_extract payload_type;
};
/**
* Bitvector sign extend.
*/
template<>
struct term_op_traits<TERM_BV_SGN_EXTEND> {
typedef expr::bitvector_sgn_extend payload_type;
};
/**
* Boolean constant terms have a payload of type bool and no children.
*/
template<>
struct term_op_traits<CONST_BOOL> {
typedef bool payload_type;
};
/**
* Rational constants terms have a payload of type rational (gmp) and no children.
*/
template<>
struct term_op_traits<CONST_RATIONAL> {
typedef rational payload_type;
};
/**
* Bitvector constants have a payload of type bitvector.
*/
template<>
struct term_op_traits<CONST_BITVECTOR> {
typedef bitvector payload_type;
};
/**
* Enumeration constants have a payload of type size_t (index).
*/
template<>
struct term_op_traits<CONST_ENUM> {
typedef size_t payload_type;
};
/**
* Variables have a payload that is their name, and one child, which is the
* type of the variable.
*/
template<>
struct term_op_traits<VARIABLE> {
typedef utils::string payload_type;
};
/**
* Tuple access, payload is the index.
*/
template<>
struct term_op_traits<TERM_TUPLE_READ> {
typedef size_t payload_type;
};
/**
* Tuple write, payload is the index.
*/
template<>
struct term_op_traits<TERM_TUPLE_WRITE> {
typedef size_t payload_type;
};
/**
* Strings just have string payloads.
*/
template<>
struct term_op_traits<CONST_STRING> {
typedef utils::string payload_type;
};
}
}