@Override public boolean visit(PrefixExpression prefixExpression, BlockScope scope) { CtUnaryOperator<?> op = factory.Core().createUnaryOperator(); if (prefixExpression.operator == OperatorIds.PLUS) { op.setKind(UnaryOperatorKind.PREINC); } if (prefixExpression.operator == OperatorIds.MINUS) { op.setKind(UnaryOperatorKind.PREDEC); } context.enter(op, prefixExpression); return true; }
@Override public boolean visit(PostfixExpression postfixExpression, BlockScope scope) { CtUnaryOperator<?> op = factory.Core().createUnaryOperator(); if (postfixExpression.operator == OperatorIds.PLUS) { op.setKind(UnaryOperatorKind.POSTINC); } if (postfixExpression.operator == OperatorIds.MINUS) { op.setKind(UnaryOperatorKind.POSTDEC); } context.enter(op, postfixExpression); return true; }
@Override public <T, U> void setValue(T element, U value) { castTarget(element).setKind(castValue(value)); } }
@Override public boolean visit(UnaryExpression unaryExpression, BlockScope scope) { CtUnaryOperator<?> op = factory.Core().createUnaryOperator(); op.setKind(getUnaryOperator((unaryExpression.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT)); context.enter(op, unaryExpression); return true; }
public <T> void visitCtUnaryOperator(spoon.reflect.code.CtUnaryOperator<T> e) { ((spoon.reflect.code.CtUnaryOperator<T>) (other)).setKind(e.getKind()); ((spoon.reflect.code.CtUnaryOperator<T>) (other)).setLabel(e.getLabel()); super.visitCtUnaryOperator(e); }
@Override public boolean visit(PostfixExpression postfixExpression, BlockScope scope) { CtUnaryOperator<?> op = factory.Core().createUnaryOperator(); if (postfixExpression.operator == OperatorIds.PLUS) { op.setKind(UnaryOperatorKind.POSTINC); } if (postfixExpression.operator == OperatorIds.MINUS) { op.setKind(UnaryOperatorKind.POSTDEC); } context.enter(op, postfixExpression); return true; }
@Override public boolean visit(PrefixExpression prefixExpression, BlockScope scope) { CtUnaryOperator<?> op = factory.Core().createUnaryOperator(); if (prefixExpression.operator == OperatorIds.PLUS) { op.setKind(UnaryOperatorKind.PREINC); } if (prefixExpression.operator == OperatorIds.MINUS) { op.setKind(UnaryOperatorKind.PREDEC); } context.enter(op, prefixExpression); return true; }
@Override public boolean visit(UnaryExpression unaryExpression, BlockScope scope) { CtUnaryOperator<?> op = factory.Core().createUnaryOperator(); op.setKind(getUnaryOperator((unaryExpression.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT)); context.enter(op, unaryExpression); return true; }
@Override public List<MutantCtElement> execute(CtElement toMutate) { //List<CtElement> result = new ArrayList<CtElement>(); List<MutantCtElement> result = new ArrayList<MutantCtElement>(); if (toMutate instanceof CtUnaryOperator<?>) { CtUnaryOperator<?> unary = (CtUnaryOperator<?>) toMutate; if (unary.getKind() == UnaryOperatorKind.NOT) { CtExpression expIF = factory.Core().clone(unary.getOperand()); MutantCtElement mutatn = new MutantCtElement(expIF,0.3); //result.add(expIF); result.add(mutatn); } } else { if (toMutate instanceof CtTypedElement<?>) { CtExpression<?> inv = (CtExpression<?>) toMutate; if (inv.getType()!= null && inv.getType().getSimpleName().equals(boolean.class.getSimpleName())) { CtExpression<?> invClone = factory.Core().clone(inv); CtUnaryOperator unary = factory.Core().createUnaryOperator(); unary.setOperand(invClone); unary.setKind(UnaryOperatorKind.NOT); //result.add(unary); MutantCtElement mutatn = new MutantCtElement(unary,3); //result.add(expIF); result.add(mutatn); } } } return result; }
private CtIf createNotInitIf() { CtIf ctIf = f().Core().createIf(); CtUnaryOperator<Boolean> negInit = f().Core().createUnaryOperator(); negInit.setKind(NOT); negInit.setOperand(createStageInitInvocation()); ctIf.setCondition(negInit); return ctIf; }