org.objectweb.asm.Opcodes# SIPUSH 源码实例Demo

下面列出了org.objectweb.asm.Opcodes# SIPUSH 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Concurnas   文件: CheckMethodAdapter.java

@Override
public void visitIntInsn(final int opcode, final int operand) {
  checkVisitCodeCalled();
  checkVisitMaxsNotCalled();
  checkOpcodeMethod(opcode, Method.VISIT_INT_INSN);
  switch (opcode) {
    case Opcodes.BIPUSH:
      checkSignedByte(operand, "Invalid operand");
      break;
    case Opcodes.SIPUSH:
      checkSignedShort(operand, "Invalid operand");
      break;
    case Opcodes.NEWARRAY:
      if (operand < Opcodes.T_BOOLEAN || operand > Opcodes.T_LONG) {
        throw new IllegalArgumentException(
            "Invalid operand (must be an array type code T_...): " + operand);
      }
      break;
    default:
      throw new AssertionError();
  }
  super.visitIntInsn(opcode, operand);
  ++insnCount;
}
 

@Override
public void visitIntInsn(final int opcode, final int operand) {
  checkStartCode();
  checkEndCode();
  checkOpcode(opcode, 1);
  switch (opcode) {
  case Opcodes.BIPUSH:
    checkSignedByte(operand, "Invalid operand");
    break;
  case Opcodes.SIPUSH:
    checkSignedShort(operand, "Invalid operand");
    break;
  // case Constants.NEWARRAY:
  default:
    if (operand < Opcodes.T_BOOLEAN || operand > Opcodes.T_LONG) {
      throw new IllegalArgumentException("Invalid operand (must be an array type code T_...): " + operand);
    }
  }
  super.visitIntInsn(opcode, operand);
  ++insnCount;
}
 
源代码3 项目: deobfuscator   文件: LoadIntStep.java

public LoadIntStep() {
    super((a) -> 
    {
    	if(!(a instanceof LdcInsnNode))
    		return true;
    	return ((LdcInsnNode)a).cst instanceof Integer;
    },Opcodes.ICONST_M1,
            Opcodes.ICONST_0,
            Opcodes.ICONST_1,
            Opcodes.ICONST_2,
            Opcodes.ICONST_3,
            Opcodes.ICONST_4,
            Opcodes.ICONST_5,
            Opcodes.LDC,
            Opcodes.BIPUSH,
            Opcodes.SIPUSH
    );
}
 
源代码4 项目: deobfuscator   文件: Utils.java

public static AbstractInsnNode getNumberInsn(int num) {
    switch (num) {
    	case -1:
    		return new InsnNode(Opcodes.ICONST_M1);
        case 0:
            return new InsnNode(Opcodes.ICONST_0);
        case 1:
            return new InsnNode(Opcodes.ICONST_1);
        case 2:
            return new InsnNode(Opcodes.ICONST_2);
        case 3:
            return new InsnNode(Opcodes.ICONST_3);
        case 4:
            return new InsnNode(Opcodes.ICONST_4);
        case 5:
            return new InsnNode(Opcodes.ICONST_5);
        default:
        	if(num >= -128 && num <= 127)
        		return new IntInsnNode(Opcodes.BIPUSH, num);
        	else if(num >= -32768 && num <= 32767)
        		return new IntInsnNode(Opcodes.SIPUSH, num);
        	else
        		return new LdcInsnNode(num);
    }
}
 
源代码5 项目: deobfuscator   文件: Utils.java

public static boolean isInteger(AbstractInsnNode ain)
{
   	if (ain == null) return false;
	if((ain.getOpcode() >= Opcodes.ICONST_M1
		&& ain.getOpcode() <= Opcodes.ICONST_5)
		|| ain.getOpcode() == Opcodes.SIPUSH 
		|| ain.getOpcode() == Opcodes.BIPUSH)
		return true;
	if(ain instanceof LdcInsnNode)
	{
		LdcInsnNode ldc = (LdcInsnNode)ain;
		if(ldc.cst instanceof Integer)
			return true;
	}
	return false;
}
 
源代码6 项目: deobfuscator   文件: Utils.java

