use of org.abs_models.frontend.ast.VarDeclStmt 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.VarDeclStmt 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.VarDeclStmt in project abstools by abstools.
the class AnnotationTests method testVarDecl.
@Test
public void testVarDecl() {
Model m = assertParseOkAnn("{ [Near] I i; }");
VarDeclStmt v = ((VarDeclStmt) m.getMainBlock().getStmt(0));
assertHasLocAnnotation(v.getVarDecl().getType(), "Near");
}
use of org.abs_models.frontend.ast.VarDeclStmt in project abstools by abstools.
the class FrontendTest method getTypeOfNthAssignment.
protected Type getTypeOfNthAssignment(Model m, int n) {
int count = 0;
for (Stmt s : m.getMainBlock().getStmts()) {
Type t = null;
if (s instanceof AssignStmt) {
AssignStmt as = (AssignStmt) s;
t = as.getValue().getType();
} else if (s instanceof VarDeclStmt) {
VarDeclStmt vd = (VarDeclStmt) s;
if (vd.getVarDecl().hasInitExp()) {
t = vd.getVarDecl().getInitExp().getType();
}
}
if (t != null) {
count++;
if (count == n) {
return t;
}
}
}
return null;
}
use of org.abs_models.frontend.ast.VarDeclStmt 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