Skip to content

Commit 1b5e72a

Browse files
daniel-rafflerbaierd
authored andcommitted
MathSAT5AbstractProver: Remove the helper method exec and install the termination test directly in isUnsat and isUnsatWithAssumptions. This was suggested in #345 (comment)
1 parent a8f965c commit 1b5e72a

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/org/sosy_lab/java_smt/solvers/mathsat5/Mathsat5AbstractProver.java

+16-16
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
import com.google.common.base.Preconditions;
3232
import com.google.common.base.Splitter;
33-
import com.google.common.base.Throwables;
3433
import com.google.common.collect.ImmutableMap;
3534
import com.google.common.collect.Lists;
3635
import com.google.common.primitives.Longs;
@@ -42,7 +41,6 @@
4241
import java.util.Map;
4342
import java.util.Optional;
4443
import java.util.Set;
45-
import java.util.concurrent.Callable;
4644
import org.sosy_lab.common.ShutdownNotifier;
4745
import org.sosy_lab.java_smt.api.BooleanFormula;
4846
import org.sosy_lab.java_smt.api.Evaluator;
@@ -97,32 +95,34 @@ private long buildConfig(Set<ProverOptions> opts) {
9795
/** add needed options into the given map. */
9896
protected abstract void createConfig(Map<String, String> pConfig);
9997

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+
101102
long hook = context.addTerminationTest(curEnv);
102-
T value = null;
103+
boolean result;
103104
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);
108106
} finally {
109107
msat_free_termination_callback(hook);
110108
}
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;
118110
}
119111

120112
@Override
121113
public boolean isUnsatWithAssumptions(Collection<BooleanFormula> pAssumptions)
122114
throws SolverException, InterruptedException {
123115
Preconditions.checkState(!closed);
124116
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;
126126
}
127127

128128
private void checkForLiterals(Collection<BooleanFormula> formulas) {

0 commit comments

Comments
 (0)