@@ -1342,38 +1342,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
1342
1342
else if (statement==patternt (" ?const" ))
1343
1343
{
1344
1344
assert (results.size ()==1 );
1345
-
1346
- const char type_char=statement[0 ];
1347
- const bool is_double (' d' ==type_char);
1348
- const bool is_float (' f' ==type_char);
1349
-
1350
- if (is_double || is_float)
1351
- {
1352
- const ieee_float_spect spec (
1353
- is_float?ieee_float_spect::single_precision ():
1354
- ieee_float_spect::double_precision ());
1355
-
1356
- ieee_floatt value (spec);
1357
- if (arg0.type ().id ()!=ID_floatbv)
1358
- {
1359
- mp_integer number;
1360
- bool ret=to_integer (to_constant_expr (arg0), number);
1361
- DATA_INVARIANT (!ret, " failed to convert constant" );
1362
- value.from_integer (number);
1363
- }
1364
- else
1365
- value.from_expr (to_constant_expr (arg0));
1366
-
1367
- results[0 ]=value.to_expr ();
1368
- }
1369
- else
1370
- {
1371
- mp_integer value;
1372
- bool ret=to_integer (to_constant_expr (arg0), value);
1373
- DATA_INVARIANT (!ret, " failed to convert constant" );
1374
- const typet type=java_type_from_char (statement[0 ]);
1375
- results[0 ]=from_integer (value, type);
1376
- }
1345
+ results = convert_const (statement, arg0, results);
1377
1346
}
1378
1347
else if (statement==patternt (" ?ipush" ))
1379
1348
{
@@ -2004,6 +1973,45 @@ codet java_bytecode_convert_methodt::convert_instructions(
2004
1973
return code;
2005
1974
}
2006
1975
1976
+ exprt::operandst &java_bytecode_convert_methodt::convert_const (
1977
+ const irep_idt &statement,
1978
+ const exprt &arg0,
1979
+ exprt::operandst &results) const
1980
+ {
1981
+ const char type_char = statement[0 ];
1982
+ const bool is_double (' d' == type_char);
1983
+ const bool is_float (' f' == type_char);
1984
+
1985
+ if (is_double || is_float)
1986
+ {
1987
+ const ieee_float_spect spec (
1988
+ is_float ? ieee_float_spect::single_precision ()
1989
+ : ieee_float_spect::double_precision ());
1990
+
1991
+ ieee_floatt value (spec);
1992
+ if (arg0.type ().id () != ID_floatbv)
1993
+ {
1994
+ mp_integer number;
1995
+ bool ret = to_integer (to_constant_expr (arg0), number);
1996
+ DATA_INVARIANT (!ret, " failed to convert constant" );
1997
+ value.from_integer (number);
1998
+ }
1999
+ else
2000
+ value.from_expr (to_constant_expr (arg0));
2001
+
2002
+ results[0 ] = value.to_expr ();
2003
+ }
2004
+ else
2005
+ {
2006
+ mp_integer value;
2007
+ bool ret = to_integer (to_constant_expr (arg0), value);
2008
+ DATA_INVARIANT (!ret, " failed to convert constant" );
2009
+ const typet type = java_type_from_char (statement[0 ]);
2010
+ results[0 ] = from_integer (value, type);
2011
+ }
2012
+ return results;
2013
+ }
2014
+
2007
2015
void java_bytecode_convert_methodt::convert_invoke (
2008
2016
source_locationt location,
2009
2017
const irep_idt &statement,
0 commit comments