Search in sources :

Example 1 with LXOR

use of org.objectweb.asm.Opcodes.LXOR 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);
    }
}
Also used : ClassHelper.isPrimitiveDouble(org.codehaus.groovy.ast.ClassHelper.isPrimitiveDouble) WriterController(org.codehaus.groovy.classgen.asm.WriterController) Label(org.objectweb.asm.Label) I2B(org.objectweb.asm.Opcodes.I2B) IFNE(org.objectweb.asm.Opcodes.IFNE) I2C(org.objectweb.asm.Opcodes.I2C) IXOR(org.objectweb.asm.Opcodes.IXOR) ClassHelper.isPrimitiveShort(org.codehaus.groovy.ast.ClassHelper.isPrimitiveShort) ClassHelper.boolean_TYPE(org.codehaus.groovy.ast.ClassHelper.boolean_TYPE) ClassHelper.isPrimitiveFloat(org.codehaus.groovy.ast.ClassHelper.isPrimitiveFloat) EmptyExpression(org.codehaus.groovy.ast.expr.EmptyExpression) Expression(org.codehaus.groovy.ast.expr.Expression) INEG(org.objectweb.asm.Opcodes.INEG) UnaryMinusExpression(org.codehaus.groovy.ast.expr.UnaryMinusExpression) ICONST_1(org.objectweb.asm.Opcodes.ICONST_1) UnaryPlusExpression(org.codehaus.groovy.ast.expr.UnaryPlusExpression) ICONST_0(org.objectweb.asm.Opcodes.ICONST_0) ClassNode(org.codehaus.groovy.ast.ClassNode) ClassHelper.isPrimitiveInt(org.codehaus.groovy.ast.ClassHelper.isPrimitiveInt) ClassHelper.isPrimitiveLong(org.codehaus.groovy.ast.ClassHelper.isPrimitiveLong) ClassHelper.isPrimitiveBoolean(org.codehaus.groovy.ast.ClassHelper.isPrimitiveBoolean) ICONST_M1(org.objectweb.asm.Opcodes.ICONST_M1) NotExpression(org.codehaus.groovy.ast.expr.NotExpression) TypeChooser(org.codehaus.groovy.classgen.asm.TypeChooser) UnaryExpressionHelper(org.codehaus.groovy.classgen.asm.UnaryExpressionHelper) FNEG(org.objectweb.asm.Opcodes.FNEG) BitwiseNegationExpression(org.codehaus.groovy.ast.expr.BitwiseNegationExpression) GeneralUtils.bytecodeX(org.codehaus.groovy.ast.tools.GeneralUtils.bytecodeX) LXOR(org.objectweb.asm.Opcodes.LXOR) ClassHelper.isPrimitiveChar(org.codehaus.groovy.ast.ClassHelper.isPrimitiveChar) ClassHelper.isPrimitiveByte(org.codehaus.groovy.ast.ClassHelper.isPrimitiveByte) LNEG(org.objectweb.asm.Opcodes.LNEG) GOTO(org.objectweb.asm.Opcodes.GOTO) I2S(org.objectweb.asm.Opcodes.I2S) DNEG(org.objectweb.asm.Opcodes.DNEG) ClassNode(org.codehaus.groovy.ast.ClassNode)

Aggregations

ClassHelper.boolean_TYPE (org.codehaus.groovy.ast.ClassHelper.boolean_TYPE)1 ClassHelper.isPrimitiveBoolean (org.codehaus.groovy.ast.ClassHelper.isPrimitiveBoolean)1 ClassHelper.isPrimitiveByte (org.codehaus.groovy.ast.ClassHelper.isPrimitiveByte)1 ClassHelper.isPrimitiveChar (org.codehaus.groovy.ast.ClassHelper.isPrimitiveChar)1 ClassHelper.isPrimitiveDouble (org.codehaus.groovy.ast.ClassHelper.isPrimitiveDouble)1 ClassHelper.isPrimitiveFloat (org.codehaus.groovy.ast.ClassHelper.isPrimitiveFloat)1 ClassHelper.isPrimitiveInt (org.codehaus.groovy.ast.ClassHelper.isPrimitiveInt)1 ClassHelper.isPrimitiveLong (org.codehaus.groovy.ast.ClassHelper.isPrimitiveLong)1 ClassHelper.isPrimitiveShort (org.codehaus.groovy.ast.ClassHelper.isPrimitiveShort)1 ClassNode (org.codehaus.groovy.ast.ClassNode)1 BitwiseNegationExpression (org.codehaus.groovy.ast.expr.BitwiseNegationExpression)1 EmptyExpression (org.codehaus.groovy.ast.expr.EmptyExpression)1 Expression (org.codehaus.groovy.ast.expr.Expression)1 NotExpression (org.codehaus.groovy.ast.expr.NotExpression)1 UnaryMinusExpression (org.codehaus.groovy.ast.expr.UnaryMinusExpression)1 UnaryPlusExpression (org.codehaus.groovy.ast.expr.UnaryPlusExpression)1 GeneralUtils.bytecodeX (org.codehaus.groovy.ast.tools.GeneralUtils.bytecodeX)1 TypeChooser (org.codehaus.groovy.classgen.asm.TypeChooser)1 UnaryExpressionHelper (org.codehaus.groovy.classgen.asm.UnaryExpressionHelper)1 WriterController (org.codehaus.groovy.classgen.asm.WriterController)1