@@ -1822,64 +1822,14 @@ codet java_bytecode_convert_methodt::convert_instructions(
1822
1822
{
1823
1823
// use temporary since the stack symbol might get duplicated
1824
1824
PRECONDITION (op.empty () && results.size () == 1 );
1825
- convert_new (i_it, arg0, c, results);
1825
+ convert_new (i_it-> source_location , arg0, c, results);
1826
1826
}
1827
1827
else if (statement==" newarray" ||
1828
1828
statement==" anewarray" )
1829
1829
{
1830
1830
// the op is the array size
1831
1831
PRECONDITION (op.size () == 1 && results.size () == 1 );
1832
-
1833
- char element_type;
1834
-
1835
- if (statement==" newarray" )
1836
- {
1837
- irep_idt id=arg0.type ().id ();
1838
-
1839
- if (id==ID_bool)
1840
- element_type=' z' ;
1841
- else if (id==ID_char)
1842
- element_type=' c' ;
1843
- else if (id==ID_float)
1844
- element_type=' f' ;
1845
- else if (id==ID_double)
1846
- element_type=' d' ;
1847
- else if (id==ID_byte)
1848
- element_type=' b' ;
1849
- else if (id==ID_short)
1850
- element_type=' s' ;
1851
- else if (id==ID_int)
1852
- element_type=' i' ;
1853
- else if (id==ID_long)
1854
- element_type=' j' ;
1855
- else
1856
- element_type=' ?' ;
1857
- }
1858
- else
1859
- element_type=' a' ;
1860
-
1861
- const reference_typet ref_type=
1862
- java_array_type (element_type);
1863
-
1864
- side_effect_exprt java_new_array (ID_java_new_array, ref_type);
1865
- java_new_array.copy_to_operands (op[0 ]);
1866
-
1867
- if (!i_it->source_location .get_line ().empty ())
1868
- java_new_array.add_source_location ()=i_it->source_location ;
1869
-
1870
- c=code_blockt ();
1871
-
1872
- if (max_array_length!=0 )
1873
- {
1874
- constant_exprt size_limit=
1875
- from_integer (max_array_length, java_int_type ());
1876
- binary_relation_exprt le_max_size (op[0 ], ID_le, size_limit);
1877
- code_assumet assume_le_max_size (le_max_size);
1878
- c.move_to_operands (assume_le_max_size);
1879
- }
1880
- const exprt tmp=tmp_variable (" newarray" , ref_type);
1881
- c.copy_to_operands (code_assignt (tmp, java_new_array));
1882
- results[0 ]=tmp;
1832
+ convert_newarray (i_it->source_location , statement, arg0, op, c, results);
1883
1833
}
1884
1834
else if (statement==" multianewarray" )
1885
1835
{
@@ -2384,6 +2334,64 @@ codet java_bytecode_convert_methodt::convert_instructions(
2384
2334
return code;
2385
2335
}
2386
2336
2337
+ void java_bytecode_convert_methodt::convert_newarray (
2338
+ const source_locationt &location,
2339
+ const irep_idt &statement,
2340
+ const exprt &arg0,
2341
+ const exprt::operandst &op,
2342
+ codet &c,
2343
+ exprt::operandst &results)
2344
+ {
2345
+ char element_type;
2346
+
2347
+ if (statement == " newarray" )
2348
+ {
2349
+ irep_idt id = arg0.type ().id ();
2350
+
2351
+ if (id == ID_bool)
2352
+ element_type = ' z' ;
2353
+ else if (id == ID_char)
2354
+ element_type = ' c' ;
2355
+ else if (id == ID_float)
2356
+ element_type = ' f' ;
2357
+ else if (id == ID_double)
2358
+ element_type = ' d' ;
2359
+ else if (id == ID_byte)
2360
+ element_type = ' b' ;
2361
+ else if (id == ID_short)
2362
+ element_type = ' s' ;
2363
+ else if (id == ID_int)
2364
+ element_type = ' i' ;
2365
+ else if (id == ID_long)
2366
+ element_type = ' j' ;
2367
+ else
2368
+ element_type = ' ?' ;
2369
+ }
2370
+ else
2371
+ element_type = ' a' ;
2372
+
2373
+ const reference_typet ref_type = java_array_type (element_type);
2374
+
2375
+ side_effect_exprt java_new_array (ID_java_new_array, ref_type);
2376
+ java_new_array.copy_to_operands (op[0 ]);
2377
+
2378
+ if (!location.get_line ().empty ())
2379
+ java_new_array.add_source_location () = location;
2380
+
2381
+ c = code_blockt ();
2382
+
2383
+ if (max_array_length != 0 )
2384
+ {
2385
+ constant_exprt size_limit = from_integer (max_array_length, java_int_type ());
2386
+ binary_relation_exprt le_max_size (op[0 ], ID_le, size_limit);
2387
+ code_assumet assume_le_max_size (le_max_size);
2388
+ c.move_to_operands (assume_le_max_size);
2389
+ }
2390
+ const exprt tmp = tmp_variable (" newarray" , ref_type);
2391
+ c.copy_to_operands (code_assignt (tmp, java_new_array));
2392
+ results[0 ] = tmp;
2393
+ }
2394
+
2387
2395
void java_bytecode_convert_methodt::convert_new (
2388
2396
const source_locationt &location,
2389
2397
const exprt &arg0,
0 commit comments