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