示例#1
0
文件: stp.py 项目: wxdublin/nice
def resetVarCache():
    # deleting the variables makes stp crash, doing pop and push does not work, this is the
    # only way to have a clean STP environment """
    global _stp
    del _stp
    _stp = pystp.Stp()
    stp_vars.clear()
示例#2
0
import sys
import pystp

#   for(int j=0;j < 3; j++) {
for j in range(3):
    #     VC vc = vc_createValidityChecker();
    vc = pystp.Stp()
    #     vc_setFlags('n');
    #     vc_setFlags('d');
    #     vc_setFlags('p');
    #     vc_setFlags('x');
    vc.setFlags("ndpx")

    #     Type bv8 = vc_bvType(vc, 8);
    bv8 = vc.createType(pystp.TYPE_BITVECTOR, 8)

    #     Expr a =  vc_bvCreateMemoryArray(vc, "a");
    a = vc.bvCreateMemoryArray("a")

    #     Expr index_3 = vc_bvConstExprFromInt(vc, 32, 3);
    index_3 = vc.bvConstExprFromInt(32, 3)

    #     Expr a_of_0 = vc_readExpr(vc, a, index_3);
    a_of_0 = vc.readExpr(a, index_3)

    #   int i;
    #   for (i = 2; i >= 0; i--)
    #     a_of_0 = vc_bvConcatExpr(vc,
    # 			     a_of_0,
    # 			     vc_readExpr(vc, a,
    # 					 vc_bvConstExprFromInt(vc, 32, i)));
示例#3
0
import sys
import pystp

# preliminary
print >> sys.stderr, " * creating Stp object"
o = pystp.Stp()
print "-" * 25, "\n"

# types
print >> sys.stderr, " * creating StpType Bool object (t1)"
t1 = o.createType(pystp.TYPE_BOOL)
print >> sys.stderr, "  - printing it: '%s'" % t1
assert t1.isBool() and not t1.isBitVector() and not t1.isArray()

print >> sys.stderr, " * creating StpType BitVector object (t2)"
t2 = o.createType(pystp.TYPE_BITVECTOR)
print >> sys.stderr, "  - printing it: '%s'" % t2
assert not t2.isBool() and t2.isBitVector() and not t2.isArray()

print >> sys.stderr, " * creating StpType BitVector(24) object (t3)"
t3 = o.createType(pystp.TYPE_BITVECTOR, 24)
print >> sys.stderr, "  - printing it: '%s'" % t3
assert not t3.isBool() and t3.isBitVector() and not t3.isArray()
print "-" * 25, "\n"

# expressions
print >> sys.stderr, " * creating StpExpr variable 'pippo', with type 't1' (v1)"
v1 = o.varExpr("pippo", t1)
print >> sys.stderr, "  - printing it: '%s'" % v1
tmp = v1.getType()
assert tmp.isBool() and not tmp.isBitVector() and not tmp.isArray()
示例#4
0
文件: stp.py 项目: wxdublin/nice
#

import ast

import logging
log = logging.getLogger("nice.se.stp")
import utils

try:
    import pystp
except ImportError as e:
    utils.crash("Cannot import %s" % e)

from symbolic.symbolic_types.symbolic_type import SymbolicType

_stp = pystp.Stp()

stp_types = {}
stp_vars = {}


def int2stp(v, length):
    # see note on getIntegerType
    return _stp.bvConstExprFromLL(length, v)


def getIntegerType(bitlen):
    ### Note: Pystp threats int as 32 bit and using getBVInt / getBVUnsigned
    # with 64bit architecture can cause following crash when stp counterexample contains >32bit values:
    #    Fatal Error: GetUnsignedConst: cannot convert bvconst of length greater than 32 to unsigned int
    #    python: ASTmisc.cpp:92: void BEEV::FatalError(const char*): Assertion `0' failed.