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