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

The following examples show how to use org.objectweb.asm.Opcodes#DNEG . 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: ReturnValuesMutator.java    From pitest with Apache License 2.0 6 votes vote down vote up
/**
 * Mutates a primitive double return (<code>Opcode.DRETURN</code>). The
 * strategy used was translated from jumble BCEL code. The following is
 * complicated by the problem of <tt>NaN</tt>s. By default the new value is
 * <code>-(x + 1)</code>, but this doesn't work for <tt>NaN</tt>s. But for a
 * <tt>NaN</tt> <code>x != x</code> is true, and we use this to detect them.
 *
 * @see #mutatePrimitiveFloatReturn()
 */
private void mutatePrimitiveDoubleReturn() {
  if (shouldMutate("primitive double", "(x != NaN)? -(x + 1) : -1 ")) {
    final Label label = new Label();

    super.visitInsn(Opcodes.DUP2);
    super.visitInsn(Opcodes.DUP2);
    super.visitInsn(Opcodes.DCMPG);
    super.visitJumpInsn(Opcodes.IFEQ, label);

    super.visitInsn(Opcodes.POP2);
    super.visitInsn(Opcodes.DCONST_0);

    // the following code is executed in NaN case, too
    super.visitLabel(label);
    super.visitInsn(Opcodes.DCONST_1);
    super.visitInsn(Opcodes.DADD);
    super.visitInsn(Opcodes.DNEG);
    super.visitInsn(Opcodes.DRETURN);
  }
}
 
Example 2
Source File: InstructionAssembler.java    From es6draft with MIT License 6 votes vote down vote up
public final void neg(Type type) {
    switch (type.getOpcode(Opcodes.INEG)) {
    case Opcodes.INEG:
        ineg();
        return;
    case Opcodes.LNEG:
        lneg();
        return;
    case Opcodes.FNEG:
        fneg();
        return;
    case Opcodes.DNEG:
        dneg();
        return;
    default:
        throw new IllegalArgumentException();
    }
}
 
Example 3
Source File: TypeUtils.java    From maple-ir with GNU General Public License v3.0 5 votes vote down vote up
public static int getNegateOpcode(Type type) {
	if (type == Type.INT_TYPE || type == Type.SHORT_TYPE || type == Type.BYTE_TYPE) {
		return Opcodes.INEG;
	} else if (type == Type.LONG_TYPE) {
		return Opcodes.LNEG;
	} else if (type == Type.FLOAT_TYPE) {
		return Opcodes.FNEG;
	} else if (type == Type.DOUBLE_TYPE) {
		return Opcodes.DNEG;
	} else {
		throw new IllegalArgumentException(type.toString());
	}
}
 
Example 4
Source File: StackHelper.java    From zelixkiller with GNU General Public License v3.0 5 votes vote down vote up
public InsnValue invertValue(AbstractInsnNode insn, InsnValue value) {
	Object obj = value.getValue();
	switch (insn.getOpcode()) {
	case Opcodes.INEG:
		if (obj == null) {
			return InsnValue.INT_VALUE;
		}
		return InsnValue.intValue(-1 * (int) obj);
	case Opcodes.LNEG:
		if (obj == null) {
			return InsnValue.LONG_VALUE;
		}
		return InsnValue.longValue(-1L * (long) obj);
	case Opcodes.FNEG:
		if (obj == null) {
			return InsnValue.FLOAT_VALUE;
		}
		return InsnValue.floatValue(-1F * (float) obj);
	case Opcodes.DNEG:
		if (obj == null) {
			return InsnValue.DOUBLE_VALUE;
		}
		return InsnValue.doubleValue(-1D * (double) obj);
	}

	return null;
}
 
Example 5
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;
}