7c3e770fe8a829b7420610a4e7ab8473ea97cc57
[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
63     taskexit( s{ !initialstate } );
64 }
65
66
67 task NewObject( Foo a{ f }, Foo b{ f } ) {
68
69     Foo c = new Foo();
70
71     a.x = c;
72
73     taskexit( a{ !f }, b{ !f } );
74 }
75
76
77
78 /*
79 // this task allocates a new object, so there should
80 // be a heap region for the parameter, and several
81 // heap regions for the allocation site, but the label
82 // merely points to the newest region
83 task NewObject( Voo v{ f } ) {
84     Voo w = new Voo();
85     Baw b = new Baw();
86     b.doTheBaw( w );
87
88     taskexit( v{ !f } );
89 }
90
91
92 // this task 
93 task Branch( Voo v{ f } ) {
94     Voo w = new Voo();
95     Baw j = new Baw();
96     Baw k = new Baw();
97
98     if( v.x == 0 ) {
99         w.b = j;
100     } else {
101         w.b = k;
102     }
103
104     taskexit( v{ !f } );
105 }
106
107
108 task NoAliasNewInLoop( Voo v{ f } ) {
109
110     for( int i = 0; i < 10; ++i ) {
111         Voo w = new Voo();
112         w.b   = new Baw();
113         w.b.f = new Foo();
114     }
115
116     taskexit( v{ !f } );
117 }
118
119
120 task NoAliasNewInLoopAnotherWay( Voo v{ f } ) {
121
122     for( int i = 0; i < 10; ++i ) {
123         Voo w = new Voo();
124         Baw b = new Baw();
125         Foo f = new Foo();
126
127         w.b = b;
128         b.f = f;
129     }
130
131     taskexit( v{ !f } );
132 }
133
134
135 task ClobberInitParamReflex( Voo v{ f }, Voo w{ f } ) {
136     v.b = v.bb;
137
138     taskexit( v{ !f }, w{ !f } );
139 }
140 */