Search in sources :

Example 6 with MethodSig

use of abs.frontend.ast.MethodSig in project abstools by abstools.

the class DeltaForGetSetFieldsBuilder method addSetter.

/**
 * Add an add method modifier
 * @param fieldName
 * @param exp
 * @param decl
 * @return
 */
AddMethodModifier addSetter(String fieldName, Access type) {
    MethodSig sig = new MethodSig(testCaseNameBuilder.setterMethodName(fieldName), new abs.frontend.ast.List<Annotation>(), getUnit(), new abs.frontend.ast.List<ParamDecl>());
    sig.addParam(new ParamDecl("v", type, new abs.frontend.ast.List<Annotation>()));
    Block block = new Block();
    block.addStmtNoTransform(getVAssign(new FieldUse(fieldName), new VarUse("v")));
    MethodImpl method = new MethodImpl(sig, block, false);
    AddMethodModifier modifier = new AddMethodModifier(method);
    return modifier;
}
Also used : AddMethodModifier(abs.frontend.ast.AddMethodModifier) VarUse(abs.frontend.ast.VarUse) Annotation(abs.frontend.ast.Annotation) AbsASTBuilderUtil.createMethodSig(abs.backend.tests.AbsASTBuilderUtil.createMethodSig) MethodSig(abs.frontend.ast.MethodSig) MethodImpl(abs.frontend.ast.MethodImpl) ParamDecl(abs.frontend.ast.ParamDecl) FieldUse(abs.frontend.ast.FieldUse) Block(abs.frontend.ast.Block)

Example 7 with MethodSig

use of abs.frontend.ast.MethodSig in project abstools by abstools.

the class JavaGeneratorHelper method generateAsyncMethod.

public static void generateAsyncMethod(PrintStream stream, MethodImpl method) {
    final MethodSig sig = method.getMethodSig();
    generateMethodSig(stream, sig, true, "final", "");
    stream.println(" {");
    stream.print("return (" + ABSFut.class.getName() + ")");
    generateAsyncCall(stream, "this", null, method.getContextDecl().getType(), null, sig.getParams(), sig, new List<>());
    stream.println(";");
    stream.println("}");
}
Also used : ABSFut(abs.backend.java.lib.runtime.ABSFut) MethodSig(abs.frontend.ast.MethodSig)

Example 8 with MethodSig

use of abs.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(abs.frontend.ast.MethodSig) PureExp(abs.frontend.ast.PureExp) Annotation(abs.frontend.ast.Annotation)

Example 9 with MethodSig

use of abs.frontend.ast.MethodSig in project abstools by abstools.

the class ABSUnitRunner method analyzeModelUnit.

private void analyzeModelUnit(Model model) {
    System.out.println("Analyzing model:");
    for (CompilationUnit cu : model.getCompilationUnits()) {
        System.out.println(cu.getFileName());
        for (ModuleDecl m : cu.getModuleDecls()) {
            for (Decl cd : m.getDecls()) {
                if (cd instanceof ClassDecl) {
                    for (MethodSig ms : ((ClassDecl) cd).getAllMethodSigs()) {
                        for (Annotation a : ms.getAnnotations()) {
                            if (a.getType().getSimpleName().equals("Test")) {
                                System.out.println("Found test method:" + ms.getName());
                                testMethods.add(ms);
                            } else if (a.getType().getSimpleName().equals("Suite")) {
                                System.out.println("Found test suite:" + ms.getName());
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : CompilationUnit(abs.frontend.ast.CompilationUnit) MethodSig(abs.frontend.ast.MethodSig) ClassDecl(abs.frontend.ast.ClassDecl) ModuleDecl(abs.frontend.ast.ModuleDecl) ModuleDecl(abs.frontend.ast.ModuleDecl) ClassDecl(abs.frontend.ast.ClassDecl) Decl(abs.frontend.ast.Decl) Annotation(abs.frontend.ast.Annotation)

Example 10 with MethodSig

use of abs.frontend.ast.MethodSig in project abstools by abstools.

the class TraitTest method addModifyModifierAtRuntimeBackComp.

@Test
public void addModifyModifierAtRuntimeBackComp() {
    Model model = assertParseOk("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())), false);
    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.addDeltaAccess(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(abs.frontend.ast.CompilationUnit) MethodSig(abs.frontend.ast.MethodSig) ClassDecl(abs.frontend.ast.ClassDecl) MethodImpl(abs.frontend.ast.MethodImpl) ModifyMethodModifier(abs.frontend.ast.ModifyMethodModifier) DeltaAccess(abs.frontend.ast.DeltaAccess) Model(abs.frontend.ast.Model) Block(abs.frontend.ast.Block) List(abs.frontend.ast.List) DeltaDecl(abs.frontend.ast.DeltaDecl) SkipStmt(abs.frontend.ast.SkipStmt) ModifyClassModifier(abs.frontend.ast.ModifyClassModifier) Test(org.junit.Test)

Aggregations

MethodSig (abs.frontend.ast.MethodSig)18 MethodImpl (abs.frontend.ast.MethodImpl)7 Annotation (abs.frontend.ast.Annotation)6 Block (abs.frontend.ast.Block)6 ClassDecl (abs.frontend.ast.ClassDecl)6 AbsASTBuilderUtil.createMethodSig (abs.backend.tests.AbsASTBuilderUtil.createMethodSig)4 CompilationUnit (abs.frontend.ast.CompilationUnit)4 DeltaAccess (abs.frontend.ast.DeltaAccess)4 DeltaDecl (abs.frontend.ast.DeltaDecl)4 List (abs.frontend.ast.List)4 ModifyClassModifier (abs.frontend.ast.ModifyClassModifier)4 ParamDecl (abs.frontend.ast.ParamDecl)4 AddMethodModifier (abs.frontend.ast.AddMethodModifier)3 Model (abs.frontend.ast.Model)3 VarUse (abs.frontend.ast.VarUse)3 Test (org.junit.Test)3 Access (abs.frontend.ast.Access)2 DataTypeUse (abs.frontend.ast.DataTypeUse)2 FieldUse (abs.frontend.ast.FieldUse)2 ModifyMethodModifier (abs.frontend.ast.ModifyMethodModifier)2