Java Code Examples for org.objectweb.asm.Opcodes#LADD

The following examples show how to use org.objectweb.asm.Opcodes#LADD . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InstructionAssembler.java    From es6draft with MIT License 6 votes vote down vote up
public final void add(Type type) {
    switch (type.getOpcode(Opcodes.IADD)) {
    case Opcodes.IADD:
        iadd();
        return;
    case Opcodes.LADD:
        ladd();
        return;
    case Opcodes.FADD:
        fadd();
        return;
    case Opcodes.DADD:
        dadd();
        return;
    default:
        throw new IllegalArgumentException();
    }
}
 
Example 2
Source File: AsmUtil.java    From Bats with Apache License 2.0 5 votes vote down vote up
/**
 * Determine if the given opcode is an ADD of some kind (xADD).
 *
 * @param opcode the opcode
 * @return true if the opcode is one of the ADDs, false otherwise
 */
public static boolean isXadd(final int opcode) {
  switch(opcode) {
  case Opcodes.IADD:
  case Opcodes.DADD:
  case Opcodes.FADD:
  case Opcodes.LADD:
    return true;
  }

  return false;
}
 
Example 3
Source File: ReturnValuesMutator.java    From pitest with Apache License 2.0 5 votes vote down vote up
private void mutatePrimitiveLongReturn() {
  if (shouldMutate("primitive long", "x + 1")) {
    super.visitInsn(Opcodes.LCONST_1);
    super.visitInsn(Opcodes.LADD);
    super.visitInsn(Opcodes.LRETURN);
  }
}
 
Example 4
Source File: CompilerUtils.java    From jphp with Apache License 2.0 5 votes vote down vote up
public static int getOperatorOpcode(OperatorExprToken operator, StackItem.Type type){
    if (operator instanceof PlusExprToken){
        switch (type){
            case DOUBLE: return Opcodes.DADD;
            case FLOAT: return Opcodes.FADD;
            case LONG: return Opcodes.LADD;
            case BYTE:
            case SHORT:
            case INT: return Opcodes.IADD;
        }
    }

    if (operator instanceof MinusExprToken){
        switch (type){
            case DOUBLE: return Opcodes.DSUB;
            case FLOAT: return Opcodes.FSUB;
            case LONG: return Opcodes.LSUB;
            case BYTE:
            case SHORT:
            case INT: return Opcodes.ISUB;
        }
    }

    if (operator instanceof MulExprToken){
        switch (type){
            case DOUBLE: return Opcodes.DMUL;
            case FLOAT: return Opcodes.FMUL;
            case LONG: return Opcodes.LMUL;
            case BYTE:
            case SHORT:
            case INT: return Opcodes.IMUL;
        }
    }

    throw new IllegalArgumentException("Unknown operator " + operator.getWord() + " for type " + type.name());
}
 
Example 5
Source File: BytecodeUtils.java    From turin-programming-language with Apache License 2.0 4 votes vote down vote up
public static MathOperationBS createMathOperation(JvmTypeCategory operandsType, MathOperation.Operator operator) {
    int opcode;
    switch (operator) {
        case MULTIPLICATION:
            switch (operandsType) {
                case INT:
                    opcode = Opcodes.IMUL;
                    break;
                case LONG:
                    opcode = Opcodes.LMUL;
                    break;
                case FLOAT:
                    opcode = Opcodes.FMUL;
                    break;
                case DOUBLE:
                    opcode = Opcodes.DMUL;
                    break;
                default:
                    throw new UnsupportedOperationException(operator + " " +operandsType.name());
            }
            break;
        case SUM:
            switch (operandsType) {
                case INT:
                    opcode = Opcodes.IADD;
                    break;
                case LONG:
                    opcode = Opcodes.LADD;
                    break;
                case FLOAT:
                    opcode = Opcodes.FADD;
                    break;
                case DOUBLE:
                    opcode = Opcodes.DADD;
                    break;
                default:
                    throw new UnsupportedOperationException(operator + " " +operandsType.name());
            }
            break;
        case SUBTRACTION:
            switch (operandsType) {
                case INT:
                    opcode = Opcodes.ISUB;
                    break;
                case LONG:
                    opcode = Opcodes.LSUB;
                    break;
                case FLOAT:
                    opcode = Opcodes.FSUB;
                    break;
                case DOUBLE:
                    opcode = Opcodes.DSUB;
                    break;
                default:
                    throw new UnsupportedOperationException(operator + " " +operandsType.name());
            }
            break;
        case DIVISION:
            switch (operandsType) {
                case INT:
                    opcode = Opcodes.IDIV;
                    break;
                case LONG:
                    opcode = Opcodes.LDIV;
                    break;
                case FLOAT:
                    opcode = Opcodes.FDIV;
                    break;
                case DOUBLE:
                    opcode = Opcodes.DDIV;
                    break;
                default:
                    throw new UnsupportedOperationException(operator + " " +operandsType.name());
            }
            break;
        default:
            throw new UnsupportedOperationException(operator.name());
    }
    return new MathOperationBS(opcode);
}
 
