コード例 #1
0
ファイル: C2.cs プロジェクト: tapicer/resource-contracts-.net
        public C2(SomeClass param)
        {
            Contract.Memory.BindRsd(rsdParam, param);
            Contract.Memory.Rsd<SomeClass>(rsdParam, 1);

            Contract.Memory.DestRsd(rsdParam);
            param = new SomeClass();
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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;
        }
コード例 #5
0
        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;
        }
コード例 #6
0
 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();
 }
コード例 #7
0
 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();
 }
コード例 #8
0
 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();
 }
コード例 #9
0
        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();
        }
コード例 #10
0
        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;
        }
コード例 #11
0
 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;
 }
コード例 #12
0
        public SomeClass TestRsdAttr()
        {
            Contract.Memory.BindRsd(rsdType, this._attr2);

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

            return null;
        }
コード例 #13
0
 public SomeClass M1()
 {
     Contract.Memory.DestTmp();
     SomeClass s = new SomeClass();
     Contract.Memory.DestRsd(Contract.Memory.Return);
     s.attrPub = new SomeClass();
     return s.attrPub;
 }
コード例 #14
0
        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();
        }
コード例 #15
0
        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();
        }
コード例 #16
0
        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();
            }
        }
コード例 #17
0
        public void TestRsd(SomeClass s)
        {
            Contract.Memory.BindRsd(rsdParam, s);
            Contract.Memory.Rsd<SomeClass>(rsdParam, 1);

            Contract.Memory.DestRsd(rsdParam);
            s.attr = new SomeClass();
        }
コード例 #18
0
 public void RsdThis()
 {
     Contract.Memory.Rsd<SomeClass>(Contract.Memory.This, 1);
     Contract.Memory.DestRsd(Contract.Memory.This);
     this.attrPub = new SomeClass();
 }
コード例 #19
0
        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;
        }
コード例 #20
0
        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();
                }
            }
        }
コード例 #21
0
        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;
        }