-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathAbstractBaseFormulaManager.java
67 lines (58 loc) · 2.55 KB
/
AbstractBaseFormulaManager.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// This file is part of JavaSMT,
// an API wrapper for a collection of SMT solvers:
// https://github.com/sosy-lab/java-smt
//
// SPDX-FileCopyrightText: 2020 Dirk Beyer <https://www.sosy-lab.org>
//
// SPDX-License-Identifier: Apache-2.0
package org.sosy_lab.java_smt.basicimpl;
import org.sosy_lab.java_smt.api.BooleanFormula;
import org.sosy_lab.java_smt.api.Formula;
import org.sosy_lab.java_smt.api.FormulaType;
/**
* A BaseFormulaManager because all Abstract*FormulaManager-Classes wrap a FormulaCreator-instance.
*
* @param <TFormulaInfo> the solver specific type.
*/
@SuppressWarnings("ClassTypeParameterName")
abstract class AbstractBaseFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> {
protected final FormulaCreator<TFormulaInfo, TType, TEnv, TFuncDecl> formulaCreator;
AbstractBaseFormulaManager(FormulaCreator<TFormulaInfo, TType, TEnv, TFuncDecl> pFormulaCreator) {
this.formulaCreator = pFormulaCreator;
}
protected final FormulaCreator<TFormulaInfo, TType, TEnv, TFuncDecl> getFormulaCreator() {
return formulaCreator;
}
protected final TFormulaInfo extractInfo(Formula pBits) {
return getFormulaCreator().extractInfo(pBits);
}
final BooleanFormula wrapBool(TFormulaInfo pTerm) {
return getFormulaCreator().encapsulateBoolean(pTerm);
}
protected final TType toSolverType(FormulaType<?> formulaType) {
TType t;
if (formulaType.isBooleanType()) {
t = getFormulaCreator().getBoolType();
} else if (formulaType.isIntegerType()) {
t = getFormulaCreator().getIntegerType();
} else if (formulaType.isRationalType()) {
t = getFormulaCreator().getRationalType();
} else if (formulaType.isStringType()) {
t = getFormulaCreator().getStringType();
} else if (formulaType.isBitvectorType()) {
FormulaType.BitvectorType bitPreciseType = (FormulaType.BitvectorType) formulaType;
t = getFormulaCreator().getBitvectorType(bitPreciseType.getSize());
} else if (formulaType.isFloatingPointType()) {
FormulaType.FloatingPointType fpType = (FormulaType.FloatingPointType) formulaType;
t = getFormulaCreator().getFloatingPointType(fpType);
} else if (formulaType.isArrayType()) {
FormulaType.ArrayFormulaType<?, ?> arrType = (FormulaType.ArrayFormulaType<?, ?>) formulaType;
TType indexType = toSolverType(arrType.getIndexType());
TType elementType = toSolverType(arrType.getElementType());
t = getFormulaCreator().getArrayType(indexType, elementType);
} else {
throw new IllegalArgumentException("Not supported interface");
}
return t;
}
}