| 301 | |
| 302 | // Java box ints and floats. Other things can just be null or some informative string |
| 303 | private static Object con( Type t ) { |
| 304 | return switch ( t ) { |
| 305 | case TypeInteger i -> i.isConstant() ? (Long )i.value() : "INT"; |
| 306 | case TypeFloat f -> f.isConstant() ? (Double)f.value() : "FLT"; |
| 307 | case TypeFunPtr tfp -> tfp; |
| 308 | case TypeMem mem -> "MEM"; |
| 309 | case TypeMemPtr tmp -> { |
| 310 | if( tmp._obj.isAry() ) { // Constant array ptr |
| 311 | Type elem = tmp._obj.field("[]")._t; |
| 312 | if( elem instanceof TypeConAry con ) { |
| 313 | Object[] xs = new Object[con.len()]; |
| 314 | for( int i=0; i<con.len(); i++ ) |
| 315 | xs[i] = con.at8(i); |
| 316 | yield xs; |
| 317 | } else { |
| 318 | // Generic constant array, used as a default input to a |
| 319 | // function; should never execute. |
| 320 | yield new Object[0]; |
| 321 | } |
| 322 | |
| 323 | } else { |
| 324 | // Generic TMP (since Simple is not currently making actual |
| 325 | // memory constants), used as a default input to a function; |
| 326 | // should never execute. |
| 327 | yield tmp.toString(); |
| 328 | } |
| 329 | } |
| 330 | default -> null; |
| 331 | }; |
| 332 | } |
| 333 | |
| 334 | // Convert array size to array element count |
| 335 | private static int offToIdx( long off, TypeStruct t) { |