Skip to content

Commit

Permalink
Add missing methods (java-deobfuscator#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisTestUser authored and samczsun committed Sep 20, 2017
1 parent bd8f10e commit ae11a0b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/main/java/com/javadeobfuscator/deobfuscator/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,34 @@ public static void printClass(ClassNode classNode) {
});
}

public static boolean isNumber(AbstractInsnNode ain)
{
if(ain.getOpcode() >= Opcodes.ICONST_M1
&& ain.getOpcode() <= Opcodes.SIPUSH)
return true;
if(ain instanceof LdcInsnNode)
{
LdcInsnNode ldc = (LdcInsnNode)ain;
if(ldc.cst instanceof Number)
return true;
}
return false;
}

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 Number)
return (int)ldc.cst;
}
return 0;
}
}

0 comments on commit ae11a0b

Please sign in to comment.