Fixed x.f = y operation
[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     while( false ) {
58         Foo a = new Foo();
59         a.x   = new Foo();
60         a.x.x = new Foo();
61
62         //Foo z = a.x;
63         //z.x = new Foo();
64     }
65     
66     Foo d = new Foo();
67     Foo e = new Foo();
68     Foo f = new Foo();
69
70     d.x = e;
71     e.x = f;    
72
73     // to look like Foo a above
74     //d.x.x = f;
75
76
77     /*
78     Foo b;
79     while( false ) {
80         Foo c = new Foo();
81         c.x = b;
82         b = c;
83     }
84     */
85
86     taskexit( s{ !initialstate } );
87 }
88
89 /*
90 task NewObject( Foo a{ f }, Foo b{ f } ) {
91
92     Foo c = new Foo();
93
94     a.x = c;
95
96     taskexit( a{ !f }, b{ !f } );
97 }
98 */
99
100 /*
101 task NewObjectA( Foo a{ f }, Foo b{ f } ) {
102
103     Foo c = new Foo();
104     Foo d = new Foo();
105
106     c.x = d;
107     a.x = c;
108
109     taskexit( a{ !f }, b{ !f } );
110 }
111
112 task NewObjectB( Foo a{ f }, Foo b{ f } ) {
113
114     Foo c = new Foo();
115     Foo d = new Foo();
116
117     a.x = c;
118     c.x = d;
119
120     taskexit( a{ !f }, b{ !f } );
121 }
122 */
123
124 /*
125 task NewObject2( Foo a{ f }, Foo b{ f } ) {
126
127     Foo c;
128
129     while( false ) {
130         c   = new Foo();
131         c.x = new Foo();
132     }
133
134     taskexit( a{ !f }, b{ !f } );
135 }
136 */
137
138
139 /*
140 // this task allocates a new object, so there should
141 // be a heap region for the parameter, and several
142 // heap regions for the allocation site, but the label
143 // merely points to the newest region
144 task NewObject( Voo v{ f } ) {
145     Voo w = new Voo();
146     Baw b = new Baw();
147     b.doTheBaw( w );
148
149     taskexit( v{ !f } );
150 }
151
152
153 // this task 
154 task Branch( Voo v{ f } ) {
155     Voo w = new Voo();
156     Baw j = new Baw();
157     Baw k = new Baw();
158
159     if( v.x == 0 ) {
160         w.b = j;
161     } else {
162         w.b = k;
163     }
164
165     taskexit( v{ !f } );
166 }
167
168
169 task NoAliasNewInLoop( Voo v{ f } ) {
170
171     for( int i = 0; i < 10; ++i ) {
172         Voo w = new Voo();
173         w.b   = new Baw();
174         w.b.f = new Foo();
175     }
176
177     taskexit( v{ !f } );
178 }
179
180
181 task NoAliasNewInLoopAnotherWay( Voo v{ f } ) {
182
183     for( int i = 0; i < 10; ++i ) {
184         Voo w = new Voo();
185         Baw b = new Baw();
186         Foo f = new Foo();
187
188         w.b = b;
189         b.f = f;
190     }
191
192     taskexit( v{ !f } );
193 }
194
195
196 task ClobberInitParamReflex( Voo v{ f }, Voo w{ f } ) {
197     v.b = v.bb;
198
199     taskexit( v{ !f }, w{ !f } );
200 }
201 */