@@ -168,28 +168,29 @@ void goto_symext::symex_assign_rec(
168
168
symex_assign_byte_extract (
169
169
state, to_byte_extract_expr (lhs), full_lhs, rhs, guard, assignment_type);
170
170
}
171
- else if (lhs.id ()==ID_complex_real ||
172
- lhs.id ()==ID_complex_imag)
171
+ else if (lhs.id () == ID_complex_real)
173
172
{
174
- // this is stuff like __real__ x = 1;
175
- assert (lhs.operands ().size ()==1 );
173
+ const complex_real_exprt &complex_real_expr = to_complex_real_expr (lhs);
176
174
177
- exprt new_rhs=exprt (ID_complex, lhs.op0 ().type ());
178
- new_rhs.operands ().resize (2 );
175
+ const complex_imag_exprt complex_imag_expr (complex_real_expr.op ());
179
176
180
- if (lhs.id ()==ID_complex_real)
181
- {
182
- new_rhs.op0 ()=rhs;
183
- new_rhs.op1 ()=unary_exprt (ID_complex_imag, lhs.op0 (), lhs.type ());
184
- }
185
- else
186
- {
187
- new_rhs.op0 ()=unary_exprt (ID_complex_real, lhs.op0 (), lhs.type ());
188
- new_rhs.op1 ()=rhs;
189
- }
177
+ complex_exprt new_rhs (
178
+ rhs, complex_imag_expr, to_complex_type (complex_real_expr.op ().type ()));
179
+
180
+ symex_assign_rec (
181
+ state, complex_real_expr.op (), full_lhs, new_rhs, guard, assignment_type);
182
+ }
183
+ else if (lhs.id () == ID_complex_imag)
184
+ {
185
+ const complex_imag_exprt &complex_imag_expr = to_complex_imag_expr (lhs);
186
+
187
+ const complex_real_exprt complex_real_expr (complex_imag_expr.op ());
188
+
189
+ complex_exprt new_rhs (
190
+ complex_real_expr, rhs, to_complex_type (complex_imag_expr.op ().type ()));
190
191
191
192
symex_assign_rec (
192
- state, lhs. op0 (), full_lhs, new_rhs, guard, assignment_type);
193
+ state, complex_imag_expr. op (), full_lhs, new_rhs, guard, assignment_type);
193
194
}
194
195
else
195
196
throw " assignment to `" +lhs.id_string ()+" ' not handled" ;
0 commit comments