Ejemplo n.º 1
0
        public bool Visit(VCExprNAry node, TextWriter wr)
        {
            //Contract.Requires(wr != null);
            //Contract.Requires(node != null);
            VCExprOp /*!*/ op = node.Op;

            Contract.Assert(op != null);

            if (op.Equals(VCExpressionGenerator.AndOp) ||
                op.Equals(VCExpressionGenerator.OrOp))
            {
                // handle these operators without recursion

                wr.Write("({0}",
                         op.Equals(VCExpressionGenerator.AndOp) ? "And" : "Or");
                IEnumerator /*!*/ enumerator = new VCExprNAryUniformOpEnumerator(node);
                Contract.Assert(enumerator != null);
                while (enumerator.MoveNext())
                {
                    VCExprNAry naryExpr = enumerator.Current as VCExprNAry;
                    if (naryExpr == null || !naryExpr.Op.Equals(op))
                    {
                        wr.Write(" ");
                        Print(cce.NonNull((VCExpr /*!*/)enumerator.Current), wr);
                    }
                }

                wr.Write(")");

                return(true);
            }

            return(node.Accept <bool, TextWriter /*!*/>(OpPrinter, wr));
        }
Ejemplo n.º 2
0
        public Term Visit(VCExprNAry node, LineariserOptions options)
        {
            Contract.Requires(options != null);
            Contract.Requires(node != null);
            VCExprOp op = node.Op;

            Contract.Assert(op != null);

            if (op.Equals(VCExpressionGenerator.AndOp) || op.Equals(VCExpressionGenerator.OrOp))
            {
                // handle these operators without recursion
                List <Term> asts     = new List <Term>();
                string      opString = op.Equals(VCExpressionGenerator.AndOp) ? "AND" : "OR";

                IEnumerator enumerator = new VCExprNAryUniformOpEnumerator(node);
                Contract.Assert(enumerator != null);
                while (enumerator.MoveNext())
                {
                    VCExprNAry naryExpr = enumerator.Current as VCExprNAry;
                    if (naryExpr == null || !naryExpr.Op.Equals(op))
                    {
                        asts.Add(Linearise(cce.NonNull((VCExpr)enumerator.Current), options));
                    }
                }

                return(Make(op, asts));
            }

            return(node.Accept <Term, LineariserOptions>(OpLineariser, options));
        }
Ejemplo n.º 3
0
        /////////////////////////////////////////////////////////////////////////////////////

        public bool Visit(VCExprNAry node, LineariserOptions options)
        {
            //Contract.Requires(options != null);
            //Contract.Requires(node != null);
            VCExprOp op = node.Op;

            Contract.Assert(op != null);

            if (!options.AsTerm &&
                (op.Equals(VCExpressionGenerator.AndOp) ||
                 op.Equals(VCExpressionGenerator.OrOp)))
            {
                // handle these operators without recursion

                wr.Write("({0}",
                         op.Equals(VCExpressionGenerator.AndOp) ? andName : orName);
                IEnumerator enumerator = new VCExprNAryUniformOpEnumerator(node);
                Contract.Assert(enumerator != null);
                while (enumerator.MoveNext())
                {
                    VCExprNAry naryExpr = enumerator.Current as VCExprNAry;
                    if (naryExpr == null || !naryExpr.Op.Equals(op))
                    {
                        wr.Write(" ");
                        Linearise(cce.NonNull((VCExpr)enumerator.Current), options);
                    }
                }

                wr.Write(")");

                return(true);
            }

            return(node.Accept <bool, LineariserOptions>(OpLineariser, options));
        }
Ejemplo n.º 4
0
        /////////////////////////////////////////////////////////////////////////////////////

        public bool Visit(VCExprNAry node, LineariserOptions options)
        {
            //Contract.Requires(node != null);
            //Contract.Requires(options != null);

            VCExprOp op = node.Op;

            Contract.Assert(op != null);

            if (op.Equals(VCExpressionGenerator.AndOp) ||
                op.Equals(VCExpressionGenerator.OrOp))
            {
                // handle these operators without recursion

                wr.Write("({0}",
                         op.Equals(VCExpressionGenerator.AndOp) ? "and" : "or");
                foreach (var ch in node.UniformArguments)
                {
                    wr.Write("\n");
                    Linearise(ch, options);
                }
                wr.Write(")");

                return(true);
            }

            return(node.Accept <bool, LineariserOptions /*!*/>(OpLineariser, options));
        }
Ejemplo n.º 5
0
 private Cluster Merge(Cluster a, Cluster b)
 {
   AntiUnificationVisitor /*!*/
     visitor = new AntiUnificationVisitor(Gen);
   VCExpr /*!*/
     generator = visitor.AntiUnify(a.Generator, b.Generator);
   Contract.Assert(generator != null);
   VCExprNAry generatorNAry = generator as VCExprNAry;
   Contract.Assert(generatorNAry != null && Op.Equals(generatorNAry.Op));
   return new Cluster(generatorNAry, a.Size + b.Size);
 }