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