use of abs.frontend.typechecker.Type in project abstools by abstools.
the class TypeExtensionHelper method checkDataConstructorExp.
public void checkDataConstructorExp(DataConstructorExp e) {
DataConstructor decl = (DataConstructor) e.getDecl();
if (decl.getDataTypeDecl() instanceof ParametricDataTypeDecl) {
HashMap<TypeParameter, Type> map = new HashMap<>();
for (int i = 0; i < decl.getNumConstructorArg(); i++) {
Type rht = e.getParam(i).getType();
Type arg = decl.getConstructorArg(i).getType();
checkTypeParameter(map, rht, arg, e.getParam(i));
}
}
}
use of abs.frontend.typechecker.Type in project abstools by abstools.
the class TypeExtensionHelper method checkOverride.
@Override
public void checkOverride(MethodSig impl, MethodSig overriden) {
for (TypeSystemExtension tse : obs) {
tse.checkOverride(impl, overriden);
}
assert overriden.getParent().getParent() instanceof InterfaceDecl;
Type expectedReturnType = overriden.getType();
Type actualReturnType = impl.getType();
checkAssignable(actualReturnType, expectedReturnType, impl);
for (int i = 0; i < overriden.getNumParam(); i++) {
Type texpected = overriden.getParam(i).getType();
Type tactual = impl.getParam(i).getType();
checkAssignable(texpected, tactual, impl);
}
}
use of abs.frontend.typechecker.Type in project abstools by abstools.
the class TypeHierarchyContentProvider method getElements.
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof Type) {
Type type = (Type) inputElement;
if (type.getDecl() != null) {
return new Object[] { type.getDecl() };
}
if (type instanceof UnionType) {
UnionType unionType = (UnionType) type;
java.util.List<Object> result = new ArrayList<Object>();
for (InterfaceType t : unionType.getTypes()) {
for (Object e : getElements(t)) {
result.add(e);
}
}
return result.toArray();
}
}
return nothing;
}
use of abs.frontend.typechecker.Type in project abstools by abstools.
the class StringBasedABSTestRunnerGenerator method generateTestClassImpl.
private Set<Type> generateTestClassImpl(InterfaceDecl inf, ClassDecl clazz, TestRunnerScriptBuilder main) {
Set<Type> paramNames = new HashSet<>();
Type dataType = generateDataPoints(inf, clazz, paramNames, main);
String namePrefix = clazz.getName();
int instance = 0;
for (MethodSig method : getTestMethods(inf)) {
boolean needdata = method.getParamList().iterator().hasNext();
if (needdata) {
if (dataType == null) {
throw new IllegalStateException("Test method requires arguments but test class defines no data point");
}
/*
* a while loop over all data points
*/
String dataPointSet = dataPointSetName(clazz);
// begin while
main.append("while (hasNext(").append(dataPointSet).append(")) {").newLine().increaseIndent();
main.append("Pair<Set<").append(dataType).append(">,").append(dataType).append("> nt = next(").append(dataPointSet).append(");").newLine();
main.append(dataType).append(" ").append(dataValue).append(" = snd(nt);").newLine();
main.append(dataPointSet).append(" = fst(nt);").newLine();
}
/*
* Add those methods that are not ignored
*/
if (!isIgnored(clazz, method)) {
main.append("//Test cases for method ").append(method.getName()).newLine();
String objectRef = uncap(namePrefix) + instance;
main = newCog(main, inf, clazz, objectRef);
generateAsyncTestCall(main, objectRef, method);
}
if (needdata) {
// end while
main.decreaseIndent().append("}").newLine();
}
instance++;
}
return paramNames;
}
Aggregations