use of abs.frontend.typechecker.Type in project abstools by abstools.
the class MaudeCompilerHelper method emitParameterValueList.
public static void emitParameterValueList(PrintStream stream, abs.frontend.ast.List<PureExp> params, java.util.List<Type> paramTypes) {
if (params.getNumChild() == 0) {
stream.print("emp ");
} else {
boolean inlist = false;
stream.print("(");
for (int i = 0; i < params.getNumChild(); i++) {
PureExp param = params.getChild(i);
Type t = paramTypes.get(i);
boolean needConversion = t.isIntType() && param.getType().isRatType();
if (inlist)
stream.print(":: ");
else
inlist = true;
if (needConversion)
stream.print("\"ABS.StdLib.truncate\"(");
param.generateMaude(stream);
if (needConversion)
stream.print(")");
}
stream.print(") ");
}
}
use of abs.frontend.typechecker.Type in project abstools by abstools.
the class StringBasedABSTestRunnerGenerator method generateMainBlock.
private TestRunnerScriptBuilder generateMainBlock(TestRunnerScriptBuilder imports) {
TestRunnerScriptBuilder builder = new TestRunnerScriptBuilder();
builder.increaseIndent();
Set<Type> paramNames = new HashSet<>();
builder.append("Set<Fut<Unit>> ").append(futs).append(" = EmptySet;").newLine();
builder.append("Fut<Unit> ").append(fut).append(";").newLine();
for (InterfaceDecl key : tests.keySet()) {
builder.append("//Test cases for ").append(key.getType().getQualifiedName()).newLine();
for (ClassDecl clazz : tests.get(key)) {
builder.append("//Test cases for implementation ").append(clazz.getName()).newLine();
paramNames.addAll(generateTestClassImpl(key, clazz, builder));
}
}
generateWaitSync(builder);
generateImports(imports, paramNames);
return builder;
}
use of abs.frontend.typechecker.Type in project abstools by abstools.
the class StringBasedABSTestRunnerGenerator method generateDataPoints.
/**
* Generates data points for test class {@code clazz}
*
* @param inf
* @param clazz
* @param paramNames
* @param main
* @return The data type the set return type is parametric on, null if
* {@code inf} does not define a data point method or {@code clazz}
* does not implement such method.
*/
private Type generateDataPoints(InterfaceDecl inf, ClassDecl clazz, Set<Type> paramNames, TestRunnerScriptBuilder main) {
MethodSig dataPoint = findDataPoints(inf);
if (dataPoint == null) {
return null;
}
/*
* It must be a Set of data
*/
Type data = ((ParametricDataTypeUse) dataPoint.getReturnType()).getParams().iterator().next().getType();
/*
* make sure the return type can be resolved TODO this needs to be
* resolved recursively
*/
paramNames.add(data);
/*
* create an object in the same cog as main for retrieving the data
* points
*/
String objName = uncap(clazz.getName()) + "dataPoint";
String dataSet = dataPointSetName(clazz);
newObj(main, inf, clazz, objName, false);
main.append(dataPoint.getReturnType()).append(" ").append(dataSet).append(" = ").append(objName).append(".").append(dataPoint.getName()).append("();").newLine();
return data;
}
use of abs.frontend.typechecker.Type in project abstools by abstools.
the class TypingTest method functionTypeArgs4.
@Test
public void functionTypeArgs4() {
Model m = assertParseOkStdLib(" data Foo<A> = Bar(A,Bool); " + "def Bool f<A>(Foo<A> o) = case o { Bar(a,b) => b; } ;");
ParametricFunctionDecl d = getLastParametricFunctionDecl(m);
Type type = ((ExpFunctionDef) d.getFunctionDef()).getRhs().getType();
assertEquals(m.getBoolType(), type);
}
use of abs.frontend.typechecker.Type in project abstools by abstools.
the class ClassGenerator method generateParameterDescription.
private void generateParameterDescription(Type paramtype) {
ecs.print("<<\"" + paramtype.getQualifiedName() + "\">>,");
ecs.print(" {");
if (paramtype.isDataType()) {
DataTypeType paramdatatype = (DataTypeType) paramtype;
if (paramdatatype.hasTypeArgs()) {
String interp = "";
for (Type typearg : paramdatatype.getTypeArgs()) {
ecs.print(interp);
interp = ", ";
generateParameterDescription(typearg);
}
}
}
ecs.print(" }");
}
Aggregations