public static int getIntValue(AbstractInsnNode node)
{
	if(node.getOpcode() >= Opcodes.ICONST_M1
		&& node.getOpcode() <= Opcodes.ICONST_5)
		return node.getOpcode() - 3;
	if(node.getOpcode() == Opcodes.SIPUSH
		|| node.getOpcode() == Opcodes.BIPUSH)
		return ((IntInsnNode)node).operand;
	if(node instanceof LdcInsnNode)
	{
		LdcInsnNode ldc = (LdcInsnNode)node;
		if(ldc.cst instanceof Integer)
			return (int)ldc.cst;
	}
	return 0;
}
 

@Override
public void visitIntInsn(final int opcode, final int operand) {
  checkVisitCodeCalled();
  checkVisitMaxsNotCalled();
  checkOpcodeMethod(opcode, Method.VISIT_INT_INSN);
  switch (opcode) {
    case Opcodes.BIPUSH:
      checkSignedByte(operand, "Invalid operand");
      break;
    case Opcodes.SIPUSH:
      checkSignedShort(operand, "Invalid operand");
      break;
    case Opcodes.NEWARRAY:
      if (operand < Opcodes.T_BOOLEAN || operand > Opcodes.T_LONG) {
        throw new IllegalArgumentException(
            "Invalid operand (must be an array type code T_...): " + operand);
      }
      break;
    default:
      throw new AssertionError();
  }
  super.visitIntInsn(opcode, operand);
  ++insnCount;
}
 
源代码8 项目: radon   文件: ASMUtils.java

public static boolean isIntInsn(AbstractInsnNode insn) {
    if (insn == null) {
        return false;
    }
    int opcode = insn.getOpcode();
    return ((opcode >= Opcodes.ICONST_M1 && opcode <= Opcodes.ICONST_5)
            || opcode == Opcodes.BIPUSH
            || opcode == Opcodes.SIPUSH
            || (insn instanceof LdcInsnNode
            && ((LdcInsnNode) insn).cst instanceof Integer));
}
 
源代码9 项目: radon   文件: ASMUtils.java

public static AbstractInsnNode getNumberInsn(int number) {
    if (number >= -1 && number <= 5)
        return new InsnNode(number + 3);
    else if (number >= -128 && number <= 127)
        return new IntInsnNode(Opcodes.BIPUSH, number);
    else if (number >= -32768 && number <= 32767)
        return new IntInsnNode(Opcodes.SIPUSH, number);
    else
        return new LdcInsnNode(number);
}
 
源代码10 项目: pitest   文件: AbstractCRCRVisitor.java

@Override
public void visitIntInsn(final int opcode, final int operand) {
    if ((opcode == Opcodes.BIPUSH) || (opcode == Opcodes.SIPUSH)) {
        mutate(operand);
    } else {
        super.visitIntInsn(opcode, operand);
    }
}
 

public void visitIntInsn(int opcode, int operand) {
  switch (opcode) {
    case Opcodes.NEWARRAY :
      newArray(operand, toType(operand));
      break;
    case Opcodes.BIPUSH :
      loadConstant(operand, JavaType.INT);
      break;
    case Opcodes.SIPUSH :
      loadConstant(operand, JavaType.INT);
      break;
    default :
      throw new UnsupportedOperationException("Unexpected opcode: " + opcode);
  }
}
 
源代码12 项目: pitest   文件: InlineConstantMutator.java

@Override
public void visitIntInsn(final int opcode, final int operand) {
  if ((opcode == Opcodes.BIPUSH) || (opcode == Opcodes.SIPUSH)) {
    mutate(operand);
  } else {
    super.visitIntInsn(opcode, operand);
  }
}
 

public PushIntConst(int value) {
    if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
        useLdcInsn = true;
    } else {
        useLdcInsn = false;
        if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
            this.operation = Opcodes.SIPUSH;
        } else {
            this.operation = Opcodes.BIPUSH;
        }
    }
    this.value = value;
}
 
源代码14 项目: Concurnas   文件: InstructionAdapter.java

