use of org.abs_models.frontend.ast.List in project abstools by abstools.
the class AbsASTBuilderUtil method createMethodSig.
public static final MethodSig createMethodSig(String methodName, TypeUse returnType, ParamDecl... decls) {
List<ParamDecl> dl = new List<>();
for (ParamDecl d : decls) {
dl.add(d);
}
MethodSig method = new MethodSig(methodName, returnType, dl);
return method;
}
use of org.abs_models.frontend.ast.List in project abstools by abstools.
the class ASTBasedABSTestRunnerGenerator method generateAsyncTestCallAST.
private void generateAsyncTestCallAST(Block block, String objectRef, MethodSig method) {
List<PureExp> args = new List<>();
if (method.getNumParam() > 0) {
args.add(new VarUse(dataValue));
}
block.addStmtNoTransform(getVAssign(fut, new AsyncCall(new VarUse(objectRef), method.getName(), args)));
block.addStmtNoTransform(getVAssign(futs, getFnApp("Insert", new VarUse(fut), new VarUse(futs))));
}
use of org.abs_models.frontend.ast.List in project abstools by abstools.
the class Main method parseFiles.
private static Model parseFiles(boolean verbose, final java.util.List<File> fileNames) throws IOException, InternalBackendException {
if (fileNames.isEmpty()) {
throw new IllegalArgumentException("Please provide at least one input file");
}
java.util.List<CompilationUnit> units = new ArrayList<>();
for (File f : fileNames) {
if (!f.canRead()) {
throw new IllegalArgumentException("File " + f + " cannot be read");
}
if (!f.isDirectory() && !isABSSourceFile(f) && !isABSPackageFile(f)) {
throw new IllegalArgumentException("File " + f + " is not a legal ABS file");
}
}
for (File f : fileNames) {
parseFileOrDirectory(units, f, verbose);
}
units.add(getStdLib());
List<CompilationUnit> unitList = new List<>();
for (CompilationUnit u : units) {
unitList.add(u);
}
Model m = new Model(unitList);
return m;
}
use of org.abs_models.frontend.ast.List in project abstools by abstools.
the class TraitTest method addModifyModifierAtRuntimeBackComp.
@Test
public void addModifyModifierAtRuntimeBackComp() {
Model model = assertParse("module M;" + "class C { Unit m(){skip;} }");
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
MethodSig sig = AbsASTBuilderUtil.createMethodSig("m", AbsASTBuilderUtil.getUnit());
MethodImpl impl = new MethodImpl(sig, new Block(new List<>(), new List<>(new SkipStmt(), new SkipStmt())));
ModifyMethodModifier opr = new ModifyMethodModifier(impl);
assertNotNull(opr.getMethodImpl());
ModifyClassModifier mcn = new ModifyClassModifier();
mcn.setName("M.C");
DeltaAccess acc = new DeltaAccess(cls.getModuleDecl().getName());
DeltaDecl dd = new DeltaDecl();
dd.setName("MyDelta");
dd.setImportedModule(acc);
dd.addModuleModifier(mcn);
mcn.addModifier(opr);
mcn.setParent(dd);
acc.setParent(dd);
opr.setParent(mcn);
sig.setParent(opr);
CompilationUnit cu = model.getCompilationUnitList().getChild(0);
cu.addDeltaDecl(dd);
dd.setParent(cu);
model.applyDelta(dd);
assertEquals(1, cls.getMethods().getNumChild());
assertEquals(2, cls.getMethod(0).getBlock().getNumChild());
}
use of org.abs_models.frontend.ast.List in project abstools by abstools.
the class TraitTest method addRemoveModifierAtRuntime.
@Test
public void addRemoveModifierAtRuntime() {
Model model = assertParse("module M;" + "class C { Unit m(){skip;} }");
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
MethodSig sig = AbsASTBuilderUtil.createMethodSig("m", AbsASTBuilderUtil.getUnit());
List<MethodSig> l = new List<>(sig);
RemoveMethodModifier opr = new RemoveMethodModifier(l);
ModifyClassModifier mcn = new ModifyClassModifier();
mcn.setName("M.C");
DeltaAccess acc = new DeltaAccess(cls.getModuleDecl().getName());
DeltaDecl dd = new DeltaDecl();
dd.setName("MyDelta");
dd.setImportedModule(acc);
dd.addModuleModifier(mcn);
mcn.addModifier(opr);
mcn.setParent(dd);
acc.setParent(dd);
opr.setParent(mcn);
sig.setParent(opr);
CompilationUnit cu = model.getCompilationUnitList().getChild(0);
cu.addDeltaDecl(dd);
dd.setParent(cu);
model.applyDelta(dd);
assertEquals(0, cls.getMethods().getNumChild());
}
Aggregations