use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class AddImportsTest method addImport.
@Test
public void addImport() throws DeltaModellingException {
Model model = assertParse("module Exporter; export *;" + "interface I {}" + "interface J {}" + "module Exporter2; export *;" + "interface K {}" + "module M;" + "class C {}" + "delta D; uses M;" + "adds import Exporter.I;" + "adds import J from Exporter;" + "adds import * from Exporter2;" + "modifies class C { adds Exporter.I field1; } " + "modifies class C { adds J field2; } " + "modifies class C { adds K field3; } ");
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
DeltaDecl delta = findDelta(model, "D");
model.applyDeltas(new ArrayList<>(Arrays.asList(delta)));
ModuleDecl clsmodule = cls.getModuleDecl();
Map<KindedName, ResolvedName> clsVisibleSymbols = clsmodule.getVisibleNames();
KindedName symbol1 = new KindedName(KindedName.Kind.TYPE_DECL, "Exporter.I");
KindedName symbol2 = new KindedName(KindedName.Kind.TYPE_DECL, "J");
KindedName symbol3 = new KindedName(KindedName.Kind.TYPE_DECL, "K");
assertTrue(clsVisibleSymbols.containsKey(symbol1));
assertTrue(clsVisibleSymbols.containsKey(symbol2));
assertTrue(clsVisibleSymbols.containsKey(symbol3));
}
use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class ClassKindTypeExtension method checkNewExp.
@Override
public void checkNewExp(NewExp e) {
ClassDecl d = (ClassDecl) e.lookup(new KindedName(Kind.CLASS, e.getClassName()));
List<Annotation> anns = AnnotationHelper.getAnnotationsOfType(d.getAnnotations(), "ABS.StdLib.ClassKindAnnotation");
if (!anns.isEmpty()) {
String name = ((DataConstructorExp) anns.get(0).getValue()).getDecl().getName();
if (e.hasLocal()) {
if (name.equals("COG")) {
errors.add(new TypeError(e, ErrorMessage.CLASSKIND_PLAIN, d.getName()));
}
} else {
if (!name.equals("COG")) {
errors.add(new TypeError(e, ErrorMessage.CLASSKIND_COG, d.getName()));
}
}
}
}
use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class SchedulerChecker method checkNewExp.
@Override
public void checkNewExp(NewExp e) {
Stmt stmt = CompilerUtils.findStmtForExpression(e);
PureExp sched = AnnotationHelper.getAnnotationValueFromName(stmt.getAnnotations(), "ABS.Scheduler.Scheduler");
if (sched != null) {
ClassDecl decl = (ClassDecl) (e.lookup(new KindedName(KindedName.Kind.CLASS, e.getClassName())));
checkScheduleExp(sched, decl, stmt);
}
}
use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class ASTBasedABSTestRunnerGenerator method generateImportsAST.
private List<Import> generateImportsAST() {
List<Import> imports = new List<>();
Set<String> mn = new HashSet<>();
Set<String> qn = new HashSet<>();
for (InterfaceDecl key : tests.keySet()) {
getImportsFrom(mn, qn, key.getModuleDecl());
for (ClassDecl clazz : tests.get(key)) {
getImportsFrom(mn, qn, clazz.getModuleDecl());
}
}
for (String m : mn) {
imports.add(new StarImport(m));
}
if (!qn.isEmpty()) {
List<Name> names = new List<>();
for (String q : qn) {
names.add(new Name(q));
}
imports.add(new NamedImport(names));
}
return imports;
}
use of org.abs_models.frontend.ast.ClassDecl 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;
}
Aggregations