Retooled edges and basic stuff is working again (finally) but reachability needs...
[IRC.git] / Robust / src / Tests / OwnershipAnalysisTest / test01 / test01.java
1 /*
2 public class Parameter {
3     flag w;
4     int a, b;
5     Parameter f, g;
6     Penguin penguin;
7
8     public Parameter() { a = 0; b = 0; f = null; g = null; }
9
10     public void bar() { foo(); }
11     public void foo() { bar(); }
12 }
13
14 public class Penguin {
15     int x, y;
16
17     public Penguin() { x = 0; y = 0; }
18
19     public void bar() { x = 1; }
20 }
21
22 public class Voo {
23     flag f; int x; Baw b; Baw bb;
24
25     public Voo() {}
26 }
27
28 public class Baw {
29     int y;
30     Foo f;
31
32     public Baw() {}
33
34     public void doTheBaw( Voo v ) { v = new Voo(); }
35 }
36 */
37
38 public class Foo {
39     flag f;
40
41     public Foo() {}
42
43     public Foo x;
44
45     /*
46     public void ruinSomeFoos( Foo a, Foo b ) {
47         a.x = b.x;
48     }
49
50
51     static public void test( Foo p0, Foo p1 ) {
52         Foo f0 = new Foo();
53         Foo f1 = new Foo();
54         Foo f2 = new Foo();
55
56         f0.x = f1;
57         p0.x = f0;
58         p1.x = f1;
59         p1.x = f2;
60     }
61     */
62 }
63
64
65 // this empty task should still create a non-empty
66 // ownership graph showing parameter allocation
67 // look for the parameter s as a label referencing
68 // a heap region that is multi-object, flagged, not summary
69 task Startup( StartupObject s{ initialstate } ) {
70     
71     /*
72     while( false ) {
73         Foo a = new Foo();
74         a.x   = new Foo();
75         a.x.x = new Foo();
76
77         //Foo z = a.x;
78         //z.x = new Foo();
79     }
80     
81
82
83     Foo d = new Foo();
84     Foo e = new Foo();
85     Foo f = new Foo();
86     Foo g = new Foo();
87
88     d.x = e;
89     e.x = f;
90     f.x = g;
91
92
93     Foo h = new Foo();
94     Foo i = new Foo();
95     Foo j = new Foo();
96     Foo k = new Foo();
97
98     j.x = k;
99     i.x = j;
100     h.x = i;
101
102
103     
104
105     // to look like Foo a above
106     //d.x.x = f;
107
108
109     Foo b;
110     while( false ) {
111         Foo c = new Foo();
112         c.x = b;
113         b = c;
114     }
115     */
116
117     taskexit( s{ !initialstate } );
118 }
119
120
121 task basics( Foo p0{ f }, Foo p1{ f } ) {
122
123     //Foo a = new Foo();
124     //Foo b = new Foo();
125
126     Foo q = p0;
127     p0.x = p1;
128
129     Foo a = new Foo();
130     a.x   = new Foo();
131     a.x.x = new Foo();
132
133     //p0.x = a;
134     //a.x  = b;
135
136     taskexit( p0{ !f }, p1{ !f } );
137 }
138
139 /*
140 task methodTest( Foo p0{ f } ) {
141
142     Foo up0 = new Foo();
143     Foo up1 = new Foo();
144     Foo up2 = new Foo();
145
146     Foo a0;
147     Foo a1;
148
149     if( false ) {
150         a0    = new Foo();
151         up0.x = a0;     
152         a0.x  = new Foo();
153         //Foo temp = new Foo();
154     }
155
156     if( false ) {
157         a0    = new Foo();
158         a0.x  = new Foo();
159         a1    = a0;
160         up1.x = a0;
161     }
162
163     if( false ) {
164         a1    = new Foo();
165         up2.x = a1;
166     }
167
168     // Foo.test( a0, a1 );
169
170     taskexit( p0{ !f } );
171 }
172 */
173
174
175
176 /*
177 task NewObject( Foo a{ f }, Foo b{ f } ) {
178
179     Foo c = new Foo();
180
181     a.x = c;
182
183     taskexit( a{ !f }, b{ !f } );
184 }
185 */
186
187 /*
188 task NewObjectA( Foo a{ f }, Foo b{ f } ) {
189
190     Foo c = new Foo();
191     Foo d = new Foo();
192
193     c.x = d;
194     a.x = c;
195
196     taskexit( a{ !f }, b{ !f } );
197 }
198
199 task NewObjectB( Foo a{ f }, Foo b{ f } ) {
200
201     Foo c = new Foo();
202     Foo d = new Foo();
203
204     a.x = c;
205     c.x = d;
206
207     taskexit( a{ !f }, b{ !f } );
208 }
209 */
210
211 /*
212 task NewObject2( Foo a{ f }, Foo b{ f } ) {
213
214     Foo c;
215
216     while( false ) {
217         c   = new Foo();
218         c.x = new Foo();
219     }
220
221     taskexit( a{ !f }, b{ !f } );
222 }
223 */
224
225
226 /*
227 // this task allocates a new object, so there should
228 // be a heap region for the parameter, and several
229 // heap regions for the allocation site, but the label
230 // merely points to the newest region
231 task NewObject( Voo v{ f } ) {
232     Voo w = new Voo();
233     Baw b = new Baw();
234     b.doTheBaw( w );
235
236     taskexit( v{ !f } );
237 }
238
239
240 // this task 
241 task Branch( Voo v{ f } ) {
242     Voo w = new Voo();
243     Baw j = new Baw();
244     Baw k = new Baw();
245
246     if( v.x == 0 ) {
247         w.b = j;
248     } else {
249         w.b = k;
250     }
251
252     taskexit( v{ !f } );
253 }
254
255
256 task NoAliasNewInLoop( Voo v{ f } ) {
257
258     for( int i = 0; i < 10; ++i ) {
259         Voo w = new Voo();
260         w.b   = new Baw();
261         w.b.f = new Foo();
262     }
263
264     taskexit( v{ !f } );
265 }
266
267
268 task NoAliasNewInLoopAnotherWay( Voo v{ f } ) {
269
270     for( int i = 0; i < 10; ++i ) {
271         Voo w = new Voo();
272         Baw b = new Baw();
273         Foo f = new Foo();
274
275         w.b = b;
276         b.f = f;
277     }
278
279     taskexit( v{ !f } );
280 }
281
282
283 task ClobberInitParamReflex( Voo v{ f }, Voo w{ f } ) {
284     v.b = v.bb;
285
286     taskexit( v{ !f }, w{ !f } );
287 }
288 */