483c3e31950b3e2d42f938319a096631af92e815
[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
23 /*
24 public class Voo {
25     flag f; int x; Baw b;
26
27     public Voo() {}
28 }
29
30 public class Baw {
31     flag g; int y;
32
33     public Baw() {}
34
35     public void doTheBaw( Voo v ) { v = new Voo(); }
36 }
37 */
38
39 public class Foo {
40     public Foo() {}
41
42     public Foo x;
43
44     public void ruinSomeFoos( Foo a, Foo b ) {
45         a.x = b.x;
46     }
47 }
48
49 // this empty task should still create a non-empty
50 // ownership graph showing parameter allocation
51 // look for the parameter s as a label referencing
52 // a heap region that is multi-object, flagged, not summary
53 task Startup( StartupObject s{ initialstate } ) {
54  
55     Foo a = new Foo();
56     Foo b = new Foo();
57     Foo c = new Foo();
58     
59     c.ruinSomeFoos( a, b );
60
61     taskexit( s{ !initialstate } );
62 }
63
64 // this task allocates a new object, so there should
65 // be a heap region for the parameter, and several
66 // heap regions for the allocation site, but the label
67 // merely points to the newest region
68 /*
69 task NewObject( Voo v{ f } ) {
70     Voo w = new Voo();
71     Baw b = new Baw();
72     b.doTheBaw( w );
73
74     taskexit( v{ !f } );
75 }
76
77 // this task 
78 task Branch( Voo v{ f } ) {
79     Voo w = new Voo();
80     Baw j = new Baw();
81     Baw k = new Baw();
82
83     if( v.x == 0 ) {
84         w.b = j;
85     } else {
86         w.b = k;
87     }
88
89     taskexit( v{ !f } );
90 }
91
92
93 task NewInLoop( Voo v{ f } ) {
94     Voo w = new Voo();
95
96     for( int i = 0; i < 10; ++i ) {
97         w.b = new Baw();
98     }
99
100     taskexit( v{ !f } );
101 }
102 */