use of org.objectweb.asm.Opcodes.I2B in project groovy by apache.
the class StaticTypesUnaryExpressionHelper method writeBitwiseNegate.
@Override
public void writeBitwiseNegate(final BitwiseNegationExpression expression) {
expression.getExpression().visit(controller.getAcg());
ClassNode top = controller.getOperandStack().getTopOperand();
if (isPrimitiveInt(top) || isPrimitiveLong(top) || isPrimitiveShort(top) || isPrimitiveByte(top) || isPrimitiveChar(top)) {
bytecodeX(mv -> {
if (isPrimitiveLong(top)) {
mv.visitLdcInsn(-1L);
mv.visitInsn(LXOR);
} else {
mv.visitInsn(ICONST_M1);
mv.visitInsn(IXOR);
if (isPrimitiveByte(top)) {
mv.visitInsn(I2B);
} else if (isPrimitiveChar(top)) {
mv.visitInsn(I2C);
} else if (isPrimitiveShort(top)) {
mv.visitInsn(I2S);
}
}
}).visit(controller.getAcg());
controller.getOperandStack().remove(1);
} else {
super.writeBitwiseNegate(EMPTY_BITWISE_NEGATE);
}
}
use of org.objectweb.asm.Opcodes.I2B in project groovy by apache.
the class StaticTypesUnaryExpressionHelper method writeUnaryMinus.
@Override
public void writeUnaryMinus(final UnaryMinusExpression expression) {
expression.getExpression().visit(controller.getAcg());
ClassNode top = controller.getOperandStack().getTopOperand();
if (isPrimitiveInt(top) || isPrimitiveLong(top) || isPrimitiveShort(top) || isPrimitiveFloat(top) || isPrimitiveDouble(top) || isPrimitiveByte(top) || isPrimitiveChar(top)) {
bytecodeX(mv -> {
if (isPrimitiveInt(top) || isPrimitiveShort(top) || isPrimitiveByte(top) || isPrimitiveChar(top)) {
mv.visitInsn(INEG);
if (isPrimitiveByte(top)) {
mv.visitInsn(I2B);
} else if (isPrimitiveChar(top)) {
mv.visitInsn(I2C);
} else if (isPrimitiveShort(top)) {
mv.visitInsn(I2S);
}
} else if (isPrimitiveLong(top)) {
mv.visitInsn(LNEG);
} else if (isPrimitiveFloat(top)) {
mv.visitInsn(FNEG);
} else if (isPrimitiveDouble(top)) {
mv.visitInsn(DNEG);
}
}).visit(controller.getAcg());
controller.getOperandStack().remove(1);
} else {
super.writeUnaryMinus(EMPTY_UNARY_MINUS);
}
}
Aggregations