Search in sources :

Example 1 with FieldUse

use of abs.frontend.ast.FieldUse 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 2 with FieldUse

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

the class DeltaForGetSetFieldsBuilder method addGetter.

AddMethodModifier addGetter(Exp returnValue, String fieldName, Access returnType) {
    MethodSig sig = new MethodSig(testCaseNameBuilder.getterMethodName(fieldName), new abs.frontend.ast.List<Annotation>(), returnType, new abs.frontend.ast.List<ParamDecl>());
    Block block = new Block();
    ReturnStmt rs = new ReturnStmt();
    rs.setRetExp(new FieldUse(fieldName));
    block.addStmtNoTransform(rs);
    MethodImpl method = new MethodImpl(sig, block, false);
    AddMethodModifier modifier = new AddMethodModifier(method);
    return modifier;
}
Also used : 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) AddMethodModifier(abs.frontend.ast.AddMethodModifier) Block(abs.frontend.ast.Block) ReturnStmt(abs.frontend.ast.ReturnStmt) Annotation(abs.frontend.ast.Annotation)

Aggregations

AbsASTBuilderUtil.createMethodSig (abs.backend.tests.AbsASTBuilderUtil.createMethodSig)2 AddMethodModifier (abs.frontend.ast.AddMethodModifier)2 Annotation (abs.frontend.ast.Annotation)2 Block (abs.frontend.ast.Block)2 FieldUse (abs.frontend.ast.FieldUse)2 MethodImpl (abs.frontend.ast.MethodImpl)2 MethodSig (abs.frontend.ast.MethodSig)2 ParamDecl (abs.frontend.ast.ParamDecl)2 ReturnStmt (abs.frontend.ast.ReturnStmt)1 VarUse (abs.frontend.ast.VarUse)1