private void LiteralArgumentAnalyser(Procedure p, int arg) { LiteralExpr literal = null; foreach (CallCmd callCmd in CallSites[p]) { if (callCmd.Ins[arg] == null || !(callCmd.Ins[arg] is LiteralExpr)) { return; } LiteralExpr l = callCmd.Ins[arg] as LiteralExpr; if (literal == null) { literal = l; } else if (!literal.Equals(l)) { return; } } Expr e; e = new IdentifierExpr(Token.NoToken, p.InParams[arg]); e = Expr.Eq(e, literal); p.Requires.Add(new Requires(false, e)); }
public void LiteralReal() { var constant = new LiteralExpr(Token.NoToken, BigDec.FromString("11.7")); // Real var constant2 = new LiteralExpr(Token.NoToken, BigDec.FromString("11.7")); // Real Assert.AreNotSame(constant, constant2); // These are different references Assert.IsTrue(constant.Equals(constant2)); // These are "structurally equal" Assert.AreEqual(constant.GetHashCode(), constant2.GetHashCode()); // If the .Equals() is true then hash codes must be the same }
public void LiteralInt() { var constant = new LiteralExpr(Token.NoToken, BigNum.FromInt(18)); // Integer var constant2 = new LiteralExpr(Token.NoToken, BigNum.FromInt(18)); // Integer Assert.AreNotSame(constant, constant2); // These are different references Assert.IsTrue(constant.Equals(constant2)); // These are "structurally equal" Assert.AreEqual(constant.GetHashCode(), constant2.GetHashCode()); // If the .Equals() is true then hash codes must be the same }