Add smtio.py support for parsing SMT2 (_ bvX n) syntax for BitVec constants
authorClifford Wolf <clifford@clifford.at>
Wed, 4 Apr 2018 16:12:27 +0000 (18:12 +0200)
committerClifford Wolf <clifford@clifford.at>
Wed, 4 Apr 2018 16:12:27 +0000 (18:12 +0200)
Signed-off-by: Clifford Wolf <clifford@clifford.at>
backends/smt2/smtio.py

index bf72e8916eff3016f2f6e32fd0fb9af0c0729905..1a8d2484ccc4c133930dc45f40e27eedb133f7a9 100644 (file)
@@ -737,6 +737,9 @@ class SmtIo:
         return h
 
     def bv2bin(self, v):
+        if type(v) is list and len(v) == 3 and v[0] == "_" and v[1].startswith("bv"):
+            x, n = int(v[1][2:]), int(v[2])
+            return "".join("1" if (x & (1 << i)) else "0" for i in range(n-1, -1, -1))
         if v == "true": return "1"
         if v == "false": return "0"
         if v.startswith("#b"):