Skip to content

Commit d86fd2b

Browse files
Use ASTs in convert_expr
This is in preparation for making convert_expr return an AST.
1 parent 51bb35b commit d86fd2b

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

src/solvers/smt2/smt2_conv.cpp

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -936,28 +936,25 @@ void smt2_convt::convert_expr(const exprt &expr)
936936
"given expression should have at least two operands",
937937
expr.id_string());
938938

939-
out << "(";
940-
941-
if(expr.id()==ID_concatenation)
942-
out << "concat";
943-
else if(expr.id()==ID_bitand)
944-
out << "bvand";
945-
else if(expr.id()==ID_bitor)
946-
out << "bvor";
947-
else if(expr.id()==ID_bitxor)
948-
out << "bvxor";
949-
else if(expr.id()==ID_bitnand)
950-
out << "bvnand";
951-
else if(expr.id()==ID_bitnor)
952-
out << "bvnor";
953-
954-
forall_operands(it, expr)
955-
{
956-
out << " ";
957-
flatten2bv(*it);
958-
}
939+
auto node = make_shared_tree([&] {
940+
if(expr.id() == ID_concatenation)
941+
return "concat";
942+
else if(expr.id() == ID_bitand)
943+
return "bvand";
944+
else if(expr.id() == ID_bitor)
945+
return "bvor";
946+
else if(expr.id() == ID_bitxor)
947+
return "bvxor";
948+
else if(expr.id() == ID_bitnand)
949+
return "bvnand";
950+
else if(expr.id() == ID_bitnor)
951+
return "bvnor";
952+
UNREACHABLE;
953+
}());
959954

960-
out << ")";
955+
for(const exprt &e : expr.operands())
956+
node->add_child(flatten2bv(e));
957+
print(node, out);
961958
}
962959
else if(expr.id()==ID_bitnot)
963960
{

0 commit comments

Comments
 (0)