use of apet.testCases.ABSTerm in project abstools by abstools.
the class ABSUnitTestCaseBuilder method getTypesFromABSData.
Map<String, InterfaceTypeUse> getTypesFromABSData(String testName, ABSData data) {
Map<String, InterfaceTypeUse> map = new HashMap<String, InterfaceTypeUse>();
if (data instanceof ABSRef) {
String type = getABSDataType(data);
String value = getABSDataValue(data);
if (!value.equals(NULL)) {
map.put(heapRefBuilder.heapReferenceForTest(testName, value), new InterfaceTypeUse(type, new abs.frontend.ast.List<abs.frontend.ast.Annotation>()));
}
} else if (data instanceof ABSTerm) {
ABSTerm term = (ABSTerm) data;
for (ABSData t : getABSTermArgs(term)) {
map.putAll(getTypesFromABSData(testName, t));
}
}
return map;
}
use of apet.testCases.ABSTerm in project abstools by abstools.
the class PureExpressionBuilder method createPureExpression.
/**
* @param currentHeapReference
* @param initialisationsOrders
* @param heapNames
* @param dataValue
* @return
*/
PureExp createPureExpression(String currentHeapReference, List<String> initialisationsOrders, String testName, Set<String> heapNames, ABSData dataValue) {
String type = getABSDataType(dataValue);
String value = getABSDataValue(dataValue);
if (type.contains("(") && dataValue instanceof ABSTerm) {
ABSTerm term = (ABSTerm) dataValue;
type = getABSTermTypeName(term);
}
// import type
Decl decl = getDecl(model, Decl.class, namePred(type));
importType(decl);
if (dataValue instanceof ABSTerm) {
ABSTerm term = (ABSTerm) dataValue;
return makeDataTermValue(currentHeapReference, initialisationsOrders, testName, heapNames, term, decl);
} else if (dataValue instanceof ABSRef) {
if (heapNames.contains(value)) {
String ref = heapRefBuilder.heapReferenceForTest(testName, value);
if (currentHeapReference != null) {
// we need to consider initialisation order!
updateInitialisationOrder(initialisationsOrders, currentHeapReference, ref);
}
return new VarUse(ref);
} else {
return new NullExp();
}
} else {
throw new IllegalStateException("Cannot handle ABSData that is not " + "either a ABSRef or a ABSTerm");
}
}
Aggregations