Search in sources :

Example 1 with Annotation

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

the class ABSUnitTestCaseTranslatorHelper method createTestClass.

ClassDecl createTestClass(InterfaceDecl inf) {
    ClassDecl ct = new ClassDecl(testCaseNameBuilder.className(inf.getName()), new abs.frontend.ast.List<Annotation>(), new abs.frontend.ast.List<ParamDecl>(), new abs.frontend.ast.List<InterfaceTypeUse>(), new Opt<InitBlock>(), new abs.frontend.ast.List<CaseBranchStmt>(), new abs.frontend.ast.List<FieldDecl>(), new abs.frontend.ast.List<MethodImpl>());
    ct.addAnnotation(getTestAnnotation(suiteType));
    ct.addImplementedInterfaceUse(new InterfaceTypeUse(inf.getName(), new abs.frontend.ast.List<abs.frontend.ast.Annotation>()));
    for (MethodSig m : inf.getAllMethodSigs()) {
        ct.addMethod(createMethodImpl(m));
    }
    FieldDecl assertImpl = new FieldDecl();
    assertImpl.setName(ASSERT_HELPER);
    assertImpl.setAccess(absAssertImpl.getImplementedInterfaceUse(0).treeCopyNoTransform());
    ct.addField(assertImpl);
    InitBlock block = new InitBlock();
    block.addStmtNoTransform(getVAssign(ASSERT_HELPER, newObj(absAssertImpl, false)));
    ct.setInitBlock(block);
    return ct;
}
Also used : InitBlock(abs.frontend.ast.InitBlock) CaseBranchStmt(abs.frontend.ast.CaseBranchStmt) Annotation(abs.frontend.ast.Annotation) FieldDecl(abs.frontend.ast.FieldDecl) AbsASTBuilderUtil.createMethodSig(abs.backend.tests.AbsASTBuilderUtil.createMethodSig) MethodSig(abs.frontend.ast.MethodSig) ClassDecl(abs.frontend.ast.ClassDecl) AbsASTBuilderUtil.createMethodImpl(abs.backend.tests.AbsASTBuilderUtil.createMethodImpl) MethodImpl(abs.frontend.ast.MethodImpl) ParamDecl(abs.frontend.ast.ParamDecl) InterfaceTypeUse(abs.frontend.ast.InterfaceTypeUse)

Example 2 with Annotation

use of abs.frontend.ast.Annotation 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 3 with Annotation

use of abs.frontend.ast.Annotation 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()));
            }
        }
    }
}
Also used : ClassDecl(abs.frontend.ast.ClassDecl) TypeError(abs.frontend.analyser.TypeError) KindedName(abs.frontend.typechecker.KindedName) Annotation(abs.frontend.ast.Annotation)

Example 4 with Annotation

use of abs.frontend.ast.Annotation 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 5 with Annotation

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

Aggregations

Annotation (abs.frontend.ast.Annotation)11 MethodSig (abs.frontend.ast.MethodSig)6 PureExp (abs.frontend.ast.PureExp)4 AbsASTBuilderUtil.createMethodSig (abs.backend.tests.AbsASTBuilderUtil.createMethodSig)3 ClassDecl (abs.frontend.ast.ClassDecl)3 IntLiteral (abs.frontend.ast.IntLiteral)3 MethodImpl (abs.frontend.ast.MethodImpl)3 ParamDecl (abs.frontend.ast.ParamDecl)3 TypedAnnotation (abs.frontend.ast.TypedAnnotation)3 AddMethodModifier (abs.frontend.ast.AddMethodModifier)2 Block (abs.frontend.ast.Block)2 FieldUse (abs.frontend.ast.FieldUse)2 AbsASTBuilderUtil.createMethodImpl (abs.backend.tests.AbsASTBuilderUtil.createMethodImpl)1 TypeError (abs.frontend.analyser.TypeError)1 CaseBranchStmt (abs.frontend.ast.CaseBranchStmt)1 CompilationUnit (abs.frontend.ast.CompilationUnit)1 DataConstructorExp (abs.frontend.ast.DataConstructorExp)1 Decl (abs.frontend.ast.Decl)1 FieldDecl (abs.frontend.ast.FieldDecl)1 InitBlock (abs.frontend.ast.InitBlock)1