@@ -236,8 +236,8 @@ const exprt java_bytecode_convert_methodt::variable(
236
236
else
237
237
{
238
238
exprt result=var.symbol_expr ;
239
- if (do_cast==CAST_AS_NEEDED && t!=result. type () )
240
- result= typecast_exprt (result, t);
239
+ if (do_cast == CAST_AS_NEEDED )
240
+ result = typecast_exprt::conditional_cast (result, t);
241
241
return result;
242
242
}
243
243
}
@@ -1289,9 +1289,8 @@ code_blockt java_bytecode_convert_methodt::convert_instructions(
1289
1289
// Return types are promoted in java, so this might need
1290
1290
// conversion.
1291
1291
PRECONDITION (op.size () == 1 && results.empty ());
1292
- exprt r=op[0 ];
1293
- if (r.type ()!=method_return_type)
1294
- r=typecast_exprt (r, method_return_type);
1292
+ const exprt r =
1293
+ typecast_exprt::conditional_cast (op[0 ], method_return_type);
1295
1294
c=code_returnt (r);
1296
1295
}
1297
1296
else if (statement==patternt (" ?astore" ))
@@ -2793,17 +2792,11 @@ code_ifthenelset java_bytecode_convert_methodt::convert_if_cmp(
2793
2792
{
2794
2793
code_ifthenelset code_branch;
2795
2794
const irep_idt cmp_op = get_if_cmp_operator (statement);
2796
-
2797
- binary_relation_exprt condition (op[0 ], cmp_op, op[1 ]);
2798
-
2799
- exprt &lhs (condition.lhs ());
2800
- exprt &rhs (condition.rhs ());
2801
- const typet &lhs_type (lhs.type ());
2802
- if (lhs_type != rhs.type ())
2803
- rhs = typecast_exprt (rhs, lhs_type);
2795
+ binary_relation_exprt condition (
2796
+ op[0 ], cmp_op, typecast_exprt::conditional_cast (op[1 ], op[0 ].type ()));
2797
+ condition.add_source_location () = location;
2804
2798
2805
2799
code_branch.cond () = condition;
2806
- code_branch.cond ().add_source_location () = location;
2807
2800
const method_offsett label_number = numeric_cast_v<method_offsett>(number);
2808
2801
code_branch.then_case () = code_gotot (label (std::to_string (label_number)));
2809
2802
code_branch.then_case ().add_source_location () =
@@ -2876,8 +2869,8 @@ code_blockt java_bytecode_convert_methodt::convert_store(
2876
2869
const irep_idt &var_name = to_symbol_expr (var).get_identifier ();
2877
2870
2878
2871
exprt toassign = op[0 ];
2879
- if (' a' == statement[0 ] && toassign. type () != var. type () )
2880
- toassign = typecast_exprt (toassign, var.type ());
2872
+ if (' a' == statement[0 ])
2873
+ toassign = typecast_exprt::conditional_cast (toassign, var.type ());
2881
2874
2882
2875
code_blockt block;
2883
2876
0 commit comments