@Override
public void visitIntInsn(final int opcode, final int operand) {
  switch (opcode) {
    case Opcodes.BIPUSH:
      iconst(operand);
      break;
    case Opcodes.SIPUSH:
      iconst(operand);
      break;
    case Opcodes.NEWARRAY:
      switch (operand) {
        case Opcodes.T_BOOLEAN:
          newarray(Type.BOOLEAN_TYPE);
          break;
        case Opcodes.T_CHAR:
          newarray(Type.CHAR_TYPE);
          break;
        case Opcodes.T_BYTE:
          newarray(Type.BYTE_TYPE);
          break;
        case Opcodes.T_SHORT:
          newarray(Type.SHORT_TYPE);
          break;
        case Opcodes.T_INT:
          newarray(Type.INT_TYPE);
          break;
        case Opcodes.T_FLOAT:
          newarray(Type.FLOAT_TYPE);
          break;
        case Opcodes.T_LONG:
          newarray(Type.LONG_TYPE);
          break;
        case Opcodes.T_DOUBLE:
          newarray(Type.DOUBLE_TYPE);
          break;
        default:
          throw new IllegalArgumentException();
      }
      break;
    default:
      throw new IllegalArgumentException();
  }
}
 
源代码15 项目: zelixkiller   文件: StackHelper.java

public InsnValue createConstant(AbstractInsnNode insn) throws AnalyzerException {
	switch (insn.getOpcode()) {
	case Opcodes.ACONST_NULL:
		return InsnValue.NULL_REFERENCE_VALUE;
	case Opcodes.ICONST_M1:
	case Opcodes.ICONST_0:
	case Opcodes.ICONST_1:
	case Opcodes.ICONST_2:
	case Opcodes.ICONST_3:
	case Opcodes.ICONST_4:
	case Opcodes.ICONST_5:
	case Opcodes.BIPUSH:
	case Opcodes.SIPUSH:
		return InsnValue.intValue(insn);
	case Opcodes.LCONST_0:
	case Opcodes.LCONST_1:
		return InsnValue.longValue(insn.getOpcode());
	case Opcodes.FCONST_0:
	case Opcodes.FCONST_1:
	case Opcodes.FCONST_2:
		return InsnValue.floatValue(insn.getOpcode());
	case Opcodes.DCONST_0:
	case Opcodes.DCONST_1:
		return InsnValue.doubleValue(insn.getOpcode());
	case Opcodes.LDC:
		Object obj = ((LdcInsnNode) insn).cst;
		if (obj instanceof Type) {
			return new InsnValue((Type) obj);
		} else {
			Type t = Type.getType(obj.getClass());
			int sort = t.getSort();
			// Non-included types:
			// Type.ARRAY
			// Type.VOID
			// Type.METHOD
			switch (sort) {
			case Type.BOOLEAN:
				return InsnValue.intValue((int) obj);
			case Type.CHAR:
				return InsnValue.charValue((char) obj);
			case Type.BYTE:
				return InsnValue.byteValue((byte) obj);
			case Type.SHORT:
				return InsnValue.shortValue((short) obj);
			case Type.INT:
				return InsnValue.intValue((int) obj);
			case Type.FLOAT:
				return InsnValue.floatValue((float) obj);
			case Type.LONG:
				return InsnValue.longValue((long) obj);
			case Type.DOUBLE:
				return InsnValue.doubleValue((double) obj);
			case Type.OBJECT:
				return new InsnValue(t, obj);
			}
			return new InsnValue(t);
		}
	case Opcodes.NEW:
		return new InsnValue(Type.getType(((TypeInsnNode) insn).desc));
	case Opcodes.JSR:
		// TODO: IDK if this is right.
		return InsnValue.REFERENCE_VALUE;
	}

	return null;
}
 
源代码16 项目: JByteMod-Beta   文件: InstructionAdapter.java

