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