use of org.abs_models.frontend.ast.MethodSig in project abstools by abstools.
the class JavaGeneratorHelper method generateAsyncCall.
public static void generateAsyncCall(PrintStream stream, AsyncCall call) {
final PureExp callee = call.getCallee();
final List<PureExp> params = call.getParams();
final MethodSig sig = call.getMethodSig();
final List<Annotation> annotations = call.getAnnotations();
generateAsyncCall(stream, null, callee, callee.getType(), params, null, sig, annotations);
}
use of org.abs_models.frontend.ast.MethodSig in project abstools by abstools.
the class TypeCheckerTest method methodSigs.
@Test
public void methodSigs() {
Model m = assertParse("interface I { Unit m(); } interface J { Unit n(); } interface K extends I, J { Unit foo(); } { K k; } ");
ModuleDecl module = m.lookupModule("UnitTest");
InterfaceDecl d = (InterfaceDecl) module.getDecl(2);
ArrayList<MethodSig> list = new ArrayList<>(d.getAllMethodSigs());
assertEquals(list.toString(), 3, list.size());
VarDeclStmt stmt = (VarDeclStmt) module.getBlock().getStmt(0);
Collection<MethodSig> sigs = stmt.getVarDecl().getTypeUse().getType().getAllMethodSigs();
assertArrayEquals(sigs.toArray(), d.getAllMethodSigs().toArray());
}
use of org.abs_models.frontend.ast.MethodSig 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.MethodSig 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