@@ -119,7 +119,18 @@ class java_bytecode_convert_methodt:public messaget
119
119
}
120
120
121
121
// JVM local variables
122
- const exprt variable (const exprt &arg, char type_char, size_t address, instruction_sizet inst_size)
122
+ enum variable_cast_argumentt
123
+ {
124
+ CAST_AS_NEEDED,
125
+ NO_CAST
126
+ };
127
+
128
+ const exprt variable (
129
+ const exprt &arg,
130
+ char type_char,
131
+ size_t address,
132
+ instruction_sizet inst_size,
133
+ variable_cast_argumentt do_cast)
123
134
{
124
135
irep_idt number=to_constant_expr (arg).get_value ();
125
136
@@ -145,7 +156,7 @@ class java_bytecode_convert_methodt:public messaget
145
156
else
146
157
{
147
158
exprt result=var.symbol_expr ;
148
- if (t!=result.type ()) result=typecast_exprt (result, t);
159
+ if (do_cast==CAST_AS_NEEDED && t!=result.type ()) result=typecast_exprt (result, t);
149
160
return result;
150
161
}
151
162
}
@@ -835,7 +846,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
835
846
// store value into some local variable
836
847
assert (op.size ()==1 && results.empty ());
837
848
838
- exprt var=variable (arg0, statement[0 ], i_it->address , INST_INDEX);
849
+ exprt var=variable (arg0, statement[0 ], i_it->address , INST_INDEX, NO_CAST );
839
850
840
851
exprt toassign=op[0 ];
841
852
if (' a' ==statement[0 ] && toassign.type ()!=var.type ())
@@ -866,7 +877,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
866
877
else if (statement==patternt (" ?load" ))
867
878
{
868
879
// load a value from a local variable
869
- results[0 ]=variable (arg0, statement[0 ], i_it->address , INST_INDEX);
880
+ results[0 ]=variable (arg0, statement[0 ], i_it->address , INST_INDEX, CAST_AS_NEEDED );
870
881
}
871
882
else if (statement==" ldc" || statement==" ldc_w" ||
872
883
statement==" ldc2" || statement==" ldc2_w" )
@@ -1028,10 +1039,10 @@ codet java_bytecode_convert_methodt::convert_instructions(
1028
1039
else if (statement==" iinc" )
1029
1040
{
1030
1041
code_assignt code_assign;
1031
- code_assign.lhs ()=variable (arg0, ' i' , i_it->address , INST_INDEX_CONST);
1042
+ code_assign.lhs ()=variable (arg0, ' i' , i_it->address , INST_INDEX_CONST, NO_CAST );
1032
1043
code_assign.rhs ()=plus_exprt (
1033
- variable (arg0, ' i' , i_it->address , INST_INDEX_CONST),
1034
- typecast_exprt (arg1, java_int_type ()));
1044
+ variable (arg0, ' i' , i_it->address , INST_INDEX_CONST, CAST_AS_NEEDED ),
1045
+ typecast_exprt (arg1, java_int_type ()));
1035
1046
c=code_assign;
1036
1047
}
1037
1048
else if (statement==patternt (" ?xor" ))
0 commit comments