static public void main( String args[] ) {
+ int m = 2;
int n = 3;
- Foo[] a = getArray();
- for( int j = 0; j < n; ++j ) {
- a[j] = getFoo();
+ Foo[] a;
+ Foo b;
+
+ Foo[][] top = new Foo[m][];
+ for( int i = 0; i < m; ++i ) {
+ a = getArray( n );
+ for( int j = 0; j < n; ++j ) {
+ b = getFoo();
+ a[j] = b;
+ }
+ top[i] = a;
}
- //Foo a = getFlagged();
- //Foo b = getUnflagged();
- //a.f = b;
- //
- //// a is flagged and b is reachable from
- //// at most one object from that site
- //gendefreach z0;
- //genreach z0;
- //
- //Foo c = new Foo();
- //a.g = c;
- //
- //Foo t = getFlagged();
- //t = getFlagged();
- //
- //Foo u = getUnflagged();
- //u = getUnflagged();
- //
- //// a is flagged and b is reachable from
- //// at most one object from that site, even
- //// though a and b are summarized now. a
- //// has a reference to a new object c
- //gendefreach z1;
- //genreach z1;
- //
- //c.f = b;
- //
- //// if we had definite reachability analysis
- //// we would realize b is already reachable
- //// from a
- //gendefreach z3;
- //genreach z3;
- //
- //System.out.println( " "+a+b+c );
+ // every Foo is reachable from only one Foo array
+ gendefreach z0;
+ genreach z0;
+ // resize array...
+ //Foo[] b = getArray( n + 1 );
+ //Foo[] notused = getArray( 1 );
+ //b[0] = getFoo();
+ //for( int j = 0; j < n; ++j ) {
+ // b[j+1] = a[j];
+ //}
+
+ // after array resize?
+ gendefreach z1;
+ genreach z1;
+
+ // use info to keep compiler from optimizing anything away
int total = 0;
- for( int j = 0; j < n; ++j ) {
- total += a[j].z;
+ for( int i = 0; i < m; ++i ) {
+ for( int j = 0; j < n; ++j ) {
+ total += top[i][j].z;
+ }
}
System.out.println( " "+total );
}
- static public Foo[] getArray() {
- return disjoint jupiter new Foo[]();
+ static public Foo[] getArray( int n ) {
+ return disjoint jupiter new Foo[n];
}
static public Foo getFoo() {