Skip to content

Commit 509604b

Browse files
committed
Added incRef and decRef to z3 ieee number constructor
1 parent 6f5d95c commit 509604b

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

src/org/sosy_lab/java_smt/solvers/cvc4/CVC4FloatingPointFormulaManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
package org.sosy_lab.java_smt.solvers.cvc4;
1010

1111
import com.google.common.collect.ImmutableList;
12-
import edu.stanford.CVC4.BitVectorExtract;
1312
import edu.stanford.CVC4.BitVector;
13+
import edu.stanford.CVC4.BitVectorExtract;
1414
import edu.stanford.CVC4.Expr;
1515
import edu.stanford.CVC4.ExprManager;
1616
import edu.stanford.CVC4.FloatingPoint;

src/org/sosy_lab/java_smt/solvers/z3/Z3FloatingPointFormulaManager.java

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,22 @@ protected Long makeNumberImpl(double pN, FloatingPointType pType, Long pRounding
7575
protected Long makeNumberImpl(
7676
BigInteger exponent, BigInteger mantissa, boolean signBit, FloatingPointType type) {
7777

78-
long signBv = Native.mkBvNumeral(z3context, 1, new boolean[] {signBit});
79-
long expoBv =
80-
Native.mkNumeral(
81-
z3context, exponent.toString(), Native.mkBvSort(z3context, type.getExponentSize()));
82-
long mantBv =
83-
Native.mkNumeral(
84-
z3context, mantissa.toString(), Native.mkBvSort(z3context, type.getMantissaSize()));
85-
86-
assert Native.getBvSortSize(z3context, Native.getSort(z3context, signBv)) == 1
87-
: "SignBV should be 1 bit long";
88-
assert Native.getBvSortSize(z3context, Native.getSort(z3context, expoBv))
89-
== type.getExponentSize()
90-
: "ExpoBV should be " + type.getExponentSize() + " bits long";
91-
assert Native.getBvSortSize(z3context, Native.getSort(z3context, mantBv))
92-
== type.getMantissaSize()
93-
: "MantBV should be " + type.getMantissaSize() + " bits long";
94-
95-
return Native.mkFpaFp(z3context, signBv, expoBv, mantBv);
78+
final Long signSort = getFormulaCreator().getBitvectorType(1);
79+
final Long expoSort = getFormulaCreator().getBitvectorType(type.getExponentSize());
80+
final Long mantSort = getFormulaCreator().getBitvectorType(type.getMantissaSize());
81+
82+
final Long signBv = Native.mkNumeral(z3context, signBit ? "1" : "0", signSort);
83+
Native.incRef(z3context, signBv);
84+
final Long expoBv = Native.mkNumeral(z3context, exponent.toString(), expoSort);
85+
Native.incRef(z3context, expoBv);
86+
final Long mantBv = Native.mkNumeral(z3context, mantissa.toString(), mantSort);
87+
Native.incRef(z3context, mantBv);
88+
89+
final Long fp = Native.mkFpaFp(z3context, signBv, expoBv, mantBv);
90+
Native.decRef(z3context, mantBv);
91+
Native.decRef(z3context, expoBv);
92+
Native.decRef(z3context, signBv);
93+
return fp;
9694
}
9795

9896
@Override

0 commit comments

Comments
 (0)