13
13
#include < util/std_code_base.h>
14
14
#include < util/std_expr.h>
15
15
16
- // / A \ref codet representing an assignment in the program.
16
+ using goto_instruction_codet = codet;
17
+
18
+ // / A \ref goto_instruction_codet representing an assignment in the program.
17
19
// / For example, if an expression `e1` is represented as an \ref exprt `expr1`
18
20
// / and an expression `e2` is represented as an \ref exprt `expr2`, the
19
21
// / assignment `e1 = e2;` can be represented as `code_assignt(expr1, expr2)`.
20
- class code_assignt : public codet
22
+ class code_assignt : public goto_instruction_codet
21
23
{
22
24
public:
23
- code_assignt () : codet (ID_assign)
25
+ code_assignt () : goto_instruction_codet (ID_assign)
24
26
{
25
27
operands ().resize (2 );
26
28
}
27
29
28
30
code_assignt (exprt lhs, exprt rhs)
29
- : codet (ID_assign, {std::move (lhs), std::move (rhs)})
31
+ : goto_instruction_codet (ID_assign, {std::move (lhs), std::move (rhs)})
30
32
{
31
33
}
32
34
33
35
code_assignt (exprt lhs, exprt rhs, source_locationt loc)
34
- : codet(ID_assign, {std::move (lhs), std::move (rhs)}, std::move(loc))
36
+ : goto_instruction_codet(
37
+ ID_assign,
38
+ {std::move (lhs), std::move (rhs)},
39
+ std::move (loc))
35
40
{
36
41
}
37
42
@@ -56,15 +61,15 @@ class code_assignt : public codet
56
61
}
57
62
58
63
static void check (
59
- const codet &code,
64
+ const goto_instruction_codet &code,
60
65
const validation_modet vm = validation_modet::INVARIANT)
61
66
{
62
67
DATA_CHECK (
63
68
vm, code.operands ().size () == 2 , " assignment must have two operands" );
64
69
}
65
70
66
71
static void validate (
67
- const codet &code,
72
+ const goto_instruction_codet &code,
68
73
const namespacet &,
69
74
const validation_modet vm = validation_modet::INVARIANT)
70
75
{
@@ -77,7 +82,7 @@ class code_assignt : public codet
77
82
}
78
83
79
84
static void validate_full (
80
- const codet &code,
85
+ const goto_instruction_codet &code,
81
86
const namespacet &ns,
82
87
const validation_modet vm = validation_modet::INVARIANT)
83
88
{
@@ -90,10 +95,10 @@ class code_assignt : public codet
90
95
}
91
96
92
97
protected:
93
- using codet ::op0;
94
- using codet ::op1;
95
- using codet ::op2;
96
- using codet ::op3;
98
+ using goto_instruction_codet ::op0;
99
+ using goto_instruction_codet ::op1;
100
+ using goto_instruction_codet ::op2;
101
+ using goto_instruction_codet ::op3;
97
102
};
98
103
99
104
template <>
@@ -107,26 +112,27 @@ inline void validate_expr(const code_assignt &x)
107
112
code_assignt::check (x);
108
113
}
109
114
110
- inline const code_assignt &to_code_assign (const codet &code)
115
+ inline const code_assignt &to_code_assign (const goto_instruction_codet &code)
111
116
{
112
117
PRECONDITION (code.get_statement () == ID_assign);
113
118
code_assignt::check (code);
114
119
return static_cast <const code_assignt &>(code);
115
120
}
116
121
117
- inline code_assignt &to_code_assign (codet &code)
122
+ inline code_assignt &to_code_assign (goto_instruction_codet &code)
118
123
{
119
124
PRECONDITION (code.get_statement () == ID_assign);
120
125
code_assignt::check (code);
121
126
return static_cast <code_assignt &>(code);
122
127
}
123
128
124
- // / A \ref codet representing the removal of a local variable going out of
125
- // / scope.
126
- class code_deadt : public codet
129
+ // / A \ref goto_instruction_codet representing the removal of
130
+ // / a local variable going out of scope.
131
+ class code_deadt : public goto_instruction_codet
127
132
{
128
133
public:
129
- explicit code_deadt (symbol_exprt symbol) : codet(ID_dead, {std::move (symbol)})
134
+ explicit code_deadt (symbol_exprt symbol)
135
+ : goto_instruction_codet(ID_dead, {std::move (symbol)})
130
136
{
131
137
}
132
138
@@ -146,7 +152,7 @@ class code_deadt : public codet
146
152
}
147
153
148
154
static void check (
149
- const codet &code,
155
+ const goto_instruction_codet &code,
150
156
const validation_modet vm = validation_modet::INVARIANT)
151
157
{
152
158
DATA_CHECK (
@@ -160,10 +166,10 @@ class code_deadt : public codet
160
166
}
161
167
162
168
protected:
163
- using codet ::op0;
164
- using codet ::op1;
165
- using codet ::op2;
166
- using codet ::op3;
169
+ using goto_instruction_codet ::op0;
170
+ using goto_instruction_codet ::op1;
171
+ using goto_instruction_codet ::op2;
172
+ using goto_instruction_codet ::op3;
167
173
};
168
174
169
175
template <>
@@ -177,28 +183,29 @@ inline void validate_expr(const code_deadt &x)
177
183
code_deadt::check (x);
178
184
}
179
185
180
- inline const code_deadt &to_code_dead (const codet &code)
186
+ inline const code_deadt &to_code_dead (const goto_instruction_codet &code)
181
187
{
182
188
PRECONDITION (code.get_statement () == ID_dead);
183
189
code_deadt::check (code);
184
190
return static_cast <const code_deadt &>(code);
185
191
}
186
192
187
- inline code_deadt &to_code_dead (codet &code)
193
+ inline code_deadt &to_code_dead (goto_instruction_codet &code)
188
194
{
189
195
PRECONDITION (code.get_statement () == ID_dead);
190
196
code_deadt::check (code);
191
197
return static_cast <code_deadt &>(code);
192
198
}
193
199
194
- // / A `codet ` representing the declaration of a local variable.
200
+ // / A `goto_instruction_codet ` representing the declaration of a local variable.
195
201
// / For example, if a variable (symbol) `x` is represented as a
196
202
// / \ref symbol_exprt `sym`, then the declaration of this variable can be
197
203
// / represented as `code_declt(sym)`.
198
- class code_declt : public codet
204
+ class code_declt : public goto_instruction_codet
199
205
{
200
206
public:
201
- explicit code_declt (symbol_exprt symbol) : codet(ID_decl, {std::move (symbol)})
207
+ explicit code_declt (symbol_exprt symbol)
208
+ : goto_instruction_codet(ID_decl, {std::move (symbol)})
202
209
{
203
210
}
204
211
@@ -218,7 +225,7 @@ class code_declt : public codet
218
225
}
219
226
220
227
static void check (
221
- const codet &code,
228
+ const goto_instruction_codet &code,
222
229
const validation_modet vm = validation_modet::INVARIANT)
223
230
{
224
231
DATA_CHECK (
@@ -242,30 +249,30 @@ inline void validate_expr(const code_declt &x)
242
249
code_declt::check (x);
243
250
}
244
251
245
- inline const code_declt &to_code_decl (const codet &code)
252
+ inline const code_declt &to_code_decl (const goto_instruction_codet &code)
246
253
{
247
254
PRECONDITION (code.get_statement () == ID_decl);
248
255
code_declt::check (code);
249
256
return static_cast <const code_declt &>(code);
250
257
}
251
258
252
- inline code_declt &to_code_decl (codet &code)
259
+ inline code_declt &to_code_decl (goto_instruction_codet &code)
253
260
{
254
261
PRECONDITION (code.get_statement () == ID_decl);
255
262
code_declt::check (code);
256
263
return static_cast <code_declt &>(code);
257
264
}
258
265
259
- // / \ref codet representation of a function call statement.
266
+ // / \ref goto_instruction_codet representation of a function call statement.
260
267
// / The function call statement has three operands.
261
268
// / The first is the expression that is used to store the return value.
262
269
// / The second is the function called.
263
270
// / The third is a vector of argument values.
264
- class code_function_callt : public codet
271
+ class code_function_callt : public goto_instruction_codet
265
272
{
266
273
public:
267
274
explicit code_function_callt (exprt _function)
268
- : codet (
275
+ : goto_instruction_codet (
269
276
ID_function_call,
270
277
{nil_exprt (), std::move (_function), exprt (ID_arguments)})
271
278
{
@@ -274,7 +281,7 @@ class code_function_callt : public codet
274
281
typedef exprt::operandst argumentst;
275
282
276
283
code_function_callt (exprt _lhs, exprt _function, argumentst _arguments)
277
- : codet (
284
+ : goto_instruction_codet (
278
285
ID_function_call,
279
286
{std::move (_lhs), std::move (_function), exprt (ID_arguments)})
280
287
{
@@ -318,7 +325,7 @@ class code_function_callt : public codet
318
325
}
319
326
320
327
static void check (
321
- const codet &code,
328
+ const goto_instruction_codet &code,
322
329
const validation_modet vm = validation_modet::INVARIANT)
323
330
{
324
331
DATA_CHECK (
@@ -330,7 +337,7 @@ class code_function_callt : public codet
330
337
}
331
338
332
339
static void validate (
333
- const codet &code,
340
+ const goto_instruction_codet &code,
334
341
const namespacet &,
335
342
const validation_modet vm = validation_modet::INVARIANT)
336
343
{
@@ -344,7 +351,7 @@ class code_function_callt : public codet
344
351
}
345
352
346
353
static void validate_full (
347
- const codet &code,
354
+ const goto_instruction_codet &code,
348
355
const namespacet &ns,
349
356
const validation_modet vm = validation_modet::INVARIANT)
350
357
{
@@ -357,10 +364,10 @@ class code_function_callt : public codet
357
364
}
358
365
359
366
protected:
360
- using codet ::op0;
361
- using codet ::op1;
362
- using codet ::op2;
363
- using codet ::op3;
367
+ using goto_instruction_codet ::op0;
368
+ using goto_instruction_codet ::op1;
369
+ using goto_instruction_codet ::op2;
370
+ using goto_instruction_codet ::op3;
364
371
};
365
372
366
373
template <>
@@ -374,29 +381,30 @@ inline void validate_expr(const code_function_callt &x)
374
381
code_function_callt::check (x);
375
382
}
376
383
377
- inline const code_function_callt &to_code_function_call (const codet &code)
384
+ inline const code_function_callt &
385
+ to_code_function_call (const goto_instruction_codet &code)
378
386
{
379
387
PRECONDITION (code.get_statement () == ID_function_call);
380
388
code_function_callt::check (code);
381
389
return static_cast <const code_function_callt &>(code);
382
390
}
383
391
384
- inline code_function_callt &to_code_function_call (codet &code)
392
+ inline code_function_callt &to_code_function_call (goto_instruction_codet &code)
385
393
{
386
394
PRECONDITION (code.get_statement () == ID_function_call);
387
395
code_function_callt::check (code);
388
396
return static_cast <code_function_callt &>(code);
389
397
}
390
398
391
- // / A `codet ` representing the declaration that an input of a particular
392
- // / description has a value which corresponds to the value of a given expression
393
- // / (or expressions).
399
+ // / A `goto_instruction_codet ` representing the declaration that an input of
400
+ // / a particular description has a value which corresponds to the value of a
401
+ // / given expression (or expressions).
394
402
// / When working with the C front end, calls to the `__CPROVER_input` intrinsic
395
403
// / can be added to the input code in order add instructions of this type to the
396
404
// / goto program.
397
405
// / The first argument is expected to be a C string denoting the input
398
406
// / identifier. The second argument is the expression for the input value.
399
- class code_inputt : public codet
407
+ class code_inputt : public goto_instruction_codet
400
408
{
401
409
public:
402
410
// / This constructor is for support of calls to `__CPROVER_input` in user
@@ -420,7 +428,7 @@ class code_inputt : public codet
420
428
optionalt<source_locationt> location = {});
421
429
422
430
static void check (
423
- const codet &code,
431
+ const goto_instruction_codet &code,
424
432
const validation_modet vm = validation_modet::INVARIANT);
425
433
};
426
434
@@ -435,15 +443,15 @@ inline void validate_expr(const code_inputt &input)
435
443
code_inputt::check (input);
436
444
}
437
445
438
- // / A `codet ` representing the declaration that an output of a particular
439
- // / description has a value which corresponds to the value of a given expression
440
- // / (or expressions).
446
+ // / A `goto_instruction_codet ` representing the declaration that an output of
447
+ // / a particular description has a value which corresponds to the value of a
448
+ // / given expression (or expressions).
441
449
// / When working with the C front end, calls to the `__CPROVER_output` intrinsic
442
450
// / can be added to the input code in order add instructions of this type to the
443
451
// / goto program.
444
452
// / The first argument is expected to be a C string denoting the output
445
453
// / identifier. The second argument is the expression for the output value.
446
- class code_outputt : public codet
454
+ class code_outputt : public goto_instruction_codet
447
455
{
448
456
public:
449
457
// / This constructor is for support of calls to `__CPROVER_output` in user
@@ -466,7 +474,7 @@ class code_outputt : public codet
466
474
optionalt<source_locationt> location = {});
467
475
468
476
static void check (
469
- const codet &code,
477
+ const goto_instruction_codet &code,
470
478
const validation_modet vm = validation_modet::INVARIANT);
471
479
};
472
480
@@ -481,11 +489,13 @@ inline void validate_expr(const code_outputt &output)
481
489
code_outputt::check (output);
482
490
}
483
491
484
- // / \ref codet representation of a "return from a function" statement.
485
- class code_returnt : public codet
492
+ // / \ref goto_instruction_codet representation of a "return from a
493
+ // / function" statement.
494
+ class code_returnt : public goto_instruction_codet
486
495
{
487
496
public:
488
- explicit code_returnt (exprt _op) : codet(ID_return, {std::move (_op)})
497
+ explicit code_returnt (exprt _op)
498
+ : goto_instruction_codet(ID_return, {std::move (_op)})
489
499
{
490
500
}
491
501
@@ -500,17 +510,17 @@ class code_returnt : public codet
500
510
}
501
511
502
512
static void check (
503
- const codet &code,
513
+ const goto_instruction_codet &code,
504
514
const validation_modet vm = validation_modet::INVARIANT)
505
515
{
506
516
DATA_CHECK (vm, code.operands ().size () == 1 , " return must have one operand" );
507
517
}
508
518
509
519
protected:
510
- using codet ::op0;
511
- using codet ::op1;
512
- using codet ::op2;
513
- using codet ::op3;
520
+ using goto_instruction_codet ::op0;
521
+ using goto_instruction_codet ::op1;
522
+ using goto_instruction_codet ::op2;
523
+ using goto_instruction_codet ::op3;
514
524
};
515
525
516
526
template <>
@@ -524,14 +534,14 @@ inline void validate_expr(const code_returnt &x)
524
534
code_returnt::check (x);
525
535
}
526
536
527
- inline const code_returnt &to_code_return (const codet &code)
537
+ inline const code_returnt &to_code_return (const goto_instruction_codet &code)
528
538
{
529
539
PRECONDITION (code.get_statement () == ID_return);
530
540
code_returnt::check (code);
531
541
return static_cast <const code_returnt &>(code);
532
542
}
533
543
534
- inline code_returnt &to_code_return (codet &code)
544
+ inline code_returnt &to_code_return (goto_instruction_codet &code)
535
545
{
536
546
PRECONDITION (code.get_statement () == ID_return);
537
547
code_returnt::check (code);
0 commit comments