@SuppressWarnings("unchecked") @Override public <T, U> U getValue(T element) { return ((U) ((Object) (castTarget(element).getKind()))); }
@Override public <T> void visitCtUnaryOperator(CtUnaryOperator<T> e) { final CtUnaryOperator peek = (CtUnaryOperator) this.other; if (e.getKind() == null) { if (peek.getKind() != null) { setNotEqual(CtRole.OPERATOR_KIND); } } else if (peek.getKind() == null) { setNotEqual(CtRole.OPERATOR_KIND); } else if (!e.getKind().equals(peek.getKind())) { setNotEqual(CtRole.OPERATOR_KIND); } super.visitCtUnaryOperator(e); }
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 <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) { CtExpression<?> operand = evaluate(operator.getOperand()); if (operand instanceof CtLiteral) { Object object = ((CtLiteral<?>) operand).getValue(); CtLiteral<Object> res = operator.getFactory().Core().createLiteral(); switch (operator.getKind()) { case NOT: res.setValue(!(Boolean) object); break; default: throw new RuntimeException("unsupported operator " + operator.getKind()); } setResult(res); return; } setResult(operator.clone()); }
@Override public <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) { enterCtStatement(operator); enterCtExpression(operator); UnaryOperatorKind op = operator.getKind(); if (OperatorHelper.isPrefixOperator(op)) { printer.writeOperator(OperatorHelper.getOperatorText(op)); } scan(operator.getOperand()); if (OperatorHelper.isSufixOperator(op)) { printer.writeOperator(OperatorHelper.getOperatorText(op)); } exitCtExpression(operator); exitCtStatement(operator); }
@Override public <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) { label = operator.getKind().toString(); }
@Override public <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) { label = operator.getKind().toString(); }
public <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) { scan(operator.getOperand()); write(operator.getKind().toString()); }
public <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) { enterCtStatement(operator); enterCtExpression(operator); preWriteUnaryOperator(operator.getKind()); context.enterTarget(); scan(operator.getOperand()); context.exitTarget(); postWriteUnaryOperator(operator.getKind()); exitCtExpression(operator); }
public <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) { CtExpression<?> operand = evaluate(operator, operator.getOperand()); if (operand instanceof CtLiteral) { Object object = ((CtLiteral<?>) operand).getValue(); CtLiteral<Object> res = operator.getFactory().Core().createLiteral(); switch (operator.getKind()) { case NOT: res.setValue(!(Boolean) object); break; default: throw new RuntimeException("unsupported operator " + operator.getKind()); } setResult(res); return; } setResult(operator.getFactory().Core().clone(operator)); }
@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; }
if (parent.getKind().equals(UnaryOperatorKind.NEG)) { toReplace = parent;