Exemplo n.º 1
0
        public void AsBVZEXTNotWithoutBVZEXT()
        {
            var sb       = GetSimpleBuilder();
            var v        = GetVarAndIdExpr("foo", BasicType.GetBvType(4)).Item2;
            var zext     = sb.BVADD(v, v);
            var asBvZExt = ExprUtil.AsBVZEXT(zext);

            Assert.IsNull(asBvZExt);
        }
Exemplo n.º 2
0
        public void MSBIsZero()
        {
            var cfb    = GetConstantFoldingBuilder();
            var msb    = cfb.ConstantBV(0, 8);
            var lsb    = GetVarAndIdExpr("x", BasicType.GetBvType(4)).Item2;
            var result = cfb.BVCONCAT(msb, lsb);

            var asBvZExt = ExprUtil.AsBVZEXT(result);

            Assert.IsNotNull(asBvZExt);
            CheckIsBvType(result, 12);
            Assert.AreSame(lsb, asBvZExt.Args[0]);
        }
Exemplo n.º 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.BVZEXT(id, 16);
            var simpleResult = sb.BVZEXT(id, 16);

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

            var asBvZExt = ExprUtil.AsBVZEXT(foldedResult);

            Assert.IsNotNull(asBvZExt);
            Assert.AreSame(id, asBvZExt.Args[0]);
        }
Exemplo n.º 4
0
        public void nestedBVZEXT(int depth)
        {
            var  pair     = GetVarAndIdExpr("foo", BasicType.GetBvType(4));
            var  variable = pair.Item1;
            var  id       = pair.Item2;
            var  cfb      = GetConstantFoldingBuilder();
            Expr result   = cfb.BVZEXT(id, 8);

            Assert.IsNotNull(ExprUtil.AsBVZEXT(result));
            for (int i = 0; i < depth; ++i)
            {
                // The newest (closest to the root) zero_extend superseeds any below
                result = cfb.BVZEXT(result, 8 + i);
                CheckIsBvType(result, 8 + i);
            }

            CheckIsBvType(result, depth + 8 - 1);
            var asBvZext = ExprUtil.AsBVZEXT(result);

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