|
30 | 30 |
|
31 | 31 | import com.google.common.base.Preconditions;
|
32 | 32 | import com.google.common.base.Splitter;
|
33 |
| -import com.google.common.base.Throwables; |
34 | 33 | import com.google.common.collect.ImmutableMap;
|
35 | 34 | import com.google.common.collect.Lists;
|
36 | 35 | import com.google.common.primitives.Longs;
|
|
42 | 41 | import java.util.Map;
|
43 | 42 | import java.util.Optional;
|
44 | 43 | import java.util.Set;
|
45 |
| -import java.util.concurrent.Callable; |
46 | 44 | import org.sosy_lab.common.ShutdownNotifier;
|
47 | 45 | import org.sosy_lab.java_smt.api.BooleanFormula;
|
48 | 46 | import org.sosy_lab.java_smt.api.Evaluator;
|
@@ -97,32 +95,34 @@ private long buildConfig(Set<ProverOptions> opts) {
|
97 | 95 | /** add needed options into the given map. */
|
98 | 96 | protected abstract void createConfig(Map<String, String> pConfig);
|
99 | 97 |
|
100 |
| - private <T> T exec(Callable<T> closure) throws SolverException, InterruptedException { |
| 98 | + @Override |
| 99 | + public boolean isUnsat() throws InterruptedException, SolverException { |
| 100 | + Preconditions.checkState(!closed); |
| 101 | + |
101 | 102 | long hook = context.addTerminationTest(curEnv);
|
102 |
| - T value = null; |
| 103 | + boolean result; |
103 | 104 | try {
|
104 |
| - value = closure.call(); |
105 |
| - } catch (Throwable t) { |
106 |
| - Throwables.propagateIfPossible(t, IllegalStateException.class, SolverException.class); |
107 |
| - Throwables.propagateIfPossible(t, InterruptedException.class); |
| 105 | + result = !msat_check_sat(curEnv); |
108 | 106 | } finally {
|
109 | 107 | msat_free_termination_callback(hook);
|
110 | 108 | }
|
111 |
| - return value; |
112 |
| - } |
113 |
| - |
114 |
| - @Override |
115 |
| - public boolean isUnsat() throws InterruptedException, SolverException { |
116 |
| - Preconditions.checkState(!closed); |
117 |
| - return exec(() -> !msat_check_sat(curEnv)); |
| 109 | + return result; |
118 | 110 | }
|
119 | 111 |
|
120 | 112 | @Override
|
121 | 113 | public boolean isUnsatWithAssumptions(Collection<BooleanFormula> pAssumptions)
|
122 | 114 | throws SolverException, InterruptedException {
|
123 | 115 | Preconditions.checkState(!closed);
|
124 | 116 | checkForLiterals(pAssumptions);
|
125 |
| - return exec(() -> !msat_check_sat_with_assumptions(curEnv, getMsatTerm(pAssumptions))); |
| 117 | + |
| 118 | + long hook = context.addTerminationTest(curEnv); |
| 119 | + boolean result; |
| 120 | + try { |
| 121 | + result = !msat_check_sat_with_assumptions(curEnv, getMsatTerm(pAssumptions)); |
| 122 | + } finally { |
| 123 | + msat_free_termination_callback(hook); |
| 124 | + } |
| 125 | + return result; |
126 | 126 | }
|
127 | 127 |
|
128 | 128 | private void checkForLiterals(Collection<BooleanFormula> formulas) {
|
|
0 commit comments