Beispiel #1
0
        public void nestedNots(int depth)
        {
            var  pair     = GetVarAndIdExpr("foo", BasicType.GetBvType(8));
            var  variable = pair.Item1;
            var  id       = pair.Item2;
            var  cfb      = GetConstantFoldingBuilder();
            Expr result   = id;

            for (int i = 0; i < depth; ++i)
            {
                result = cfb.BVNOT(result);
                CheckIsBvType(result, 8);
            }

            if (depth % 2 == 0)
            {
                Assert.AreSame(id, result);
            }
            else
            {
                var asBvNot = ExprUtil.AsBVNOT(result);
                Assert.IsNotNull(asBvNot);
                Assert.AreSame(id, asBvNot.Args[0]);
            }
        }
Beispiel #2
0
        public void XorWithAllOnes()
        {
            var cfb     = GetConstantFoldingBuilder();
            var id      = GetVarAndIdExpr("x", BasicType.GetBvType(8)).Item2;
            var allOnes = cfb.ConstantBV(255, 8);
            var result  = cfb.BVXOR(id, allOnes);

            CheckIsBvType(result, 8);
            var resultAsBvNot = ExprUtil.AsBVNOT(result);

            Assert.IsNotNull(resultAsBvNot);
            Assert.AreSame(id, resultAsBvNot.Args[0]);
        }
Beispiel #3
0
        public void noFold()
        {
            var pair         = GetSimpleAndConstantFoldingBuilder();
            var sb           = pair.Item1;
            var cfb          = pair.Item2;
            var id           = GetVarAndIdExpr("foo", BasicType.GetBvType(8)).Item2;
            var foldedResult = cfb.BVNOT(id);
            var simpleResult = sb.BVNOT(id);

            CheckIsBvType(simpleResult, 8);
            CheckIsBvType(foldedResult, 8);
            Assert.AreEqual(simpleResult, foldedResult);

            var asBvNot = ExprUtil.AsBVNOT(foldedResult);

            Assert.IsNotNull(asBvNot);
            Assert.AreSame(id, asBvNot.Args[0]);
        }