|
19 | 19 | */
|
20 | 20 | package org.sosy_lab.java_smt.solvers.stp;
|
21 | 21 |
|
| 22 | +import com.google.common.base.Preconditions; |
22 | 23 | import java.util.Collection;
|
23 | 24 | import java.util.List;
|
24 | 25 | import java.util.Optional;
|
25 | 26 | import java.util.Set;
|
26 |
| -import org.checkerframework.checker.nullness.qual.Nullable; |
| 27 | +import org.sosy_lab.common.ShutdownNotifier; |
27 | 28 | import org.sosy_lab.java_smt.api.BooleanFormula;
|
28 | 29 | import org.sosy_lab.java_smt.api.Model;
|
29 | 30 | import org.sosy_lab.java_smt.api.SolverContext.ProverOptions;
|
30 | 31 | import org.sosy_lab.java_smt.api.SolverException;
|
31 | 32 | import org.sosy_lab.java_smt.basicimpl.AbstractProver;
|
32 | 33 |
|
33 |
| -class StpAbstractProver<T> extends AbstractProver<T> { |
| 34 | +abstract class StpAbstractProver<T> extends AbstractProver<T> { |
34 | 35 |
|
35 |
| - protected StpAbstractProver(Set<ProverOptions> pOptions) { |
| 36 | + private final StpSolverContext context; |
| 37 | + private final StpFormulaCreator creator; |
| 38 | + private final ShutdownNotifier shutdownNotifier; |
| 39 | + // private final long curConfig; |
| 40 | + protected final VC currVC; |
| 41 | + protected boolean closed; |
| 42 | + |
| 43 | + protected StpAbstractProver( |
| 44 | + StpSolverContext pContext, |
| 45 | + Set<ProverOptions> pOptions, |
| 46 | + StpFormulaCreator pCreator, |
| 47 | + ShutdownNotifier pShutdownNotifier) { |
36 | 48 | super(pOptions);
|
37 |
| - // TODO Auto-generated constructor stub |
| 49 | + context = pContext; |
| 50 | + creator = pCreator; |
| 51 | + // curConfig = buildConfig(pOptions); //TODO implement configuration handling |
| 52 | + currVC = context.createEnvironment(null);// curConfig is to be passed in here |
| 53 | + shutdownNotifier = pShutdownNotifier; |
38 | 54 | }
|
39 | 55 |
|
40 | 56 | @Override
|
41 | 57 | public void pop() {
|
42 |
| - // TODO Auto-generated method stub |
43 |
| - |
| 58 | + Preconditions.checkState(!closed); |
| 59 | + StpJavaApi.vc_pop(currVC); |
44 | 60 | }
|
45 | 61 |
|
46 |
| - @Override |
47 |
| - public @Nullable T addConstraint(BooleanFormula pConstraint) throws InterruptedException { |
48 |
| - // TODO Auto-generated method stub |
49 |
| - return null; |
50 |
| - } |
51 |
| - |
52 |
| - @Override |
53 |
| - public void push() { |
54 |
| - // TODO Auto-generated method stub |
55 |
| - |
56 |
| - } |
| 62 | + /* |
| 63 | + * @Override public @Nullable T addConstraint(BooleanFormula pConstraint) throws |
| 64 | + * InterruptedException { // TODO Auto-generated method stub return null; } |
| 65 | + * |
| 66 | + * @Override public void push() { // TODO Auto-generated method stub |
| 67 | + * |
| 68 | + * } |
| 69 | + */ |
57 | 70 |
|
58 | 71 | @Override
|
59 | 72 | public boolean isUnsat() throws SolverException, InterruptedException {
|
60 |
| - // TODO Auto-generated method stub |
61 |
| - return false; |
| 73 | + // TODO update to use vc_query_with_timeout |
| 74 | + |
| 75 | +// Preconditions.checkState(!closed); |
| 76 | +// int result = StpJavaApi.vc_query(curVC, queryExpr) |
| 77 | +// if (result == 0) { |
| 78 | +// return true; |
| 79 | +// } else if (result == 1){ |
| 80 | +// return false; |
| 81 | +// } else if (result == 2) { |
| 82 | +// throw new Exception("An error occured in STP during validation"); |
| 83 | +// } |
| 84 | +// throw new Exception("An error occured in STP during validation"); |
| 85 | + |
| 86 | + throw new SolverException("NOT MPLEMENTED"); |
62 | 87 | }
|
63 | 88 |
|
64 | 89 | @Override
|
@@ -90,8 +115,13 @@ public List<BooleanFormula> getUnsatCore() {
|
90 | 115 |
|
91 | 116 | @Override
|
92 | 117 | public void close() {
|
93 |
| - // TODO Auto-generated method stub |
| 118 | + if (!closed) { |
94 | 119 |
|
| 120 | + // TODO check if EXPRDELETE is set via vc_setInterfaceFlags |
| 121 | + // other we will can delete expression with vc_DeleteExpr |
| 122 | + StpJavaApi.vc_Destroy(currVC); |
| 123 | + closed = true; |
| 124 | + } |
95 | 125 | }
|
96 | 126 |
|
97 | 127 | @Override
|
|
0 commit comments