@@ -787,20 +787,13 @@ exprt verilog_synthesist::assignment_rec(const exprt &lhs, const exprt &rhs)
787787 // do the value
788788 exprt new_value = assignment_rec (lhs_src, new_rhs); // recursive call
789789
790- if (last_value.is_nil ())
791- last_value.swap (new_value);
792- else
790+ if (last_value.is_not_nil ())
793791 {
794- // merge the withs
795- assert (new_value.id () == ID_with);
796- assert (new_value.operands ().size () == 3 );
797- assert (last_value.id () == ID_with);
798- assert (last_value.operands ().size () >= 3 );
799-
800- last_value.add_to_operands (std::move (to_with_expr (new_value).where ()));
801- last_value.add_to_operands (
802- std::move (to_with_expr (new_value).new_value ()));
792+ // chain the withs
793+ to_with_expr (new_value).old () = std::move (last_value);
803794 }
795+
796+ last_value = std::move (new_value);
804797 }
805798
806799 return last_value;
@@ -874,20 +867,13 @@ exprt verilog_synthesist::assignment_rec(const exprt &lhs, const exprt &rhs)
874867 // do the value
875868 exprt new_value = assignment_rec (lhs_src, new_rhs); // recursive call
876869
877- if (last_value.is_nil ())
878- last_value.swap (new_value);
879- else
870+ if (last_value.is_not_nil ())
880871 {
881- // merge the withs
882- assert (new_value.id () == ID_with);
883- assert (new_value.operands ().size () == 3 );
884- assert (last_value.id () == ID_with);
885- assert (last_value.operands ().size () >= 3 );
886-
887- last_value.add_to_operands (std::move (to_with_expr (new_value).where ()));
888- last_value.add_to_operands (
889- std::move (to_with_expr (new_value).new_value ()));
872+ // chain the withs
873+ to_with_expr (new_value).old () = std::move (last_value);
890874 }
875+
876+ last_value = std::move (new_value);
891877 }
892878
893879 return last_value;
0 commit comments