Skip to content

Commit a9ad2b8

Browse files
committed
array_comprehension_exprt is now a binding_exprt
The array comprehension expression introduces a local-scope symbol, and is therefore a binding. This commit reflects this in the type hierarchy.
1 parent d52022d commit a9ad2b8

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/util/std_expr.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,16 +3009,16 @@ inline cond_exprt &to_cond_expr(exprt &expr)
30093009
/// function, respectively. The range is given by the type of the expression,
30103010
/// which has to be an \ref array_typet (which includes a value for
30113011
/// `array_size`).
3012-
class array_comprehension_exprt : public binary_exprt
3012+
class array_comprehension_exprt : public binding_exprt
30133013
{
30143014
public:
30153015
explicit array_comprehension_exprt(
30163016
symbol_exprt arg,
30173017
exprt body,
30183018
array_typet _type)
3019-
: binary_exprt(
3020-
std::move(arg),
3019+
: binding_exprt(
30213020
ID_array_comprehension,
3021+
{std::move(arg)},
30223022
std::move(body),
30233023
std::move(_type))
30243024
{
@@ -3036,22 +3036,26 @@ class array_comprehension_exprt : public binary_exprt
30363036

30373037
const symbol_exprt &arg() const
30383038
{
3039-
return static_cast<const symbol_exprt &>(op0());
3039+
auto &variables = this->variables();
3040+
PRECONDITION(variables.size() == 1);
3041+
return variables[0];
30403042
}
30413043

30423044
symbol_exprt &arg()
30433045
{
3044-
return static_cast<symbol_exprt &>(op0());
3046+
auto &variables = this->variables();
3047+
PRECONDITION(variables.size() == 1);
3048+
return variables[0];
30453049
}
30463050

30473051
const exprt &body() const
30483052
{
3049-
return op1();
3053+
return where();
30503054
}
30513055

30523056
exprt &body()
30533057
{
3054-
return op1();
3058+
return where();
30553059
}
30563060
};
30573061

0 commit comments

Comments
 (0)