@Override
public void visitIntInsn(final int opcode, final int operand) {
  switch (opcode) {
    case Opcodes.BIPUSH:
      iconst(operand);
      break;
    case Opcodes.SIPUSH:
      iconst(operand);
      break;
    case Opcodes.NEWARRAY:
      switch (operand) {
        case Opcodes.T_BOOLEAN:
          newarray(Type.BOOLEAN_TYPE);
          break;
        case Opcodes.T_CHAR:
          newarray(Type.CHAR_TYPE);
          break;
        case Opcodes.T_BYTE:
          newarray(Type.BYTE_TYPE);
          break;
        case Opcodes.T_SHORT:
          newarray(Type.SHORT_TYPE);
          break;
        case Opcodes.T_INT:
          newarray(Type.INT_TYPE);
          break;
        case Opcodes.T_FLOAT:
          newarray(Type.FLOAT_TYPE);
          break;
        case Opcodes.T_LONG:
          newarray(Type.LONG_TYPE);
          break;
        case Opcodes.T_DOUBLE:
          newarray(Type.DOUBLE_TYPE);
          break;
        default:
          throw new IllegalArgumentException();
      }
      break;
    default:
      throw new IllegalArgumentException();
  }
}
 
源代码17 项目: JReFrameworker   文件: InstructionAdapter.java

@Override
public void visitIntInsn(final int opcode, final int operand) {
  switch (opcode) {
    case Opcodes.BIPUSH:
      iconst(operand);
      break;
    case Opcodes.SIPUSH:
      iconst(operand);
      break;
    case Opcodes.NEWARRAY:
      switch (operand) {
        case Opcodes.T_BOOLEAN:
          newarray(Type.BOOLEAN_TYPE);
          break;
        case Opcodes.T_CHAR:
          newarray(Type.CHAR_TYPE);
          break;
        case Opcodes.T_BYTE:
          newarray(Type.BYTE_TYPE);
          break;
        case Opcodes.T_SHORT:
          newarray(Type.SHORT_TYPE);
          break;
        case Opcodes.T_INT:
          newarray(Type.INT_TYPE);
          break;
        case Opcodes.T_FLOAT:
          newarray(Type.FLOAT_TYPE);
          break;
        case Opcodes.T_LONG:
          newarray(Type.LONG_TYPE);
          break;
        case Opcodes.T_DOUBLE:
          newarray(Type.DOUBLE_TYPE);
          break;
        default:
          throw new IllegalArgumentException();
      }
      break;
    default:
      throw new IllegalArgumentException();
  }
}
 
源代码18 项目: bazel   文件: LambdaDesugaring.java

/**
 * Returns whether a given instruction can be used to push argument of {@code type} on stack.
 */
private /* static */ boolean isPushForType(AbstractInsnNode insn, Type type) {
  int opcode = insn.getOpcode();
  if (opcode == type.getOpcode(Opcodes.ILOAD)) {
    return true;
  }
  // b/62060793: AsyncAwait rewrites bytecode to convert java methods into state machine with
  // support of lambdas. Constant zero values are pushed on stack for all yet uninitialized
  // local variables. And SIPUSH instruction is used to advance an internal state of a state
  // machine.
  switch (type.getSort()) {
    case Type.BOOLEAN:
      return opcode == Opcodes.ICONST_0 || opcode == Opcodes.ICONST_1;

    case Type.BYTE:
    case Type.CHAR:
    case Type.SHORT:
    case Type.INT:
      return opcode == Opcodes.SIPUSH
          || opcode == Opcodes.ICONST_0
          || opcode == Opcodes.ICONST_1
          || opcode == Opcodes.ICONST_2
          || opcode == Opcodes.ICONST_3
          || opcode == Opcodes.ICONST_4
          || opcode == Opcodes.ICONST_5
          || opcode == Opcodes.ICONST_M1;

    case Type.LONG:
      return opcode == Opcodes.LCONST_0 || opcode == Opcodes.LCONST_1;

    case Type.FLOAT:
      return opcode == Opcodes.FCONST_0
          || opcode == Opcodes.FCONST_1
          || opcode == Opcodes.FCONST_2;

    case Type.DOUBLE:
      return opcode == Opcodes.DCONST_0 || opcode == Opcodes.DCONST_1;

    case Type.OBJECT:
    case Type.ARRAY:
      return opcode == Opcodes.ACONST_NULL;

    default:
      // Support for BIPUSH and LDC* opcodes is not implemented as there is no known use case.
      return false;
  }
}
 
