|
11 | 11 | import com.google.common.base.Preconditions; |
12 | 12 | import com.google.common.collect.Collections2; |
13 | 13 | import com.google.common.collect.ImmutableList; |
| 14 | +import edu.stanford.CVC4.Exception; |
14 | 15 | import edu.stanford.CVC4.Expr; |
15 | 16 | import edu.stanford.CVC4.ExprManager; |
16 | 17 | import edu.stanford.CVC4.ExprManagerMapCollection; |
@@ -123,16 +124,25 @@ protected void popImpl() { |
123 | 124 | } |
124 | 125 |
|
125 | 126 | @Override |
126 | | - protected @Nullable Void addConstraintImpl(BooleanFormula pF) throws InterruptedException { |
| 127 | + protected @Nullable Void addConstraintImpl(BooleanFormula pF) |
| 128 | + throws InterruptedException, SolverException { |
127 | 129 | Preconditions.checkState(!closed); |
128 | 130 | setChanged(); |
129 | | - Expr exp = creator.extractInfo(pF); |
130 | 131 | if (incremental) { |
131 | | - smtEngine.assertFormula(importExpr(exp)); |
| 132 | + assertFormula(pF); |
132 | 133 | } |
133 | 134 | return null; |
134 | 135 | } |
135 | 136 |
|
| 137 | + private void assertFormula(BooleanFormula pF) throws SolverException { |
| 138 | + try { |
| 139 | + smtEngine.assertFormula(importExpr(creator.extractInfo(pF))); |
| 140 | + } catch (Exception cvc4Exception) { |
| 141 | + throw new SolverException( |
| 142 | + String.format("CVC4 crashed while adding the constraint '%s'", pF), cvc4Exception); |
| 143 | + } |
| 144 | + } |
| 145 | + |
136 | 146 | @SuppressWarnings("resource") |
137 | 147 | @Override |
138 | 148 | public CVC4Model getModel() throws InterruptedException, SolverException { |
@@ -188,7 +198,9 @@ public boolean isUnsat() throws InterruptedException, SolverException { |
188 | 198 | closeAllEvaluators(); |
189 | 199 | changedSinceLastSatQuery = false; |
190 | 200 | if (!incremental) { |
191 | | - getAssertedFormulas().forEach(f -> smtEngine.assertFormula(creator.extractInfo(f))); |
| 201 | + for (BooleanFormula f : getAssertedFormulas()) { |
| 202 | + assertFormula(f); |
| 203 | + } |
192 | 204 | } |
193 | 205 |
|
194 | 206 | Result result; |
|
0 commit comments