| 320 | |
| 321 | // Builds and returns a pointer Object |
| 322 | private static Object alloc(NewNode alloc) { |
| 323 | TypeStruct type = alloc._ptr._obj; |
| 324 | if( type.isAry() ) { |
| 325 | long sz = (Long)val(alloc.in(1)); |
| 326 | long x = offToIdx(sz, type); |
| 327 | int n = (int)x; |
| 328 | if( n!=x || n<0 ) |
| 329 | throw new NegativeArraySizeException(""+n); |
| 330 | Object[] ary = new Object[n]; // Array body |
| 331 | var elem = type._fields[1]._type; |
| 332 | if (elem instanceof TypeInteger) { |
| 333 | Arrays.fill( ary, 0L ); |
| 334 | } else if (elem instanceof TypeFloat) { |
| 335 | Arrays.fill( ary, 0D ); |
| 336 | } else { |
| 337 | assert elem instanceof TypeMemPtr || elem instanceof TypeFunPtr; |
| 338 | } |
| 339 | return ary; |
| 340 | } |
| 341 | |
| 342 | int num = type._fields.length; |
| 343 | Object[] ptr = new Object[num]; |
| 344 | for( int i=0; i<num; i++ ) |
| 345 | ptr[i] = con(type._fields[i]._type.makeZero()); |
| 346 | return ptr; |
| 347 | } |
| 348 | |
| 349 | private static Object load( LoadNode ld ) { |
| 350 | Object f = val(ld.ptr()); |