@@ -852,7 +852,15 @@ simple_expr: constant {
852852 SMVnode::Type bvs_b = b->getType ();
853853 smt::Term e;
854854 if ((bvs_a == SMVnode::Real && bvs_b == SMVnode::Integer) || (bvs_a == SMVnode::Integer && bvs_b == SMVnode::Real) ){
855- e = enc.solver_ ->make_term (smt::Equal, a->getTerm (), b->getTerm ());
855+ smt::Term a_term = a->getTerm ();
856+ smt::Term b_term = b->getTerm ();
857+ if (bvs_a == SMVnode::Real || bvs_b == SMVnode::Real){
858+ if (bvs_a != SMVnode::Real)
859+ a_term = enc.solver_ ->make_term (smt::To_Real, a_term);
860+ if (bvs_b != SMVnode::Real)
861+ b_term = enc.solver_ ->make_term (smt::To_Real, b_term);
862+ }
863+ e = enc.solver_ ->make_term (smt::Equal, a_term, b_term);
856864 }else if (bvs_a != bvs_b){
857865 throw PonoException (to_string (enc.loc .end .line ) +" Unsigned/Signed mismatch" );
858866 } else {
@@ -1236,7 +1244,17 @@ simple_expr: constant {
12361244 }
12371245 }
12381246 | tok_toint " (" basic_expr " )" {
1239- throw PonoException (" No type convert" );
1247+ if (enc.module_flat ){
1248+ SMVnode *a = $3 ;
1249+ smt::Sort sort = a->getTerm ()->get_sort ();
1250+ if (sort->get_sort_kind () != smt::BV){
1251+ throw PonoException (" Can't convert non-bitvector to integer." );
1252+ }
1253+ smt::Term res = enc.solver_ ->make_term (smt::BV_To_Nat, a->getTerm ());
1254+ $$ = new SMVnode (res,SMVnode::Integer);
1255+ }else {
1256+ $$ = new toint_expr ($3 );
1257+ }
12401258 }
12411259 | tok_count " (" basic_expr_list " )" {
12421260 throw PonoException (" No type convert" );
0 commit comments