Search in sources :

Example 11 with MethodSig

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);
}
Also used : MethodSig(org.abs_models.frontend.ast.MethodSig) PureExp(org.abs_models.frontend.ast.PureExp) Annotation(org.abs_models.frontend.ast.Annotation)

Example 12 with MethodSig

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());
}
Also used : MethodSig(org.abs_models.frontend.ast.MethodSig) VarDeclStmt(org.abs_models.frontend.ast.VarDeclStmt) Model(org.abs_models.frontend.ast.Model) ArrayList(java.util.ArrayList) ModuleDecl(org.abs_models.frontend.ast.ModuleDecl) InterfaceDecl(org.abs_models.frontend.ast.InterfaceDecl) ABSTest(org.abs_models.ABSTest) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 13 with MethodSig

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());
}
Also used : CompilationUnit(org.abs_models.frontend.ast.CompilationUnit) MethodSig(org.abs_models.frontend.ast.MethodSig) ClassDecl(org.abs_models.frontend.ast.ClassDecl) MethodImpl(org.abs_models.frontend.ast.MethodImpl) ModifyMethodModifier(org.abs_models.frontend.ast.ModifyMethodModifier) DeltaAccess(org.abs_models.frontend.ast.DeltaAccess) Model(org.abs_models.frontend.ast.Model) Block(org.abs_models.frontend.ast.Block) List(org.abs_models.frontend.ast.List) DeltaDecl(org.abs_models.frontend.ast.DeltaDecl) SkipStmt(org.abs_models.frontend.ast.SkipStmt) ModifyClassModifier(org.abs_models.frontend.ast.ModifyClassModifier) Test(org.junit.Test)

Example 14 with MethodSig

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());
}
Also used : CompilationUnit(org.abs_models.frontend.ast.CompilationUnit) MethodSig(org.abs_models.frontend.ast.MethodSig) RemoveMethodModifier(org.abs_models.frontend.ast.RemoveMethodModifier) ClassDecl(org.abs_models.frontend.ast.ClassDecl) DeltaAccess(org.abs_models.frontend.ast.DeltaAccess) Model(org.abs_models.frontend.ast.Model) List(org.abs_models.frontend.ast.List) DeltaDecl(org.abs_models.frontend.ast.DeltaDecl) ModifyClassModifier(org.abs_models.frontend.ast.ModifyClassModifier) Test(org.junit.Test)

Aggregations

MethodSig (org.abs_models.frontend.ast.MethodSig)14 List (org.abs_models.frontend.ast.List)4 Model (org.abs_models.frontend.ast.Model)4 Test (org.junit.Test)4 HashSet (java.util.HashSet)3 Block (org.abs_models.frontend.ast.Block)3 ClassDecl (org.abs_models.frontend.ast.ClassDecl)3 CompilationUnit (org.abs_models.frontend.ast.CompilationUnit)3 DeltaAccess (org.abs_models.frontend.ast.DeltaAccess)3 DeltaDecl (org.abs_models.frontend.ast.DeltaDecl)3 MethodImpl (org.abs_models.frontend.ast.MethodImpl)3 ModifyClassModifier (org.abs_models.frontend.ast.ModifyClassModifier)3 ParamDecl (org.abs_models.frontend.ast.ParamDecl)3 Annotation (org.abs_models.frontend.ast.Annotation)2 DataTypeUse (org.abs_models.frontend.ast.DataTypeUse)2 InterfaceDecl (org.abs_models.frontend.ast.InterfaceDecl)2 ParametricDataTypeUse (org.abs_models.frontend.ast.ParametricDataTypeUse)2 PureExp (org.abs_models.frontend.ast.PureExp)2 SkipStmt (org.abs_models.frontend.ast.SkipStmt)2 TypeUse (org.abs_models.frontend.ast.TypeUse)2