use of org.abs_models.frontend.ast.TypeUse in project abstools by abstools.
the class TypeCheckerTest method ticket414_futNeedsDataType1.
@Test
public void ticket414_futNeedsDataType1() {
Model m = assertParse("module M; interface I {} { Fut<I> fi; }");
assertFalse(m.hasErrors());
Block b = m.getMainBlock();
assertNotNull(b);
VarDeclStmt s = (VarDeclStmt) b.getStmt(0);
ParametricDataTypeUse u = (ParametricDataTypeUse) s.getVarDecl().getTypeUse();
// Have:
TypeUse tu = u.getParam(0);
assertEquals("I", tu.getName());
assertThat(tu, instanceOf(InterfaceTypeUse.class));
assertThat(tu.getType(), instanceOf(InterfaceType.class));
assertThat(tu.getDecl(), instanceOf(InterfaceDecl.class));
}
use of org.abs_models.frontend.ast.TypeUse in project abstools by abstools.
the class TypeCheckerTest method ticket414_futNeedsDataType2.
@Test
public void ticket414_futNeedsDataType2() {
Model m = assertParse("module M; data I = I; { Fut<I> fi; }");
assertFalse(m.hasErrors());
Block b = m.getMainBlock();
assertNotNull(b);
VarDeclStmt s = (VarDeclStmt) b.getStmt(0);
ParametricDataTypeUse u = (ParametricDataTypeUse) s.getVarDecl().getTypeUse();
// Have:
TypeUse tu = u.getParam(0);
assertEquals("I", tu.getName());
assertThat(tu, instanceOf(DataTypeUse.class));
}
use of org.abs_models.frontend.ast.TypeUse in project abstools by abstools.
the class ASTBasedABSTestRunnerGenerator method generateDataPointsAST.
private TypeUse generateDataPointsAST(InterfaceDecl key, ClassDecl clazz, Set<TypeUse> use, MainBlock block) {
MethodSig dataPoint = findDataPoints(key);
if (dataPoint == null) {
return null;
}
TypeIdUse rt = dataPoint.getReturnType();
if (!(rt instanceof ParametricDataTypeUse)) {
return null;
}
ParametricDataTypeUse prt = (ParametricDataTypeUse) rt;
if (!prt.getName().equals("Set")) {
return null;
}
// Set has only one type parameter
TypeUse u = (TypeUse) prt.getParam(0).copy();
use.add(u);
String objName = uncap(clazz.getName()) + "dataPoint";
String dataSet = dataPointSetName(clazz);
block.addStmtNoTransform(newObj(key, clazz, objName, true));
block.addStmtNoTransform(getVarDecl(dataSet, prt.copy(), new SyncCall(new VarUse(objName), dataPoint.getName(), new List<>())));
return u;
}
use of org.abs_models.frontend.ast.TypeUse in project abstools by abstools.
the class AbsASTBuilderUtil method getType.
public static final DataTypeUse getType(String n, TypeUse... types) {
if (types.length > 0) {
ParametricDataTypeUse set = new ParametricDataTypeUse();
set.setName(n);
for (TypeUse d : types) {
set.addParam(d);
}
return set;
} else {
DataTypeUse set = new DataTypeUse();
set.setName(n);
return set;
}
}
use of org.abs_models.frontend.ast.TypeUse in project abstools by abstools.
the class ASTBasedABSTestRunnerGenerator method generateMainBlockAST.
private MainBlock generateMainBlockAST(List<Import> list) {
final MainBlock block = new MainBlock();
DataConstructorExp empty = new DataConstructorExp("EmptySet", new List<>());
VarDeclStmt futsStatement = getVarDecl(futs, getType("Set", getFutUnitType()), empty);
block.addStmtNoTransform(futsStatement);
VarDeclStmt futStatement = getVarDecl(fut, getFutUnitType(), null);
block.addStmtNoTransform(futStatement);
Set<TypeUse> use = new HashSet<>();
for (InterfaceDecl key : tests.keySet()) {
for (ClassDecl clazz : tests.get(key)) {
use.addAll(generateTestClassImplAST(key, clazz, block));
}
}
block.addStmtNoTransform(generateWaitSyncAST());
return block;
}
Aggregations