@@ -1312,38 +1312,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
1312
1312
else if (statement==patternt (" ?const" ))
1313
1313
{
1314
1314
assert (results.size ()==1 );
1315
-
1316
- const char type_char=statement[0 ];
1317
- const bool is_double (' d' ==type_char);
1318
- const bool is_float (' f' ==type_char);
1319
-
1320
- if (is_double || is_float)
1321
- {
1322
- const ieee_float_spect spec (
1323
- is_float?ieee_float_spect::single_precision ():
1324
- ieee_float_spect::double_precision ());
1325
-
1326
- ieee_floatt value (spec);
1327
- if (arg0.type ().id ()!=ID_floatbv)
1328
- {
1329
- mp_integer number;
1330
- bool ret=to_integer (to_constant_expr (arg0), number);
1331
- DATA_INVARIANT (!ret, " failed to convert constant" );
1332
- value.from_integer (number);
1333
- }
1334
- else
1335
- value.from_expr (to_constant_expr (arg0));
1336
-
1337
- results[0 ]=value.to_expr ();
1338
- }
1339
- else
1340
- {
1341
- mp_integer value;
1342
- bool ret=to_integer (to_constant_expr (arg0), value);
1343
- DATA_INVARIANT (!ret, " failed to convert constant" );
1344
- const typet type=java_type_from_char (statement[0 ]);
1345
- results[0 ]=from_integer (value, type);
1346
- }
1315
+ results = convert_const (statement, arg0, results);
1347
1316
}
1348
1317
else if (statement==patternt (" ?ipush" ))
1349
1318
{
@@ -1974,6 +1943,45 @@ codet java_bytecode_convert_methodt::convert_instructions(
1974
1943
return code;
1975
1944
}
1976
1945
1946
+ exprt::operandst &java_bytecode_convert_methodt::convert_const (
1947
+ const irep_idt &statement,
1948
+ exprt &arg0,
1949
+ exprt::operandst &results) const
1950
+ {
1951
+ const char type_char = statement[0 ];
1952
+ const bool is_double (' d' == type_char);
1953
+ const bool is_float (' f' == type_char);
1954
+
1955
+ if (is_double || is_float)
1956
+ {
1957
+ const ieee_float_spect spec (
1958
+ is_float ? ieee_float_spect::single_precision ()
1959
+ : ieee_float_spect::double_precision ());
1960
+
1961
+ ieee_floatt value (spec);
1962
+ if (arg0.type ().id () != ID_floatbv)
1963
+ {
1964
+ mp_integer number;
1965
+ bool ret = to_integer (to_constant_expr (arg0), number);
1966
+ DATA_INVARIANT (!ret, " failed to convert constant" );
1967
+ value.from_integer (number);
1968
+ }
1969
+ else
1970
+ value.from_expr (to_constant_expr (arg0));
1971
+
1972
+ results[0 ] = value.to_expr ();
1973
+ }
1974
+ else
1975
+ {
1976
+ mp_integer value;
1977
+ bool ret = to_integer (to_constant_expr (arg0), value);
1978
+ DATA_INVARIANT (!ret, " failed to convert constant" );
1979
+ const typet type = java_type_from_char (statement[0 ]);
1980
+ results[0 ] = from_integer (value, type);
1981
+ }
1982
+ return results;
1983
+ }
1984
+
1977
1985
void java_bytecode_convert_methodt::convert_invoke (
1978
1986
const std::vector<java_bytecode_parse_treet::instructiont>::const_iterator
1979
1987
&i_it,
0 commit comments