CBMC
expr_skeleton.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Symbolic Execution
4 
5 Author: Romain Brenguier, romain.brenguier@diffblue.com
6 
7 \*******************************************************************/
8 
11 
12 #include "expr_skeleton.h"
13 
14 #include <util/std_expr.h>
15 
17 {
18 }
19 
21 {
22  PRECONDITION(e.id() != ID_symbol);
23  PRECONDITION(e.operands().size() >= 1);
25  return expr_skeletont{std::move(e)};
26 }
27 
29 {
30  PRECONDITION(skeleton.id() != ID_symbol);
31  exprt result = skeleton;
32  exprt *p = &result;
33 
34  while(p->is_not_nil())
35  {
36  INVARIANT(
37  p->id() != ID_symbol,
38  "expected pointed-to expression not to be a symbol");
39  INVARIANT(
40  p->operands().size() >= 1,
41  "expected pointed-to expression to have at least one operand");
42  p = &to_multi_ary_expr(*p).op0();
43  }
44 
45  INVARIANT(p->is_nil(), "expected pointed-to expression to be nil");
46 
47  *p = std::move(expr);
48  return result;
49 }
50 
52 {
53  return expr_skeletont(apply(other.skeleton));
54 }
Expression in which some part is missing and can be substituted for another expression.
Definition: expr_skeleton.h:26
exprt apply(exprt expr) const
Replace the missing part by the given expression, to end-up with a complete expression.
expr_skeletont()
Empty skeleton.
expr_skeletont compose(expr_skeletont other) const
Replace the missing part of the current skeleton by another skeleton, ending in a bigger skeleton cor...
static expr_skeletont remove_op0(exprt e)
Create a skeleton by removing the first operand of e.
exprt skeleton
In skeleton, nil_exprt is used to mark the sub expression to be substituted.
Definition: expr_skeleton.h:51
Base class for all expressions.
Definition: expr.h:56
operandst & operands()
Definition: expr.h:94
bool is_not_nil() const
Definition: irep.h:372
const irep_idt & id() const
Definition: irep.h:388
void make_nil()
Definition: irep.h:446
bool is_nil() const
Definition: irep.h:368
exprt & op0()
Definition: std_expr.h:932
The NIL expression.
Definition: std_expr.h:3091
Expression skeleton.
#define PRECONDITION(CONDITION)
Definition: invariant.h:463
API to expression classes.
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
Definition: std_expr.h:987