Skip to content

Commit 71eacc2

Browse files
committed
Z3: catch Z3Exception in more places.
1 parent d9414d8 commit 71eacc2

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

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

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,27 @@ public ImmutableList<ValueAssignment> asList() throws InterruptedException, Solv
4848
Preconditions.checkState(!isClosed());
4949
ImmutableList.Builder<ValueAssignment> out = ImmutableList.builder();
5050

51-
// Iterate through constants.
52-
for (int constIdx = 0; constIdx < Native.modelGetNumConsts(z3context, model); constIdx++) {
53-
long keyDecl = Native.modelGetConstDecl(z3context, model, constIdx);
54-
Native.incRef(z3context, keyDecl);
55-
out.addAll(getConstAssignments(keyDecl));
56-
Native.decRef(z3context, keyDecl);
57-
}
51+
try {
52+
// Iterate through constants.
53+
for (int constIdx = 0; constIdx < Native.modelGetNumConsts(z3context, model); constIdx++) {
54+
long keyDecl = Native.modelGetConstDecl(z3context, model, constIdx);
55+
Native.incRef(z3context, keyDecl);
56+
out.addAll(getConstAssignments(keyDecl));
57+
Native.decRef(z3context, keyDecl);
58+
}
5859

59-
// Iterate through function applications.
60-
for (int funcIdx = 0; funcIdx < Native.modelGetNumFuncs(z3context, model); funcIdx++) {
61-
long funcDecl = Native.modelGetFuncDecl(z3context, model, funcIdx);
62-
Native.incRef(z3context, funcDecl);
63-
if (!isInternalSymbol(funcDecl)) {
64-
String functionName = z3creator.symbolToString(Native.getDeclName(z3context, funcDecl));
65-
out.addAll(getFunctionAssignments(funcDecl, funcDecl, functionName));
60+
// Iterate through function applications.
61+
for (int funcIdx = 0; funcIdx < Native.modelGetNumFuncs(z3context, model); funcIdx++) {
62+
long funcDecl = Native.modelGetFuncDecl(z3context, model, funcIdx);
63+
Native.incRef(z3context, funcDecl);
64+
if (!isInternalSymbol(funcDecl)) {
65+
String functionName = z3creator.symbolToString(Native.getDeclName(z3context, funcDecl));
66+
out.addAll(getFunctionAssignments(funcDecl, funcDecl, functionName));
67+
}
68+
Native.decRef(z3context, funcDecl);
6669
}
67-
Native.decRef(z3context, funcDecl);
70+
} catch (Z3Exception e) {
71+
throw z3creator.handleZ3Exception(e);
6872
}
6973

7074
return out.build();

0 commit comments

Comments
 (0)