@@ -137,6 +137,13 @@ class smv_typecheckt:public typecheckt
137
137
else
138
138
return id;
139
139
}
140
+
141
+ void lower_node (exprt &) const ;
142
+
143
+ void lower (exprt &expr) const
144
+ {
145
+ expr.visit_post ([this ](exprt &expr) { lower_node (expr); });
146
+ }
140
147
};
141
148
142
149
/* ******************************************************************\
@@ -1227,6 +1234,40 @@ void smv_typecheckt::typecheck_expr_rec(exprt &expr, modet mode)
1227
1234
1228
1235
/* ******************************************************************\
1229
1236
1237
+ Function: smv_typecheckt::lower_node
1238
+
1239
+ Inputs:
1240
+
1241
+ Outputs:
1242
+
1243
+ Purpose:
1244
+
1245
+ \*******************************************************************/
1246
+
1247
+ void smv_typecheckt::lower_node (exprt &expr) const
1248
+ {
1249
+ if (expr.id () == ID_smv_extend)
1250
+ {
1251
+ auto &binary = to_binary_expr (expr);
1252
+ expr = typecast_exprt{binary.lhs (), expr.type ()};
1253
+ }
1254
+ else if (expr.id () == ID_smv_resize)
1255
+ {
1256
+ auto &binary = to_binary_expr (expr);
1257
+ expr = typecast_exprt{binary.lhs (), expr.type ()};
1258
+ }
1259
+ else if (expr.id () == ID_smv_signed_cast)
1260
+ {
1261
+ expr = typecast_exprt{to_unary_expr (expr).op (), expr.type ()};
1262
+ }
1263
+ else if (expr.id () == ID_smv_unsigned_cast)
1264
+ {
1265
+ expr = typecast_exprt{to_unary_expr (expr).op (), expr.type ()};
1266
+ }
1267
+ }
1268
+
1269
+ /* ******************************************************************\
1270
+
1230
1271
Function: smv_typecheckt::convert_expr_to
1231
1272
1232
1273
Inputs:
@@ -1814,6 +1855,9 @@ void smv_typecheckt::convert(smv_parse_treet::modulet &smv_module)
1814
1855
transt{ID_trans, conjunction (trans_invar), conjunction (trans_init),
1815
1856
conjunction (trans_trans), module_symbol.type };
1816
1857
1858
+ // lowering
1859
+ lower (module_symbol.value );
1860
+
1817
1861
module_symbol.pretty_name = strip_smv_prefix (module_symbol.name );
1818
1862
1819
1863
symbol_table.add (module_symbol);
@@ -1851,6 +1895,9 @@ void smv_typecheckt::convert(smv_parse_treet::modulet &smv_module)
1851
1895
else
1852
1896
spec_symbol.pretty_name = strip_smv_prefix (spec_symbol.name );
1853
1897
1898
+ // lowering
1899
+ lower (spec_symbol.value );
1900
+
1854
1901
symbol_table.add (spec_symbol);
1855
1902
}
1856
1903
}
0 commit comments