Merge pull request #68 from vilmosnagy/master

Prints invokeDynamic
This commit is contained in:
Kalen (Konloch) Kinloch 2015-07-26 14:04:20 -06:00
commit 8d0593b119

View file

@ -19,6 +19,7 @@ import org.objectweb.asm.tree.FrameNode;
import org.objectweb.asm.tree.IincInsnNode; import org.objectweb.asm.tree.IincInsnNode;
import org.objectweb.asm.tree.InsnNode; import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.IntInsnNode; import org.objectweb.asm.tree.IntInsnNode;
import org.objectweb.asm.tree.InvokeDynamicInsnNode;
import org.objectweb.asm.tree.JumpInsnNode; import org.objectweb.asm.tree.JumpInsnNode;
import org.objectweb.asm.tree.LabelNode; import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.LdcInsnNode; import org.objectweb.asm.tree.LdcInsnNode;
@ -128,6 +129,8 @@ public class InstructionPrinter {
line = printTableSwitchInsnNode((TableSwitchInsnNode) ain); line = printTableSwitchInsnNode((TableSwitchInsnNode) ain);
} else if (ain instanceof LookupSwitchInsnNode) { } else if (ain instanceof LookupSwitchInsnNode) {
line = printLookupSwitchInsnNode((LookupSwitchInsnNode) ain); line = printLookupSwitchInsnNode((LookupSwitchInsnNode) ain);
} else if (ain instanceof InvokeDynamicInsnNode) {
line = printInvokeDynamicInsNode((InvokeDynamicInsnNode) ain);
} else { } else {
line += "UNADDED OPCODE: " + nameOpcode(ain.opcode()) + " " line += "UNADDED OPCODE: " + nameOpcode(ain.opcode()) + " "
+ ain.toString(); + ain.toString();
@ -281,6 +284,29 @@ public class InstructionPrinter {
return line; return line;
} }
protected String printInvokeDynamicInsNode(InvokeDynamicInsnNode idin) {
StringBuilder sb = new StringBuilder();
sb.append(nameOpcode(idin.opcode()) + " " + idin.name + "(");
String desc = idin.desc;
String partedDesc = idin.desc.substring(2);
try {
if(Type.getType(partedDesc) != null)
desc = Type.getType(partedDesc).getClassName();
if (desc == null || desc.equals("null"))
desc = idin.desc;
} catch(java.lang.ArrayIndexOutOfBoundsException e) {
}
sb.append(desc);
sb.append(");");
return sb.toString();
}
protected String nameOpcode(int opcode) { protected String nameOpcode(int opcode) {
return " " + OpcodeInfo.OPCODES.get(opcode).toLowerCase(); return " " + OpcodeInfo.OPCODES.get(opcode).toLowerCase();
} }