本文整理汇总了Java中spoon.reflect.code.CtBinaryOperator.setLeftHandOperand方法的典型用法代码示例。如果您正苦于以下问题:Java CtBinaryOperator.setLeftHandOperand方法的具体用法?Java CtBinaryOperator.setLeftHandOperand怎么用?Java CtBinaryOperator.setLeftHandOperand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spoon.reflect.code.CtBinaryOperator
的用法示例。
在下文中一共展示了CtBinaryOperator.setLeftHandOperand方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createEqExpressionFromSwitchCase
import spoon.reflect.code.CtBinaryOperator; //导入方法依赖的package包/类
public CtExpression<Boolean> createEqExpressionFromSwitchCase(final @NotNull CtSwitch<?> switchStat, final @NotNull CtCase<?> caze) {
if(caze.getCaseExpression() == null) {// i.e. default case
return switchStat.getCases().stream().filter(c -> c.getCaseExpression() != null).
map(c -> negBoolExpression(createEqExpressionFromSwitchCase(switchStat, c))).reduce((a, b) -> andBoolExpression(a, b, false)).
orElseGet(() -> switchStat.getFactory().Code().createLiteral(Boolean.TRUE));
}
CtBinaryOperator<Boolean> exp = switchStat.getFactory().Core().createBinaryOperator();
// A switch is an equality test against values
exp.setKind(BinaryOperatorKind.EQ);
// The tested object
exp.setLeftHandOperand(switchStat.getSelector().clone());
// The tested constant
exp.setRightHandOperand(caze.getCaseExpression().clone());
return exp;
}
示例2: applyMono
import spoon.reflect.code.CtBinaryOperator; //导入方法依赖的package包/类
public void applyMono(CodeFragment tp) throws Exception {
transplantationPoint = tp;
Factory factory = getInputProgram().getFactory();
CtTypeReference tInt = factory.Type().INTEGER_PRIMITIVE;
CtLiteral one = factory.Core().createLiteral();
one.setValue(1);
CtReturn retStmt = (CtReturn) tp.getCtCodeFragment();
CtBinaryOperator retExpression = factory.Core().createBinaryOperator();
retExpression.setKind(BinaryOperatorKind.MUL);
retExpression.setRightHandOperand(retStmt.getReturnedExpression());
retExpression.setLeftHandOperand(one);
multiply = retExpression;
CtReturn retStmt2 = (CtReturn) factory.Core().clone(tp.getCtCodeFragment());
retStmt2.setReturnedExpression(retExpression);
tp.getCtCodeFragment().replace(retStmt2);
}
示例3: andBoolExpression
import spoon.reflect.code.CtBinaryOperator; //导入方法依赖的package包/类
public CtExpression<Boolean> andBoolExpression(final @NotNull CtExpression<Boolean> exp1, final @NotNull CtExpression<Boolean> exp2, final boolean clone) {
final CtBinaryOperator<Boolean> and = exp1.getFactory().Core().createBinaryOperator();
and.setKind(BinaryOperatorKind.AND);
if(clone) {
and.setLeftHandOperand(exp1.clone());
and.setRightHandOperand(exp2.clone());
}else {
and.setLeftHandOperand(exp1);
and.setRightHandOperand(exp2);
}
return and;
}