Beispiel #1
0
        public C2(SomeClass param)
        {
            Contract.Memory.BindRsd(rsdParam, param);
            Contract.Memory.Rsd<SomeClass>(rsdParam, 1);

            Contract.Memory.DestRsd(rsdParam);
            param = new SomeClass();
        }
        public SomeClass TestNewsTypes()
        {
            Contract.Memory.Tmp<SomeClass>(3);

            Contract.Memory.DestTmp();
            SomeClass s = new SomeClass();

            Contract.Memory.DestTmp();
            new SomeClass();

            Contract.Memory.DestRsd(Contract.Memory.Return);
            s = new SomeClass();

            s.Multiple();

            return s;
        }
        public SomeClass[] CuadTestDest2(int n, int m)
        {
            System.Diagnostics.Contracts.Contract.Requires(n >= 0);
            System.Diagnostics.Contracts.Contract.Requires(m >= 0);

            Contract.Memory.Rsd<SomeClass>(Contract.Memory.Return, n * m);
            Contract.Memory.Tmp<C1>(n);

            SomeClass[] elems = new SomeClass[n * m];

            for (int i = 0; i < n; i++)
            {
                Contract.Memory.IterationSpace(0 <= i && i < n);

                Contract.Memory.DestTmp();
                new C1();

                for (int j = 0; j < m; j++)
                {
                    Contract.Memory.IterationSpace(0 <= j && j < m);

                    Contract.Memory.DestRsd(Contract.Memory.Return);
                    elems[i * n + j] = new SomeClass();
                }
            }

            return elems;
        }
        public SomeClass[] CompleteRsd(int n)
        {
            ////exact bound!
            //System.Diagnostics.Contracts.Contract.Requires(n >= 1);
            //Contract.Memory.Rsd<SomeClass>(Contract.Memory.Return, n * n + 1 + n / 6 + (n * n) / 2 + (n * n * n) / 3 + n);

            ////upper bound
            //System.Diagnostics.Contracts.Contract.Requires(n >= 1);
            //Contract.Memory.Rsd<SomeClass>(Contract.Memory.Return, n * n * n + 2 * n * n + 2 * n + 1);

            //upper bound with conditions
            System.Diagnostics.Contracts.Contract.Requires(n >= 0);
            Contract.Memory.Rsd<SomeClass>(Contract.Memory.Return, 1, n == 0);
            Contract.Memory.Rsd<SomeClass>(Contract.Memory.Return, n * n * n + 2 * n * n + 2 * n, n >= 1);

            SomeClass[] r = new SomeClass[1];

            Contract.Memory.AddRsd(Contract.Memory.Return, Contract.Memory.Return);
            r = CuadTestDest2(n, n); //cant_transf_1 --> n * n

            Contract.Memory.DestRsd(Contract.Memory.Return);
            r[0] = new SomeClass(); //cant_directa --> 1

            for (int i = 1; i <= n; i++)
            {
                Contract.Memory.IterationSpace(1 <= i && i <= n);

                Contract.Memory.AddRsd(Contract.Memory.Return, Contract.Memory.Return);
                r = CuadTestDest2(i, i); //cant_transf_loop_1 --> n / 6 + (n * n) / 2 + (n * n * n) / 3

                Contract.Memory.DestRsd(Contract.Memory.Return);
                r[0] = new SomeClass(); //cant_directa_loop_1 --> n
            }

            return r;
        }
        public SomeClass UseRsds(SomeClass ppp)
        {
            Contract.Memory.BindRsd(rsdPpp, ppp);

            Contract.Memory.AddRsd(Contract.Memory.Return, Contract.Memory.Return);
            SomeClass s = RsdRet();

            Contract.Memory.AddRsd(Contract.Memory.Return, Contract.Memory.Return);
            s = RsdRet();

            Contract.Memory.AddRsd(Contract.Memory.Return, Contract.Memory.Return);
            this.attrPub = RsdRet();

            Contract.Memory.AddRsd(Contract.Memory.Return, Contract.Memory.Return);
            attrPub = RsdRet();

            Contract.Memory.AddRsd(Contract.Memory.Return, Contract.Memory.This);
            s.RsdThis();

            Contract.Memory.AddRsd(Contract.Memory.This, Contract.Memory.This);
            this.RsdThis();

            Contract.Memory.AddRsd(Contract.Memory.This, Contract.Memory.This);
            RsdThis();

            Contract.Memory.AddRsd(Contract.Memory.This, Contract.Memory.This);
            attrPub.RsdThis();

            Contract.Memory.AddRsd(Contract.Memory.This, Contract.Memory.This);
            this.attrPub.RsdThis();

            Contract.Memory.AddRsd(Contract.Memory.Return, Contract.Memory.This);
            s = attrPub.RsdRet();

            Contract.Memory.AddRsd(Contract.Memory.Return, Contract.Memory.This);
            Contract.Memory.AddRsd(Contract.Memory.Return, Contract.Memory.Return);
            s = this.attrPub.RsdRet();

            ///

            Contract.Memory.AddRsd(Contract.Memory.Return, rsdAttr);
            s.RsdThisAttr();

            Contract.Memory.AddRsd(Contract.Memory.This, rsdAttr);
            RsdThisAttr();

            Contract.Memory.AddRsd(Contract.Memory.This, rsdAttr);
            this.RsdThisAttr();

            SomeClass t;

            Contract.Memory.AddRsd(Contract.Memory.This, rsdAttr);
            t = RsdThisAttr();

            Contract.Memory.AddRsd(Contract.Memory.This, rsdAttr);
            t = this.RsdThisAttr();

            Contract.Memory.AddRsd(Contract.Memory.Return, rsdParam_p);
            RsdParam(s);

            Contract.Memory.AddRsd(Contract.Memory.Return, rsdParam_p);
            RsdParamAttr(t, s);

            Contract.Memory.AddTmp(Contract.Memory.This);
            SomeClass s2 = new SomeClass();

            Contract.Memory.AddRsd(Contract.Memory.Return, C2.rsdParam);
            C2 c = new C2(s);

            Contract.Memory.AddRsd(rsdPpp, Contract.Memory.Return);
            ppp.attrPub = RsdRet();

            return s;
        }
 public void RsdDest()
 {
     Contract.Memory.AddRsd(Contract.Memory.This, Contract.Memory.Return);
     //Contract.Memory.AddRsd(Contract.Memory.Return, Contract.Memory.Return); //fails
     this.attrPub = RsdRet();
 }
 public void RsdParam(SomeClass p)
 {
     Contract.Memory.BindRsd(rsdParam_p, p);
     Contract.Memory.Rsd<SomeClass>(rsdParam_p, 1);
     Contract.Memory.DestRsd(rsdParam_p);
     p = new SomeClass();
 }
 public void RsdParamAttr(SomeClass p, SomeClass q)
 {
     Contract.Memory.BindRsd(rsdParam_p, q.attrPub);
     Contract.Memory.Rsd<SomeClass>(rsdParam_p, 1);
     Contract.Memory.DestRsd(rsdParam_p);
     q.attrPub = new SomeClass();
 }
        public void EscapeFieldTest(SomeClass param)
        {
            Contract.Memory.BindRsd(rsdField, this.Field);
            Contract.Memory.Rsd<SomeClass>(rsdField, 1);

            Contract.Memory.DestRsd(rsdField);
            this.Field = new SomeClass();

            Contract.Memory.BindRsd(rsdParam, param._Field.Field);
            Contract.Memory.Rsd<SomeClass>(rsdParam, 1);

            Contract.Memory.DestRsd(rsdParam);
            param.Field.Field = new SomeClass();
        }
        public SomeClass TestTmps()
        {
            Contract.Memory.DestRsd(Contract.Memory.This);
            this.attr = new SomeClass();

            Contract.Memory.DestRsd(Contract.Memory.This);
            this.attrPub = new SomeClass();

            Contract.Memory.DestTmp();
            SomeClass s = new SomeClass();

            s.Simple();

            Contract.Memory.DestTmp();
            s = new SomeClass();

            Contract.Memory.DestTmp(true); //bug, use trust
            s.attr = new SomeClass();

            Contract.Memory.DestTmp(true); //bug, use trust
            s.attrPub = new SomeClass();

            return null;
        }
 public SomeClass M3()
 {
     Contract.Memory.DestRsd(Contract.Memory.Return);
     SomeClass s = new SomeClass();
     Contract.Memory.DestRsd(Contract.Memory.Return);
     SomeClass t = new SomeClass();
     s.attrPub = t;
     return s;
 }
        public SomeClass TestRsdAttr()
        {
            Contract.Memory.BindRsd(rsdType, this._attr2);

            Contract.Memory.DestRsd(rsdType);
            this.attr2 = new SomeClass();

            return null;
        }
 public SomeClass M1()
 {
     Contract.Memory.DestTmp();
     SomeClass s = new SomeClass();
     Contract.Memory.DestRsd(Contract.Memory.Return);
     s.attrPub = new SomeClass();
     return s.attrPub;
 }
        public void TestExprs()
        {
            Contract.Memory.DestRsd(Contract.Memory.This);
            this.attrPub.attrPub = new SomeClass();

            Contract.Memory.DestRsd(Contract.Memory.This);
            this.attrPub = new SomeClass();

            Contract.Memory.DestRsd(Contract.Memory.This);
            this.attr = new SomeClass();

            Contract.Memory.DestRsd(Contract.Memory.This);
            this.attr.attr = new SomeClass();

            Contract.Memory.DestRsd(Contract.Memory.This);
            this.attrPub.attr = new SomeClass();

            Contract.Memory.DestRsd(Contract.Memory.This);
            this.attr.attrPub = new SomeClass();

            SomeClass s = new SomeClass();

            Contract.Memory.DestTmp(true); //bug, use trust
            s.attrPub = new SomeClass();

            Contract.Memory.DestTmp(true); //bug, use trust
            s.attrPub.attr = new SomeClass();

            Contract.Memory.DestTmp(true); //bug, use trust
            s.attr.attrPub = new SomeClass();
        }
        public SomeClass TestEscapeStatic()
        {
            Contract.Memory.DestRsd(null);
            SomeClass.staticAttr = new SomeClass();

            Contract.Memory.DestRsd(null);
            staticAttr = new SomeClass();

            Contract.Memory.DestRsd(null);
            C1.attr = new SomeClass();

            Contract.Memory.DestRsd(Contract.Memory.Return);
            return new SomeClass();
        }
        public void ConsExpr3(SomeClass s)
        {
            Contract.Memory.Tmp<SomeClass>(s.intProp);

            s.intProp = 5;

            for (int i = 1; i <= s.intProp; i++)
            {
                Contract.Memory.IterationSpace(1 <= i && i <= s.intProp);

                Contract.Memory.DestTmp();
                new SomeClass();
            }
        }
        public void TestRsd(SomeClass s)
        {
            Contract.Memory.BindRsd(rsdParam, s);
            Contract.Memory.Rsd<SomeClass>(rsdParam, 1);

            Contract.Memory.DestRsd(rsdParam);
            s.attr = new SomeClass();
        }
 public void RsdThis()
 {
     Contract.Memory.Rsd<SomeClass>(Contract.Memory.This, 1);
     Contract.Memory.DestRsd(Contract.Memory.This);
     this.attrPub = new SomeClass();
 }
        public SomeClass TestRsd2()
        {
            Contract.Memory.Tmp<SomeClass>(2);
            Contract.Memory.Rsd<SomeClass>(Contract.Memory.Return, 2);

            Contract.Memory.DestTmp(true); //bug, use trust
            SomeClass s = new SomeClass();

            Contract.Memory.AddTmp(rsdParam, true); //bug, use trust
            TestRsd(s);

            Contract.Memory.DestRsd(Contract.Memory.Return);
            SomeClass s2 = new SomeClass();

            Contract.Memory.AddRsd(Contract.Memory.Return, rsdParam);
            s2.TestRsd(s2);

            return s2;
        }
        public void ConsDepField2(SomeClass s)
        {
            Contract.Memory.Tmp<SomeClass>(s.IntField2 * s.IntField2);

            for (int i = 1; i <= s.IntField2; i++)
            {
                Contract.Memory.IterationSpace(1 <= i && i <= s.IntField2);
                for (int j = 1; j <= s.IntField2; j++)
                {
                    Contract.Memory.IterationSpace(1 <= j && j <= s.IntField2);
                    Contract.Memory.DestTmp();
                    new SomeClass();
                }
            }
        }
        public SomeClass RsdThisAttr()
        {
            Contract.Memory.BindRsd(rsdAttr, this.attrPub);
            Contract.Memory.Rsd<SomeClass>(rsdAttr, 1);
            Contract.Memory.DestRsd(rsdAttr);
            this.attrPub = new SomeClass();

            return null;
        }