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