Altered ownership graph to dot file by removing label nodes, marking allocation
[IRC.git] / Robust / src / Tests / OwnershipAnalysisTest / test01 / test01.java
index 1eff12beb93cede0773f779b84c141fd394b8a5d..26050fc7c51ab6468bd73bd9f66760f63e2fd41b 100644 (file)
-public class Thing { int z; public Thing(){} }
 
-public class P1 {
-    public P1(){}
-    flag a;
-    int x;
-    Thing m;
+public class Parameter {
+    flag w;
+    int a, b;
+    Parameter f, g;
+    Penguin penguin;
+
+    public Parameter() { a = 0; b = 0; f = null; g = null; }
+
+    public void bar() { foo(); }
+    public void foo() { bar(); }
+}
+
+public class Penguin {
+    int x, y;
+
+    public Penguin() { x = 0; y = 0; }
+
+    public void bar() { x = 1; }
 }
 
-public class P2 {
-    public P2(){}
-    flag b;
-    int y;
-    Thing n;
+public class Voo {
+    flag f; int x; Baw b; Baw bb;
+
+    public Voo() {}
+}
+
+public class Baw {
+    flag g; int y;
+    Foo f;
+
+    public Baw() {}
+
+    public void doTheBaw( Voo v ) { v = new Voo(); }
+}
+
+
+public class Foo {
+    public Foo() {}
+
+    public Foo x;
+
+    public void ruinSomeFoos( Foo a, Foo b ) {
+       a.x = b.x;
+    }
 }
 
+// this empty task should still create a non-empty
+// ownership graph showing parameter allocation
+// look for the parameter s as a label referencing
+// a heap region that is multi-object, flagged, not summary
 task Startup( StartupObject s{ initialstate } ) {
-    P1 p1 = new P1(){};
-    P2 p2 = new P2(){};
+    Foo a = new Foo();
+    Foo b = new Foo();
+    Foo c = new Foo();
+    
+    c.ruinSomeFoos( a, b );
+
     taskexit( s{ !initialstate } );
 }
 
+// this task allocates a new object, so there should
+// be a heap region for the parameter, and several
+// heap regions for the allocation site, but the label
+// merely points to the newest region
+
+task NewObject( Voo v{ f } ) {
+    Voo w = new Voo();
+    Baw b = new Baw();
+    b.doTheBaw( w );
+
+    taskexit( v{ !f } );
+}
+
+// this task 
+task Branch( Voo v{ f } ) {
+    Voo w = new Voo();
+    Baw j = new Baw();
+    Baw k = new Baw();
+
+    if( v.x == 0 ) {
+       w.b = j;
+    } else {
+       w.b = k;
+    }
+
+    taskexit( v{ !f } );
+}
+
+
+task NoAliasNewInLoop( Voo v{ f } ) {
+    Voo w = new Voo();
+
+    for( int i = 0; i < 10; ++i ) {
+       w.b = new Baw();
+       w.b.f = new Foo();
+    }
+
+    taskexit( v{ !f } );
+}
+
 
-task A( P1 p1{!a}, P2 p2{!b} )
-{
-    p1.m = p2.n;
+task ClobberInitParamReflex( Voo v{ f }, Voo w{ f } ) {
+    v.b = v.bb;
 
-    taskexit( p1{a}, p2{b} );
+    taskexit( v{ !f }, w{ !f } );
 }
\ No newline at end of file