Example #1
0
        /////////////////////////////////////////////////////////////////////////////////////

        public bool Visit(VCExprLiteral node, LineariserOptions options)
        {
            if (node == VCExpressionGenerator.True)
            {
                wr.Write("true");
            }
            else if (node == VCExpressionGenerator.False)
            {
                wr.Write("false");
            }
            else if (node is VCExprIntLit)
            {
                BigNum lit = ((VCExprIntLit)node).Val;
                if (lit.IsNegative)
                {
                    // In SMT2 "-42" is an identifier (SMT2, Sect. 3.2 "Symbols")
                    wr.Write("(- 0 {0})", lit.Abs);
                }
                else
                {
                    wr.Write(lit);
                }
            }
            else if (node is VCExprRealLit)
            {
                BigDec lit = ((VCExprRealLit)node).Val;
                if (lit.IsNegative)
                {
                    // In SMT2 "-42" is an identifier (SMT2, Sect. 3.2 "Symbols")
                    wr.Write("(- 0.0 {0})", lit.Abs.ToDecimalString());
                }
                else
                {
                    wr.Write(lit.ToDecimalString());
                }
            }
            else if (node is VCExprFloatLit)
            {
                BigFloat lit = ((VCExprFloatLit)node).Val;
                wr.Write("(" + lit.ToBVString() + ")");
            }
            else if (node is VCExprRModeLit)
            {
                RoundingMode lit = ((VCExprRModeLit)node).Val;
                wr.Write(lit.ToString());
            }
            else if (node is VCExprStringLit)
            {
                String lit = ((VCExprStringLit)node).Val;
                wr.Write("\"" + lit.ToString() + "\"");
            }
            else
            {
                Contract.Assert(false);
                throw new cce.UnreachableException();
            }

            return(true);
        }