use of com.strobel.decompiler.languages.java.ast.BinaryOperatorExpression in project j2objc by google.
the class MethodTranslator method visitBinaryOperatorExpression.
@Override
public TreeNode visitBinaryOperatorExpression(BinaryOperatorExpression node, Void data) {
Expression leftExpr = (Expression) node.getLeft().acceptVisitor(this, null);
Expression rightExpr = (Expression) node.getRight().acceptVisitor(this, null);
InfixExpression binaryExpr = new InfixExpression().addOperand(leftExpr).addOperand(rightExpr);
switch(node.getOperator()) {
case BITWISE_AND:
binaryExpr.setOperator(InfixExpression.Operator.AND).setTypeMirror(typeUtil.binaryNumericPromotion(leftExpr.getTypeMirror(), rightExpr.getTypeMirror()));
break;
case BITWISE_OR:
binaryExpr.setOperator(InfixExpression.Operator.OR).setTypeMirror(typeUtil.binaryNumericPromotion(leftExpr.getTypeMirror(), rightExpr.getTypeMirror()));
break;
case EXCLUSIVE_OR:
binaryExpr.setOperator(InfixExpression.Operator.XOR).setTypeMirror(typeUtil.binaryNumericPromotion(leftExpr.getTypeMirror(), rightExpr.getTypeMirror()));
break;
case LOGICAL_AND:
binaryExpr.setOperator(InfixExpression.Operator.CONDITIONAL_AND).setTypeMirror(typeUtil.getBoolean());
break;
case LOGICAL_OR:
binaryExpr.setOperator(InfixExpression.Operator.CONDITIONAL_OR).setTypeMirror(typeUtil.getBoolean());
break;
case GREATER_THAN:
binaryExpr.setOperator(InfixExpression.Operator.GREATER).setTypeMirror(typeUtil.getBoolean());
break;
case GREATER_THAN_OR_EQUAL:
binaryExpr.setOperator(InfixExpression.Operator.GREATER_EQUALS).setTypeMirror(typeUtil.getBoolean());
break;
case LESS_THAN:
binaryExpr.setOperator(InfixExpression.Operator.LESS).setTypeMirror(typeUtil.getBoolean());
break;
case LESS_THAN_OR_EQUAL:
binaryExpr.setOperator(InfixExpression.Operator.LESS_EQUALS).setTypeMirror(typeUtil.getBoolean());
break;
case EQUALITY:
binaryExpr.setOperator(InfixExpression.Operator.EQUALS).setTypeMirror(typeUtil.getBoolean());
break;
case INEQUALITY:
binaryExpr.setOperator(InfixExpression.Operator.NOT_EQUALS).setTypeMirror(typeUtil.getBoolean());
break;
case ADD:
binaryExpr.setOperator(InfixExpression.Operator.PLUS).setTypeMirror(typeUtil.binaryNumericPromotion(leftExpr.getTypeMirror(), rightExpr.getTypeMirror()));
break;
case SUBTRACT:
binaryExpr.setOperator(InfixExpression.Operator.MINUS).setTypeMirror(typeUtil.binaryNumericPromotion(leftExpr.getTypeMirror(), rightExpr.getTypeMirror()));
break;
case MULTIPLY:
binaryExpr.setOperator(InfixExpression.Operator.TIMES).setTypeMirror(typeUtil.binaryNumericPromotion(leftExpr.getTypeMirror(), rightExpr.getTypeMirror()));
break;
case DIVIDE:
binaryExpr.setOperator(InfixExpression.Operator.DIVIDE).setTypeMirror(typeUtil.binaryNumericPromotion(leftExpr.getTypeMirror(), rightExpr.getTypeMirror()));
break;
case MODULUS:
binaryExpr.setOperator(InfixExpression.Operator.REMAINDER).setTypeMirror(typeUtil.binaryNumericPromotion(leftExpr.getTypeMirror(), rightExpr.getTypeMirror()));
break;
case SHIFT_LEFT:
binaryExpr.setOperator(InfixExpression.Operator.LEFT_SHIFT).setTypeMirror(typeUtil.unaryNumericPromotion(leftExpr.getTypeMirror()));
break;
case SHIFT_RIGHT:
binaryExpr.setOperator(InfixExpression.Operator.RIGHT_SHIFT_SIGNED).setTypeMirror(typeUtil.unaryNumericPromotion(leftExpr.getTypeMirror()));
break;
case UNSIGNED_SHIFT_RIGHT:
binaryExpr.setOperator(InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED).setTypeMirror(typeUtil.unaryNumericPromotion(leftExpr.getTypeMirror()));
break;
default:
throw new AssertionError("Unsupported infix operator: " + node.getOperator());
}
return binaryExpr;
}
Aggregations