org.objectweb.asm.tree.IntInsnNode Java Examples
The following examples show how to use
org.objectweb.asm.tree.IntInsnNode.
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: TreeInstructions.java From instrumentation with Apache License 2.0 | 6 votes |
public static AbstractInsnNode getPushInstruction(int value) { if (value == -1) { return new InsnNode(Opcodes.ICONST_M1); } else if (value == 0) { return new InsnNode(Opcodes.ICONST_0); } else if (value == 1) { return new InsnNode(Opcodes.ICONST_1); } else if (value == 2) { return new InsnNode(Opcodes.ICONST_2); } else if (value == 3) { return new InsnNode(Opcodes.ICONST_3); } else if (value == 4) { return new InsnNode(Opcodes.ICONST_4); } else if (value == 5) { return new InsnNode(Opcodes.ICONST_5); } else if ((value >= -128) && (value <= 127)) { return new IntInsnNode(Opcodes.BIPUSH, value); } else if ((value >= -32768) && (value <= 32767)) { return new IntInsnNode(Opcodes.SIPUSH, value); } else { return new LdcInsnNode(value); } }
Example #2
Source File: ConstantInterpreter.java From radon with GNU General Public License v3.0 | 6 votes |
private static AbstractValue valueFromArrayInsn(IntInsnNode iinsn) { switch (iinsn.operand) { case T_BOOLEAN: return new UnknownValue(iinsn, Type.getType("[Z")); case T_CHAR: return new UnknownValue(iinsn, Type.getType("[C")); case T_BYTE: return new UnknownValue(iinsn, Type.getType("[B")); case T_SHORT: return new UnknownValue(iinsn, Type.getType("[S")); case T_INT: return new UnknownValue(iinsn, Type.getType("[I")); case T_FLOAT: return new UnknownValue(iinsn, Type.getType("[F")); case T_DOUBLE: return new UnknownValue(iinsn, Type.getType("[D")); case T_LONG: return new UnknownValue(iinsn, Type.getType("[J")); default: throw new IllegalArgumentException("Invalid array type"); } }
Example #3
Source File: InstructionComparator.java From NOVA-Core with GNU Lesser General Public License v3.0 | 6 votes |
public static boolean insnEqual(AbstractInsnNode node1, AbstractInsnNode node2) { if (node1.getOpcode() != node2.getOpcode()) { return false; } switch (node2.getType()) { case VAR_INSN: return varInsnEqual((VarInsnNode) node1, (VarInsnNode) node2); case TYPE_INSN: return typeInsnEqual((TypeInsnNode) node1, (TypeInsnNode) node2); case FIELD_INSN: return fieldInsnEqual((FieldInsnNode) node1, (FieldInsnNode) node2); case METHOD_INSN: return methodInsnEqual((MethodInsnNode) node1, (MethodInsnNode) node2); case LDC_INSN: return ldcInsnEqual((LdcInsnNode) node1, (LdcInsnNode) node2); case IINC_INSN: return iincInsnEqual((IincInsnNode) node1, (IincInsnNode) node2); case INT_INSN: return intInsnEqual((IntInsnNode) node1, (IntInsnNode) node2); default: return true; } }
Example #4
Source File: OpUtils.java From zelixkiller with GNU General Public License v3.0 | 6 votes |
/** * Given an integer, returns an InsnNode that will properly represent the * int. * * @param i * @return */ public static AbstractInsnNode toInt(int i) { switch (i) { 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); } if (i > -129 && i < 128) { return new IntInsnNode(Opcodes.BIPUSH, i); } return new LdcInsnNode(i); }
Example #5
Source File: OpUtils.java From JByteMod-Beta with GNU General Public License v2.0 | 6 votes |
/** * Given an integer, returns an InsnNode that will properly represent the int. * * @param i * @return */ public static AbstractInsnNode toInt(int i) { switch (i) { 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); } if (i > -129 && i < 128) { return new IntInsnNode(Opcodes.BIPUSH, i); } return new LdcInsnNode(i); }
Example #6
Source File: ASMUtils.java From rembulan with Apache License 2.0 | 6 votes |
public static AbstractInsnNode loadInt(int i) { switch (i) { case -1: return new InsnNode(ICONST_M1); case 0: return new InsnNode(ICONST_0); case 1: return new InsnNode(ICONST_1); case 2: return new InsnNode(ICONST_2); case 3: return new InsnNode(ICONST_3); case 4: return new InsnNode(ICONST_4); case 5: return new InsnNode(ICONST_5); default: { if (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE) return new IntInsnNode(BIPUSH, i); else if (i >= Short.MIN_VALUE && i <= Short.MAX_VALUE) return new IntInsnNode(SIPUSH, i); else return new LdcInsnNode(i); } } }
Example #7
Source File: InstructionComparator.java From NOVA-Core with GNU Lesser General Public License v3.0 | 6 votes |
public static boolean insnEqual(AbstractInsnNode node1, AbstractInsnNode node2) { if (node1.getOpcode() != node2.getOpcode()) { return false; } switch (node2.getType()) { case VAR_INSN: return varInsnEqual((VarInsnNode) node1, (VarInsnNode) node2); case TYPE_INSN: return typeInsnEqual((TypeInsnNode) node1, (TypeInsnNode) node2); case FIELD_INSN: return fieldInsnEqual((FieldInsnNode) node1, (FieldInsnNode) node2); case METHOD_INSN: return methodInsnEqual((MethodInsnNode) node1, (MethodInsnNode) node2); case LDC_INSN: return ldcInsnEqual((LdcInsnNode) node1, (LdcInsnNode) node2); case IINC_INSN: return iincInsnEqual((IincInsnNode) node1, (IincInsnNode) node2); case INT_INSN: return intInsnEqual((IntInsnNode) node1, (IntInsnNode) node2); default: return true; } }
Example #8
Source File: OpcodeFormatting.java From Cafebabe with GNU General Public License v3.0 | 6 votes |
/** * Given an integer, returns an InsnNode that will properly represent the int. * * @param i * @return */ public static AbstractInsnNode toInt(int i) { switch (i) { 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); } if (i > -129 && i < 128) { return new IntInsnNode(Opcodes.BIPUSH, i); } return new LdcInsnNode(i); }
Example #9
Source File: InstructionComparator.java From NOVA-Core with GNU Lesser General Public License v3.0 | 6 votes |
public static boolean insnEqual(AbstractInsnNode node1, AbstractInsnNode node2) { if (node1.getOpcode() != node2.getOpcode()) { return false; } switch (node2.getType()) { case VAR_INSN: return varInsnEqual((VarInsnNode) node1, (VarInsnNode) node2); case TYPE_INSN: return typeInsnEqual((TypeInsnNode) node1, (TypeInsnNode) node2); case FIELD_INSN: return fieldInsnEqual((FieldInsnNode) node1, (FieldInsnNode) node2); case METHOD_INSN: return methodInsnEqual((MethodInsnNode) node1, (MethodInsnNode) node2); case LDC_INSN: return ldcInsnEqual((LdcInsnNode) node1, (LdcInsnNode) node2); case IINC_INSN: return iincInsnEqual((IincInsnNode) node1, (IincInsnNode) node2); case INT_INSN: return intInsnEqual((IntInsnNode) node1, (IntInsnNode) node2); default: return true; } }
Example #10
Source File: NewArrayStep.java From deobfuscator with Apache License 2.0 | 5 votes |
@Override public AbstractInsnNode tryMatch(InstructionMatcher matcher, AbstractInsnNode now) { if (now.getOpcode() == Opcodes.NEWARRAY && now instanceof IntInsnNode) { if (this.sorts.contains(((IntInsnNode) now).operand)) { return now.getNext(); } } return null; }
Example #11
Source File: ASMHelper.java From jaop with Apache License 2.0 | 5 votes |
public static void intInsnNode(ListIterator<AbstractInsnNode> iterator, int i) { if (i >=0 && i < 6) { // int ICONST_0 = 3; // - // int ICONST_1 = 4; // - // int ICONST_2 = 5; // - // int ICONST_3 = 6; // - // int ICONST_4 = 7; // - // int ICONST_5 = 8; // - iterator.add(new InsnNode(Opcodes.ICONST_0 + i)); } else { iterator.add(new IntInsnNode(Opcodes.BIPUSH, i)); } }
Example #12
Source File: ASMUtils.java From radon with GNU General Public License v3.0 | 5 votes |
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); }
Example #13
Source File: ThermosClassTransformer.java From Thermos with GNU General Public License v3.0 | 5 votes |
public void extractFrom(ImagineASM asm, InsnList list) { //Pair<String, String> fieldChunkProvider = asm.field("net/minecraft/world/World", "chunkProvider"); list.clear(); list.add(new IntInsnNode(ALOAD, 1)); list.add(new FieldInsnNode(GETFIELD, "ahb", "v", "Lapu;")); list.add(new InsnNode(ARETURN)); }
Example #14
Source File: OpUtils.java From JByteMod-Beta with GNU General Public License v2.0 | 5 votes |
/** * Get the integer value of a InsnNode. * * @param ain * @return */ public static int getIntValue(AbstractInsnNode ain) { int opcode = ain.getOpcode(); if (opcode >= Opcodes.ICONST_M1 && opcode <= Opcodes.ICONST_5) { return getIntValue(opcode); } else { return ((IntInsnNode) ain).operand; } }
Example #15
Source File: ApiDetector.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override protected void add(@NonNull AbstractInsnNode from, @NonNull AbstractInsnNode to) { if (from.getType() == AbstractInsnNode.JUMP_INSN && from.getPrevious() != null && from.getPrevious().getType() == AbstractInsnNode.INT_INSN) { IntInsnNode intNode = (IntInsnNode) from.getPrevious(); if (intNode.getPrevious() != null && isSdkVersionLookup(intNode.getPrevious())) { JumpInsnNode jumpNode = (JumpInsnNode) from; int api = intNode.operand; boolean isJumpEdge = to == jumpNode.label; boolean includeEdge; switch (from.getOpcode()) { case Opcodes.IF_ICMPNE: includeEdge = api < mRequiredApi || isJumpEdge; break; case Opcodes.IF_ICMPLE: includeEdge = api < mRequiredApi - 1 || isJumpEdge; break; case Opcodes.IF_ICMPLT: includeEdge = api < mRequiredApi || isJumpEdge; break; case Opcodes.IF_ICMPGE: includeEdge = api < mRequiredApi || !isJumpEdge; break; case Opcodes.IF_ICMPGT: includeEdge = api < mRequiredApi - 1 || !isJumpEdge; break; default: // unexpected comparison for int API level includeEdge = true; } if (!includeEdge) { return; } } } super.add(from, to); }
Example #16
Source File: MethodByteCodeUtil.java From jumbune with GNU Lesser General Public License v3.0 | 5 votes |
/** * Deciding factors for Anonymous object creation 1) The current method is init e.g. new MyClass() 2) The current method is valueOf and its * previous node is LDC, IntInsn, or Insn e.g new Double(23.3), 123, false */ public static boolean isAnonymousInitialization(MethodInsnNode min) { AbstractInsnNode previousNode = min.getPrevious(); if ("<init>".equals(min.name)){ return true; } if ("valueOf".equals(min.name) && (previousNode instanceof LdcInsnNode) || (previousNode instanceof IntInsnNode) || (previousNode instanceof InsnNode)){ return true; } return false; }
Example #17
Source File: ASMUtilsTest.java From radon with GNU General Public License v3.0 | 5 votes |
@Test public void testGetIntegerFromInsn() { Assert.assertEquals(Opcodes.ACONST_NULL, ASMUtils.getIntegerFromInsn(new InsnNode(Opcodes.ICONST_1))); Assert.assertEquals(Opcodes.ACONST_NULL, ASMUtils.getIntegerFromInsn(new IntInsnNode(Opcodes.ICONST_1, 1))); Assert.assertEquals(Opcodes.ACONST_NULL, ASMUtils.getIntegerFromInsn(new LdcInsnNode(Opcodes.ACONST_NULL))); thrown.expect(RadonException.class); ASMUtils.getIntegerFromInsn(new InsnNode(Opcodes.NOP)); }
Example #18
Source File: InsnComparator.java From TFC2 with GNU General Public License v3.0 | 5 votes |
/** * Respects {@link #INT_WILDCARD} and {@link #WILDCARD} instruction properties. * Always returns true if {@code a} and {@code b} are label, line number, or frame instructions. * * @return Whether or not the given instructions are equivalent. */ public boolean areInsnsEqual(AbstractInsnNode a, AbstractInsnNode b) { if (a == b) return true; if (a == null || b == null) return false; if (a.equals(b)) return true; if (a.getOpcode() != b.getOpcode()) return false; switch (a.getType()) { case AbstractInsnNode.VAR_INSN: return areVarInsnsEqual((VarInsnNode) a, (VarInsnNode) b); case AbstractInsnNode.TYPE_INSN: return areTypeInsnsEqual((TypeInsnNode) a, (TypeInsnNode) b); case AbstractInsnNode.FIELD_INSN: return areFieldInsnsEqual((FieldInsnNode) a, (FieldInsnNode) b); case AbstractInsnNode.METHOD_INSN: return areMethodInsnsEqual((MethodInsnNode) a, (MethodInsnNode) b); case AbstractInsnNode.LDC_INSN: return areLdcInsnsEqual((LdcInsnNode) a, (LdcInsnNode) b); case AbstractInsnNode.IINC_INSN: return areIincInsnsEqual((IincInsnNode) a, (IincInsnNode) b); case AbstractInsnNode.INT_INSN: return areIntInsnsEqual((IntInsnNode) a, (IntInsnNode) b); default: return true; } }
Example #19
Source File: ASMUtils.java From radon with GNU General Public License v3.0 | 5 votes |
public static int getIntegerFromInsn(AbstractInsnNode insn) { int opcode = insn.getOpcode(); if (opcode >= Opcodes.ICONST_M1 && opcode <= Opcodes.ICONST_5) { return opcode - 3; } else if (insn instanceof IntInsnNode && insn.getOpcode() != Opcodes.NEWARRAY) { return ((IntInsnNode) insn).operand; } else if (insn instanceof LdcInsnNode && ((LdcInsnNode) insn).cst instanceof Integer) { return (Integer) ((LdcInsnNode) insn).cst; } throw new RadonException("Unexpected instruction"); }
Example #20
Source File: ASMHelper.java From jaop with Apache License 2.0 | 5 votes |
public static void intInsnNode(ListIterator<AbstractInsnNode> iterator, int i) { if (i >=0 && i < 6) { // int ICONST_0 = 3; // - // int ICONST_1 = 4; // - // int ICONST_2 = 5; // - // int ICONST_3 = 6; // - // int ICONST_4 = 7; // - // int ICONST_5 = 8; // - iterator.add(new InsnNode(Opcodes.ICONST_0 + i)); } else { iterator.add(new IntInsnNode(Opcodes.BIPUSH, i)); } }
Example #21
Source File: InsnUtils.java From zelixkiller with GNU General Public License v3.0 | 5 votes |
public static int getIntValue(AbstractInsnNode node) { if (node.getOpcode() >= ICONST_M1 && node.getOpcode() <= ICONST_5) { return node.getOpcode() - 3; } if (node.getOpcode() == SIPUSH || node.getOpcode() == BIPUSH) { return ((IntInsnNode) node).operand; } if(node instanceof LdcInsnNode) { LdcInsnNode ldc = (LdcInsnNode) node; return Integer.parseInt(ldc.cst.toString()); } return 0; }
Example #22
Source File: InsnUtils.java From zelixkiller with GNU General Public License v3.0 | 5 votes |
public static AbstractInsnNode generateIntPush(int i) { if (i <= 5 && i >= -1) { return new InsnNode(i + 3); //iconst_i } if (i >= -128 && i <= 127) { return new IntInsnNode(BIPUSH, i); } if (i >= -32768 && i <= 32767) { return new IntInsnNode(SIPUSH, i); } return new LdcInsnNode(i); }
Example #23
Source File: OpUtils.java From zelixkiller with GNU General Public License v3.0 | 5 votes |
/** * Get the integer value of a InsnNode. * * @param ain * @return */ public static int getIntValue(AbstractInsnNode ain) { int opcode = ain.getOpcode(); if (opcode >= Opcodes.ICONST_M1 && opcode <= Opcodes.ICONST_5) { return getIntValue(opcode); } else { return ((IntInsnNode) ain).operand; } }
Example #24
Source File: IntInstructionFilter.java From maple-ir with GNU General Public License v3.0 | 5 votes |
@Override public boolean accept(AbstractInsnNode t) { if (!(t instanceof IntInsnNode)) return false; if (!opcodeFilter.accept(t)) return false; IntInsnNode fin = (IntInsnNode) t; if (!numberFilter.accept(fin.operand)) return false; return true; }
Example #25
Source File: IntInsnNodeSerializer.java From maple-ir with GNU General Public License v3.0 | 5 votes |
@Override public JsonElement serialize(IntInsnNode src, Type typeOfSrc, JsonSerializationContext context) { JsonObject jsonObject = new JsonObject(); jsonObject.add("opcode", context.serialize(src.getOpcode(), Integer.class)); jsonObject.add("operand", context.serialize(src.operand, Integer.class)); return jsonObject; }
Example #26
Source File: IntInsnNodeSerializer.java From maple-ir with GNU General Public License v3.0 | 5 votes |
@Override public IntInsnNode deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = (JsonObject) json; int opcode, operand; opcode = jsonObject.get("opcode").getAsInt(); operand = jsonObject.get("operand").getAsInt(); return new IntInsnNode(opcode, operand); }
Example #27
Source File: IntHandler.java From native-obfuscator with GNU General Public License v3.0 | 5 votes |
@Override protected void process(MethodContext context, IntInsnNode node) { props.put("operand", String.valueOf(node.operand)); if (node.getOpcode() == Opcodes.NEWARRAY) { instructionName += "_" + node.operand; } }
Example #28
Source File: OpcodeFormatting.java From Cafebabe with GNU General Public License v3.0 | 5 votes |
/** * Get the integer value of a InsnNode. * * @param ain * @return */ public static int getIntValue(AbstractInsnNode ain) { int opcode = ain.getOpcode(); if (opcode >= Opcodes.ICONST_M1 && opcode <= Opcodes.ICONST_5) { return getIntValue(opcode); } else { return ((IntInsnNode) ain).operand; } }
Example #29
Source File: ASMMethodVariables.java From pinpoint with Apache License 2.0 | 5 votes |
void push(InsnList insnList, final int value) { if (value >= -1 && value <= 5) { insnList.add(new InsnNode(Opcodes.ICONST_0 + value)); } else if (value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE) { insnList.add(new IntInsnNode(Opcodes.BIPUSH, value)); } else if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE) { insnList.add(new IntInsnNode(Opcodes.SIPUSH, value)); } else { insnList.add(new LdcInsnNode(value)); } }
Example #30
Source File: BasicInterpreter.java From JReFrameworker with MIT License | 4 votes |
@Override public BasicValue unaryOperation(final AbstractInsnNode insn, final BasicValue value) throws AnalyzerException { switch (insn.getOpcode()) { case INEG: case IINC: case L2I: case F2I: case D2I: case I2B: case I2C: case I2S: return BasicValue.INT_VALUE; case FNEG: case I2F: case L2F: case D2F: return BasicValue.FLOAT_VALUE; case LNEG: case I2L: case F2L: case D2L: return BasicValue.LONG_VALUE; case DNEG: case I2D: case L2D: case F2D: return BasicValue.DOUBLE_VALUE; case IFEQ: case IFNE: case IFLT: case IFGE: case IFGT: case IFLE: case TABLESWITCH: case LOOKUPSWITCH: case IRETURN: case LRETURN: case FRETURN: case DRETURN: case ARETURN: case PUTSTATIC: return null; case GETFIELD: return newValue(Type.getType(((FieldInsnNode) insn).desc)); case NEWARRAY: switch (((IntInsnNode) insn).operand) { case T_BOOLEAN: return newValue(Type.getType("[Z")); case T_CHAR: return newValue(Type.getType("[C")); case T_BYTE: return newValue(Type.getType("[B")); case T_SHORT: return newValue(Type.getType("[S")); case T_INT: return newValue(Type.getType("[I")); case T_FLOAT: return newValue(Type.getType("[F")); case T_DOUBLE: return newValue(Type.getType("[D")); case T_LONG: return newValue(Type.getType("[J")); default: break; } throw new AnalyzerException(insn, "Invalid array type"); case ANEWARRAY: return newValue(Type.getType("[" + Type.getObjectType(((TypeInsnNode) insn).desc))); case ARRAYLENGTH: return BasicValue.INT_VALUE; case ATHROW: return null; case CHECKCAST: return newValue(Type.getObjectType(((TypeInsnNode) insn).desc)); case INSTANCEOF: return BasicValue.INT_VALUE; case MONITORENTER: case MONITOREXIT: case IFNULL: case IFNONNULL: return null; default: throw new AssertionError(); } }