Esempio n. 1
0
        ////////////////////////////////////////////////////////////////////////////

        private VCExpr AssembleOpExpression(OpTypesPair opTypes, IEnumerable <VCExpr /*!*/> /*!*/ oldArgs, VariableBindings bindings)
        {
            Contract.Requires(bindings != null);
            Contract.Requires(cce.NonNullElements(oldArgs));
            Contract.Ensures(Contract.Result <VCExpr>() != null);
            // UGLY: the code for tracking polarities should be factored out
            int oldPolarity = Eraser.Polarity;

            Eraser.Polarity = 0;

            List <VCExpr /*!*/> /*!*/ newArgs = new List <VCExpr /*!*/> ();

            // explicit type parameters
            foreach (Type /*!*/ t in opTypes.Types)
            {
                Contract.Assert(newArgs != null);
                newArgs.Add(AxBuilder.Type2Term(t, bindings.TypeVariableBindings));
            }

            // and the actual value parameters
            Function /*!*/ newFun = ((VCExprBoogieFunctionOp)opTypes.Op).Func;
            // ^ we only allow this operator at this point
            int i = opTypes.Types.Count;

            foreach (VCExpr /*!*/ arg in oldArgs)
            {
                Contract.Assert(arg != null);
                newArgs.Add(AxBuilder.Cast(Eraser.Mutate(arg, bindings),
                                           cce.NonNull(newFun.InParams[i]).TypedIdent.Type));
                i = i + 1;
            }

            Eraser.Polarity = oldPolarity;
            return(Gen.Function(opTypes.Op, newArgs));
        }
Esempio n. 2
0
        public override VCExpr VisitSubtypeOp(VCExprNAry node, VariableBindings bindings)
        {
            Contract.Requires((bindings != null));
            Contract.Requires((node != null));
            Contract.Ensures(Contract.Result <VCExpr>() != null);
            // UGLY: the code for tracking polarities should be factored out
            int oldPolarity = Eraser.Polarity;

            Eraser.Polarity = 0;

            VCExpr /*!*/ res =
                Gen.Function(VCExpressionGenerator.Subtype3Op,
                             AxBuilder.Type2Term(node[0].Type,
                                                 bindings.TypeVariableBindings),
                             AxBuilder.Cast(Eraser.Mutate(node[0], bindings),
                                            AxBuilder.U),
                             AxBuilder.Cast(Eraser.Mutate(node[1], bindings),
                                            AxBuilder.U));

            Eraser.Polarity = oldPolarity;
            return(res);
        }