| 332 | |
| 333 | // Builds and returns a pointer Object |
| 334 | private static Object alloc(NewNode alloc) { |
| 335 | TypeStruct type = alloc._ptr._obj; |
| 336 | if( type.isAry() ) { |
| 337 | long sz = (Long)val(alloc.in(1)); |
| 338 | long x = offToIdx(sz, type); |
| 339 | int n = (int)x; |
| 340 | if( n!=x || n<0 ) |
| 341 | throw new NegativeArraySizeException(""+n); |
| 342 | Object[] ary = new Object[n]; // Array body |
| 343 | var elem = type._fields[1]._t; |
| 344 | if (elem instanceof TypeInteger) { |
| 345 | Arrays.fill( ary, 0L ); |
| 346 | } else if (elem instanceof TypeFloat) { |
| 347 | Arrays.fill( ary, 0D ); |
| 348 | } else { |
| 349 | assert elem instanceof TypeMemPtr || elem instanceof TypeFunPtr; |
| 350 | } |
| 351 | return ary; |
| 352 | } |
| 353 | |
| 354 | int num = type._fields.length; |
| 355 | Object[] ptr = new Object[num]; |
| 356 | for( int i=0; i<num; i++ ) |
| 357 | ptr[i] = con(type._fields[i]._t.makeZero()); |
| 358 | return ptr; |
| 359 | } |
| 360 | |
| 361 | private static Object load( LoadNode ld ) { |
| 362 | Object f = val(ld.ptr()); |