Prune change sets during token prop by beta info only, not whether the rule was applied
[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     public void ruinSomeFoos( Foo a, Foo b ) {
46         a.x = b.x;
47     }
48 }
49
50
51 // this empty task should still create a non-empty
52 // ownership graph showing parameter allocation
53 // look for the parameter s as a label referencing
54 // a heap region that is multi-object, flagged, not summary
55 task Startup( StartupObject s{ initialstate } ) {
56     
57     
58     while( false ) {
59         Foo a = new Foo();
60         a.x   = new Foo();
61         a.x.x = new Foo();
62
63         //Foo z = a.x;
64         //z.x = new Foo();
65     }
66     
67
68
69     Foo d = new Foo();
70     Foo e = new Foo();
71     Foo f = new Foo();
72     Foo g = new Foo();
73
74     d.x = e;
75     e.x = f;
76     f.x = g;
77
78
79     Foo h = new Foo();
80     Foo i = new Foo();
81     Foo j = new Foo();
82     Foo k = new Foo();
83
84     j.x = k;
85     i.x = j;
86     h.x = i;
87
88
89     
90
91     // to look like Foo a above
92     //d.x.x = f;
93
94
95     Foo b;
96     while( false ) {
97         Foo c = new Foo();
98         c.x = b;
99         b = c;
100     }
101
102
103     taskexit( s{ !initialstate } );
104 }
105
106 /*
107 task NewObject( Foo a{ f }, Foo b{ f } ) {
108
109     Foo c = new Foo();
110
111     a.x = c;
112
113     taskexit( a{ !f }, b{ !f } );
114 }
115 */
116
117 /*
118 task NewObjectA( Foo a{ f }, Foo b{ f } ) {
119
120     Foo c = new Foo();
121     Foo d = new Foo();
122
123     c.x = d;
124     a.x = c;
125
126     taskexit( a{ !f }, b{ !f } );
127 }
128
129 task NewObjectB( Foo a{ f }, Foo b{ f } ) {
130
131     Foo c = new Foo();
132     Foo d = new Foo();
133
134     a.x = c;
135     c.x = d;
136
137     taskexit( a{ !f }, b{ !f } );
138 }
139 */
140
141 /*
142 task NewObject2( Foo a{ f }, Foo b{ f } ) {
143
144     Foo c;
145
146     while( false ) {
147         c   = new Foo();
148         c.x = new Foo();
149     }
150
151     taskexit( a{ !f }, b{ !f } );
152 }
153 */
154
155
156 /*
157 // this task allocates a new object, so there should
158 // be a heap region for the parameter, and several
159 // heap regions for the allocation site, but the label
160 // merely points to the newest region
161 task NewObject( Voo v{ f } ) {
162     Voo w = new Voo();
163     Baw b = new Baw();
164     b.doTheBaw( w );
165
166     taskexit( v{ !f } );
167 }
168
169
170 // this task 
171 task Branch( Voo v{ f } ) {
172     Voo w = new Voo();
173     Baw j = new Baw();
174     Baw k = new Baw();
175
176     if( v.x == 0 ) {
177         w.b = j;
178     } else {
179         w.b = k;
180     }
181
182     taskexit( v{ !f } );
183 }
184
185
186 task NoAliasNewInLoop( Voo v{ f } ) {
187
188     for( int i = 0; i < 10; ++i ) {
189         Voo w = new Voo();
190         w.b   = new Baw();
191         w.b.f = new Foo();
192     }
193
194     taskexit( v{ !f } );
195 }
196
197
198 task NoAliasNewInLoopAnotherWay( Voo v{ f } ) {
199
200     for( int i = 0; i < 10; ++i ) {
201         Voo w = new Voo();
202         Baw b = new Baw();
203         Foo f = new Foo();
204
205         w.b = b;
206         b.f = f;
207     }
208
209     taskexit( v{ !f } );
210 }
211
212
213 task ClobberInitParamReflex( Voo v{ f }, Voo w{ f } ) {
214     v.b = v.bb;
215
216     taskexit( v{ !f }, w{ !f } );
217 }
218 */