Altered ownership graph to dot file by removing label nodes, marking allocation
[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     flag g; 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     public Foo() {}
40
41     public Foo x;
42
43     public void ruinSomeFoos( Foo a, Foo b ) {
44         a.x = b.x;
45     }
46 }
47
48 // this empty task should still create a non-empty
49 // ownership graph showing parameter allocation
50 // look for the parameter s as a label referencing
51 // a heap region that is multi-object, flagged, not summary
52 task Startup( StartupObject s{ initialstate } ) {
53  
54     Foo a = new Foo();
55     Foo b = new Foo();
56     Foo c = new Foo();
57     
58     c.ruinSomeFoos( a, b );
59
60     taskexit( s{ !initialstate } );
61 }
62
63 // this task allocates a new object, so there should
64 // be a heap region for the parameter, and several
65 // heap regions for the allocation site, but the label
66 // merely points to the newest region
67
68 task NewObject( Voo v{ f } ) {
69     Voo w = new Voo();
70     Baw b = new Baw();
71     b.doTheBaw( w );
72
73     taskexit( v{ !f } );
74 }
75
76 // this task 
77 task Branch( Voo v{ f } ) {
78     Voo w = new Voo();
79     Baw j = new Baw();
80     Baw k = new Baw();
81
82     if( v.x == 0 ) {
83         w.b = j;
84     } else {
85         w.b = k;
86     }
87
88     taskexit( v{ !f } );
89 }
90
91
92 task NoAliasNewInLoop( Voo v{ f } ) {
93     Voo w = new Voo();
94
95     for( int i = 0; i < 10; ++i ) {
96         w.b = new Baw();
97         w.b.f = new Foo();
98     }
99
100     taskexit( v{ !f } );
101 }
102
103
104 task ClobberInitParamReflex( Voo v{ f }, Voo w{ f } ) {
105     v.b = v.bb;
106
107     taskexit( v{ !f }, w{ !f } );
108 }