源代码19 项目: JReFrameworker   文件: InstructionAdapter.java

@Override
public void visitIntInsn(final int opcode, final int operand) {
  switch (opcode) {
    case Opcodes.BIPUSH:
      iconst(operand);
      break;
    case Opcodes.SIPUSH:
      iconst(operand);
      break;
    case Opcodes.NEWARRAY:
      switch (operand) {
        case Opcodes.T_BOOLEAN:
          newarray(Type.BOOLEAN_TYPE);
          break;
        case Opcodes.T_CHAR:
          newarray(Type.CHAR_TYPE);
          break;
        case Opcodes.T_BYTE:
          newarray(Type.BYTE_TYPE);
          break;
        case Opcodes.T_SHORT:
          newarray(Type.SHORT_TYPE);
          break;
        case Opcodes.T_INT:
          newarray(Type.INT_TYPE);
          break;
        case Opcodes.T_FLOAT:
          newarray(Type.FLOAT_TYPE);
          break;
        case Opcodes.T_LONG:
          newarray(Type.LONG_TYPE);
          break;
        case Opcodes.T_DOUBLE:
          newarray(Type.DOUBLE_TYPE);
          break;
        default:
          throw new IllegalArgumentException();
      }
      break;
    default:
      throw new IllegalArgumentException();
  }
}
 
源代码20 项目: CodenameOne   文件: VarOp.java

@Override
public void appendInstruction(StringBuilder b) {
    b.append("    ");
    switch(opcode) {
        case Opcodes.ILOAD:
            b.append("(*SP).type = CN1_TYPE_INT; /* ILOAD */ \n" +
                    "    (*SP).data.i = ilocals_");
            b.append(var);
            b.append("_; \n    SP++;\n");
            return;
        case Opcodes.LLOAD:
            b.append("BC_LLOAD(");
            break;
        case Opcodes.FLOAD:
            b.append("BC_FLOAD(");
            break;
        case Opcodes.DLOAD:
            b.append("BC_DLOAD(");
            break;
        case Opcodes.ALOAD:
            b.append("BC_ALOAD(");
            break;
        case Opcodes.ISTORE:
            b.append("BC_ISTORE(");
            break;
        case Opcodes.LSTORE:
            b.append("BC_LSTORE(");
            break;
        case Opcodes.FSTORE:
            b.append("BC_FSTORE(");
            break;
        case Opcodes.DSTORE:
            b.append("BC_DSTORE(");
            break;
        case Opcodes.ASTORE:
            b.append("BC_ASTORE(");
            break;
        case Opcodes.RET:
            b.append("/* RET TODO */");
            //b.append("goto label_");
            //b.append(var);
            //b.append("; /* RET */\n");
            return;
        case Opcodes.SIPUSH:
        case Opcodes.BIPUSH:
            b.append("PUSH_INT(");
            break;
        case Opcodes.NEWARRAY:
            switch(var) {
                case 4: // boolean
                    b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_BOOLEAN, sizeof(JAVA_ARRAY_BOOLEAN), 1));\n");
                    break;
                case 5: // char
                    b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_CHAR, sizeof(JAVA_ARRAY_CHAR), 1));\n");
                    break;
                case 6: // float
                    b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_FLOAT, sizeof(JAVA_ARRAY_FLOAT), 1));\n");
                    break;
                case 7: // double
                    b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_DOUBLE, sizeof(JAVA_ARRAY_DOUBLE), 1));\n");
                    break;
                case 8: // byte
                    b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_BYTE, sizeof(JAVA_ARRAY_BYTE), 1));\n");
                    break;
                case 9: // short
                    b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_SHORT, sizeof(JAVA_ARRAY_SHORT), 1));\n");
                    break;
                case 10: // int
                    b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_INT, sizeof(JAVA_ARRAY_INT), 1));\n");
                    break;
                case 11: // long 
                    b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_LONG, sizeof(JAVA_ARRAY_LONG), 1));\n");
                    break;
            }
            return;
        default:
            throw new RuntimeException("Missing opcode: " + opcode);
    }
    b.append(var);
    b.append(");\n");
}
 
 方法所在类
 同类方法