@SuppressWarnings("unchecked") @Override public <T, U> U getValue(T element) { return ((U) ((Object) (castTarget(element).getOperand()))); }
@Override public <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) { if (operator.getOperand() == null && child instanceof CtExpression) { operator.setOperand((CtExpression<T>) child); return; } super.visitCtUnaryOperator(operator); }
public <T> void visitCtUnaryOperator(final spoon.reflect.code.CtUnaryOperator<T> operator) { spoon.reflect.code.CtUnaryOperator other = ((spoon.reflect.code.CtUnaryOperator) (this.stack.peek())); enter(operator); biScan(spoon.reflect.path.CtRole.ANNOTATION, operator.getAnnotations(), other.getAnnotations()); biScan(spoon.reflect.path.CtRole.TYPE, operator.getType(), other.getType()); biScan(spoon.reflect.path.CtRole.CAST, operator.getTypeCasts(), other.getTypeCasts()); biScan(spoon.reflect.path.CtRole.EXPRESSION, operator.getOperand(), other.getOperand()); biScan(spoon.reflect.path.CtRole.COMMENT, operator.getComments(), other.getComments()); exit(operator); }
@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()); }
public <T> void visitCtUnaryOperator(final CtUnaryOperator<T> operator) { enter(operator); scan(CtRole.ANNOTATION, operator.getAnnotations()); scan(CtRole.TYPE, operator.getType()); scan(CtRole.CAST, operator.getTypeCasts()); scan(CtRole.EXPRESSION, operator.getOperand()); scan(CtRole.COMMENT, operator.getComments()); exit(operator); }
@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); }
@java.lang.Override public <T> void visitCtUnaryOperator(final spoon.reflect.code.CtUnaryOperator<T> operator) { replaceInListIfExist(operator.getAnnotations(), new spoon.support.visitor.replace.ReplacementVisitor.CtElementAnnotationsReplaceListener(operator)); replaceElementIfExist(operator.getType(), new spoon.support.visitor.replace.ReplacementVisitor.CtTypedElementTypeReplaceListener(operator)); replaceInListIfExist(operator.getTypeCasts(), new spoon.support.visitor.replace.ReplacementVisitor.CtExpressionTypeCastsReplaceListener(operator)); replaceElementIfExist(operator.getOperand(), new spoon.support.visitor.replace.ReplacementVisitor.CtUnaryOperatorOperandReplaceListener(operator)); replaceInListIfExist(operator.getComments(), new spoon.support.visitor.replace.ReplacementVisitor.CtElementCommentsReplaceListener(operator)); }
public <T> void visitCtUnaryOperator(final spoon.reflect.code.CtUnaryOperator<T> operator) { spoon.reflect.code.CtUnaryOperator<T> aCtUnaryOperator = operator.getFactory().Core().createUnaryOperator(); this.builder.copy(operator, aCtUnaryOperator); aCtUnaryOperator.setAnnotations(this.cloneHelper.clone(operator.getAnnotations())); aCtUnaryOperator.setType(this.cloneHelper.clone(operator.getType())); aCtUnaryOperator.setTypeCasts(this.cloneHelper.clone(operator.getTypeCasts())); aCtUnaryOperator.setOperand(this.cloneHelper.clone(operator.getOperand())); aCtUnaryOperator.setComments(this.cloneHelper.clone(operator.getComments())); this.cloneHelper.tailor(operator, aCtUnaryOperator); this.other = aCtUnaryOperator; }
@Override public <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) { addFrom(operator); scan(operator.getOperand()); }
@Override public <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) { if (operator.getOperand() == null && child instanceof CtExpression) { operator.setOperand((CtExpression<T>) child); return; } super.visitCtUnaryOperator(operator); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) { super.visitCtUnaryOperator(operator); CtExpression exper=operator.getOperand(); if (candidates.containsKey(exper)) { operator.setOperand(candidates.get(exper)); saveSketchAndSynthesize(); operator.setOperand(exper); resoreDiskFile(); } }
public static List<CtExpression<Boolean>> getExpressions(CtExpression<Boolean> element) { List<CtExpression<Boolean>> expsRetrieved = new ArrayList<CtExpression<Boolean>>(); if (element instanceof CtUnaryOperator) { expsRetrieved.add(element); element = ((CtUnaryOperator) element).getOperand(); } if (element instanceof CtBinaryOperator) { expsRetrieved.add(element); CtBinaryOperator bin = (CtBinaryOperator) element; if (bin.getKind().equals(BinaryOperatorKind.AND) || bin.getKind().equals(BinaryOperatorKind.OR)) { expsRetrieved.addAll(getExpressions(bin.getLeftHandOperand())); expsRetrieved.addAll(getExpressions(bin.getRightHandOperand())); } } else { if (element instanceof CtInvocation && element.getType().getSimpleName().equals(boolean.class.getSimpleName())) { expsRetrieved.add(element); } } return expsRetrieved; }
public <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) { scan(operator.getOperand()); write(operator.getKind().toString()); }
@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; }
public <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) { enter(operator); scan(operator.getAnnotations()); scan(operator.getType()); scanReferences(operator.getTypeCasts()); scan(operator.getOperand()); exit(operator); }
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)); }
CtExpression clone = ((CtExpression) argument).clone(); if (clone instanceof CtUnaryOperator) { clone = ((CtUnaryOperator) clone).getOperand();