Example 6
Source File: ArithmeticExpression.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public static boolean isBinaryOp(Instruction instr) {
    switch (instr.getOpcode()) {
        case Opcodes.ISHL:
        case Opcodes.ISHR:
        case Opcodes.LSHL:
        case Opcodes.LSHR:
        case Opcodes.IUSHR:
        case Opcodes.LUSHR:
        case Opcodes.DCMPG:
        case Opcodes.DCMPL:
        case Opcodes.FCMPG:
        case Opcodes.FCMPL:
        case Opcodes.LCMP:
        case Opcodes.IOR:
        case Opcodes.LOR:
        case Opcodes.IXOR:
        case Opcodes.LXOR:
        case Opcodes.IAND:
        case Opcodes.LAND:
        case Opcodes.FADD:
        case Opcodes.DADD:
        case Opcodes.IADD:
        case Opcodes.LADD:
        case Opcodes.FSUB:
        case Opcodes.DSUB:
        case Opcodes.ISUB:
        case Opcodes.LSUB:
        case Opcodes.FDIV:
        case Opcodes.DDIV:
        case Opcodes.LDIV:
        case Opcodes.IDIV:
        case Opcodes.IREM:
        case Opcodes.FREM:
        case Opcodes.DREM:
        case Opcodes.LREM:
        case Opcodes.FMUL:
        case Opcodes.DMUL:
        case Opcodes.IMUL:
        case Opcodes.LMUL:
            return true;
    }
    return false;
}
 
Example 7
Source File: ArithmeticExpression.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public static boolean isArithmeticOp(Instruction instr) {
    
    switch (instr.getOpcode()) {
        case Opcodes.ISHL:
        case Opcodes.ISHR:
        case Opcodes.LSHL:
        case Opcodes.LSHR:
        case Opcodes.IUSHR:
        case Opcodes.LUSHR:
        
        case Opcodes.DCMPG:
        case Opcodes.DCMPL:
        case Opcodes.FCMPG:
        case Opcodes.FCMPL:
        case Opcodes.LCMP:
        case Opcodes.FNEG:
        case Opcodes.DNEG:
        case Opcodes.INEG:
        case Opcodes.D2F:
        case Opcodes.D2I:
        case Opcodes.D2L:
        case Opcodes.F2D:
        case Opcodes.F2I:
        case Opcodes.F2L:
        case Opcodes.L2D:
        case Opcodes.L2F:
        case Opcodes.L2I:
        case Opcodes.I2L:
        case Opcodes.I2B:
        case Opcodes.I2C:
        case Opcodes.I2D:
        case Opcodes.I2F:
        case Opcodes.I2S:
        case Opcodes.IOR:
        case Opcodes.LOR:
        case Opcodes.IXOR:
        case Opcodes.LXOR:
        case Opcodes.IAND:
        case Opcodes.LAND:
        case Opcodes.FADD:
        case Opcodes.DADD:
        case Opcodes.IADD:
        case Opcodes.LADD:
        case Opcodes.FSUB:
        case Opcodes.DSUB:
        case Opcodes.ISUB:
        case Opcodes.LSUB:
        case Opcodes.FDIV:
        case Opcodes.DDIV:
        case Opcodes.LDIV:
        case Opcodes.IDIV:
        case Opcodes.IREM:
        case Opcodes.FREM:
        case Opcodes.DREM:
        case Opcodes.LREM:
        case Opcodes.FMUL:
        case Opcodes.DMUL:
        case Opcodes.IMUL:
        case Opcodes.LMUL:
            return true;
    }
    return false;
}
 
Example 8
Source File: AOD1Mutator.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public void visitInsn(int opcode) {
    switch (opcode) {
        case Opcodes.IADD:
        case Opcodes.ISUB:
        case Opcodes.IMUL:
        case Opcodes.IDIV:
        case Opcodes.IREM:
            if (this.shouldMutate("integer"))  {
                mv.visitInsn(Opcodes.POP);
            } else  {
                mv.visitInsn(opcode);
            }
            break;
        case Opcodes.FADD:
        case Opcodes.FSUB:
        case Opcodes.FMUL:
        case Opcodes.FDIV:
        case Opcodes.FREM:
            if (this.shouldMutate("float"))  {
                mv.visitInsn(Opcodes.POP);
            } else  {
                mv.visitInsn(opcode);
            }
            break;
        case Opcodes.LADD:
        case Opcodes.LSUB:
        case Opcodes.LMUL:
        case Opcodes.LDIV:
        case Opcodes.LREM:
            if (this.shouldMutate("long"))  {
                mv.visitInsn(Opcodes.POP2);
            } else  {
                mv.visitInsn(opcode);
            }
            break;
        case Opcodes.DADD:
        case Opcodes.DSUB:
        case Opcodes.DMUL:
        case Opcodes.DDIV:
        case Opcodes.DREM:
            if (this.shouldMutate("double"))  {
                mv.visitInsn(Opcodes.POP2);
            } else  {
                mv.visitInsn(opcode);
            }
            break;
        default:
            mv.visitInsn(opcode);
            break;
    }
}