internal Bpl.Expr BplBvLiteralExpr(Bpl.IToken tok, BaseTypes.BigNum n, int width) { Contract.Requires(tok != null); Contract.Requires(0 <= width); if (width == 0) { // see comment in BplBvType Contract.Assert(n.IsZero); return(Bpl.Expr.Literal(0)); } else if (n.IsNegative) { // This can only happen if some error is reported elsewhere. Nevertheless, we do need to // generate a Boogie expression and Boogie would crash if we pass a negative number to // Bpl.LiteralExpr for a bitvector. var zero = new Bpl.LiteralExpr(tok, BaseTypes.BigNum.ZERO, width); var absN = new Bpl.LiteralExpr(tok, -n, width); var etran = new ExpressionTranslator(this, predef, tok); return(etran.TrToFunctionCall(tok, "sub_bv" + width, BplBvType(width), zero, absN, false)); } else { return(new Bpl.LiteralExpr(tok, n, width)); } }