Updated frames

This commit is contained in:
SuspiciousActivity committed 2019-02-10 00:07:32 +01:00
1 parent 8c94bb4497
commit 6e1a0a26b3
4 files changed
+1145 -1072

No files matched your search

File diff suppressed because it is too large. Load diff
+244 -201
View File
@@ -139,16 +139,18 @@ public class Disassembler {
} }
s += "// #Class v:" + classNode.version + "\n"; s += "// #Class v:" + classNode.version + "\n";
s += "// #Signature: " + UnicodeUtils.escapeWithSpaces(classNode.signature) + "\n"; s += "// #Signature: " + UnicodeUtils.escapeWithSpaces(classNode.signature) + "\n";
s += "// #OuterMethod: " s += "// #OuterMethod: " + (classNode.outerMethod == null ? "null"
+ (classNode.outerMethod == null ? "null" : (UnicodeUtils.escapeWithSpaces(classNode.outerMethod) + " "
: (UnicodeUtils.escapeWithSpaces(classNode.outerMethod) + " " + UnicodeUtils.escapeWithSpaces(classNode.outerMethodDesc))) + UnicodeUtils.escapeWithSpaces(classNode.outerMethodDesc)))
+ "\n"; + "\n";
s += "// #OuterClass: " + UnicodeUtils.escapeWithSpaces(classNode.outerClass) + "\n"; s += "// #OuterClass: " + UnicodeUtils.escapeWithSpaces(classNode.outerClass) + "\n";
s += "// #InnerClasses:\n"; s += "// #InnerClasses:\n";
if (classNode.innerClasses != null) { if (classNode.innerClasses != null) {
for (InnerClassNode icn : classNode.innerClasses) { for (InnerClassNode icn : classNode.innerClasses) {
s += "// " + UnicodeUtils.escapeWithSpaces(icn.name) + " " + UnicodeUtils.escapeWithSpaces(icn.outerName) + " " s += "// " + UnicodeUtils.escapeWithSpaces(icn.name) + " "
+ UnicodeUtils.escapeWithSpaces(icn.innerName) + " 0x" + Integer.toHexString(icn.access) + "\n"; + UnicodeUtils.escapeWithSpaces(icn.outerName) + " "
+ UnicodeUtils.escapeWithSpaces(icn.innerName) + " 0x" + Integer.toHexString(icn.access)
+ "\n";
} }
} }
s += ClassUtil.getAccessFlagsClass(classNode.access) + UnicodeUtils.escapeWithSpaces(classNode.name) + " "; s += ClassUtil.getAccessFlagsClass(classNode.access) + UnicodeUtils.escapeWithSpaces(classNode.name) + " ";
@@ -165,7 +167,9 @@ public class Disassembler {
if (!interfaceStr.isEmpty()) if (!interfaceStr.isEmpty())
s += "implements " + interfaceStr + " "; s += "implements " + interfaceStr + " ";
} }
s += "{\n// #SourceFile: " + (classNode.sourceFile == null ? "null" : UnicodeUtils.escape(classNode.sourceFile)) + "\n\n// #Fields\n"; s += "{\n// #SourceFile: "
+ (classNode.sourceFile == null ? "null" : UnicodeUtils.escape(classNode.sourceFile))
+ "\n\n// #Fields\n";
for (FieldNode fn : classNode.fields) { for (FieldNode fn : classNode.fields) {
if (fn.signature != null) if (fn.signature != null)
s += "\t// #Signature: " + UnicodeUtils.escapeWithSpaces(fn.signature) + "\n"; s += "\t// #Signature: " + UnicodeUtils.escapeWithSpaces(fn.signature) + "\n";
@@ -231,8 +235,8 @@ public class Disassembler {
if (fn.equals(nodeToFind)) { if (fn.equals(nodeToFind)) {
lineFound = s.split("\\n").length; lineFound = s.split("\\n").length;
} }
s += "\t" + ClassUtil.getAccessFlagsFull(fn.access).replace("varargs", "transient") + UnicodeUtils.escapeWithSpaces(fn.desc) + " " s += "\t" + ClassUtil.getAccessFlagsFull(fn.access).replace("varargs", "transient")
+ UnicodeUtils.escapeWithSpaces(fn.name); + UnicodeUtils.escapeWithSpaces(fn.desc) + " " + UnicodeUtils.escapeWithSpaces(fn.name);
if (fn.value != null) { if (fn.value != null) {
s += " = " + ClassUtil.getDecompiledValue(fn.value, fn.desc, true); s += " = " + ClassUtil.getDecompiledValue(fn.value, fn.desc, true);
} }
@@ -327,16 +331,19 @@ public class Disassembler {
s += dis[0]; s += dis[0];
s += "\t}\n\n"; s += "\t}\n\n";
} catch (Exception e) { } catch (Exception e) {
s += "\t\t// Method couldn't be disassembled:\n\t\t// " + e.getClass().getName() + ": " + e.getMessage() + "\n" s += "\t\t// Method couldn't be disassembled:\n\t\t// "
+ Arrays.toString(e.getStackTrace()).replace(", ", "\n\t\t// \tat ").replace("[", "\t\t// \tat ").replace("]", "") + e.getClass().getName() + ": " + e.getMessage() + "\n" + Arrays.toString(e.getStackTrace())
.replace(", ", "\n\t\t// \tat ").replace("[", "\t\t// \tat ").replace("]", "")
+ "\n\t}\n\n"; + "\n\t}\n\n";
} }
} }
s += "}\n"; s += "}\n";
return new DisassembleTuple(s, lineFound); return new DisassembleTuple(s, lineFound);
} catch (Throwable e) { } catch (Throwable e) {
return new DisassembleTuple("Class couldn't be decompiled:\n" + e.getClass().getName() + ": " + e.getMessage() + "\n" return new DisassembleTuple("Class couldn't be decompiled:\n" + e.getClass().getName() + ": "
+ Arrays.toString(e.getStackTrace()).replace(", ", "\n\tat ").replace("[", "\tat ").replace("]", "") + "\n"); + e.getMessage() + "\n"
+ Arrays.toString(e.getStackTrace()).replace(", ", "\n\tat ").replace("[", "\tat ").replace("]", "")
+ "\n");
} }
} }
@@ -352,15 +359,17 @@ public class Disassembler {
} }
if (mn.localVariables != null) { if (mn.localVariables != null) {
for (LocalVariableNode lvn : mn.localVariables) { for (LocalVariableNode lvn : mn.localVariables) {
localVarTable += "\t// " + UnicodeUtils.escapeWithSpaces(lvn.name) + ": " + UnicodeUtils.escapeWithSpaces(lvn.desc) + " i:" localVarTable += "\t// " + UnicodeUtils.escapeWithSpaces(lvn.name) + ": "
+ lvn.index + " s:" + labels.get(lvn.start.getLabel()) + " e:" + labels.get(lvn.end.getLabel()) + " sig:" + UnicodeUtils.escapeWithSpaces(lvn.desc) + " i:" + lvn.index + " s:"
+ labels.get(lvn.start.getLabel()) + " e:" + labels.get(lvn.end.getLabel()) + " sig:"
+ UnicodeUtils.escapeWithSpaces(lvn.signature) + "\n"; + UnicodeUtils.escapeWithSpaces(lvn.signature) + "\n";
} }
} }
if (mn.tryCatchBlocks != null) { if (mn.tryCatchBlocks != null) {
for (TryCatchBlockNode tcbn : mn.tryCatchBlocks) { for (TryCatchBlockNode tcbn : mn.tryCatchBlocks) {
tryCatchTable += "\t// " + UnicodeUtils.escapeWithSpaces(tcbn.type) + " s:" + labels.get(tcbn.start.getLabel()) + " e:" tryCatchTable += "\t// " + UnicodeUtils.escapeWithSpaces(tcbn.type) + " s:"
+ labels.get(tcbn.end.getLabel()) + " h:" + labels.get(tcbn.handler.getLabel()) + "\n"; + labels.get(tcbn.start.getLabel()) + " e:" + labels.get(tcbn.end.getLabel()) + " h:"
+ labels.get(tcbn.handler.getLabel()) + "\n";
} }
} }
for (AbstractInsnNode n : mn.instructions.toArray()) { for (AbstractInsnNode n : mn.instructions.toArray()) {
@@ -371,208 +380,242 @@ public class Disassembler {
public static String disassembleInstruction(AbstractInsnNode n, HashMap<Label, Integer> labels) { public static String disassembleInstruction(AbstractInsnNode n, HashMap<Label, Integer> labels) {
switch (n.getClass().getSimpleName()) { switch (n.getClass().getSimpleName()) {
case "FieldInsnNode": { case "FieldInsnNode": {
FieldInsnNode node = (FieldInsnNode) n; FieldInsnNode node = (FieldInsnNode) n;
return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " " + UnicodeUtils.escapeWithSpaces(node.desc) + " " return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " "
+ UnicodeUtils.escapeWithSpaces(node.owner) + "/" + UnicodeUtils.escapeWithSpaces(node.name).replace("/", "\\u002F") + "\n"; + UnicodeUtils.escapeWithSpaces(node.desc) + " " + UnicodeUtils.escapeWithSpaces(node.owner) + "/"
+ UnicodeUtils.escapeWithSpaces(node.name).replace("/", "\\u002F") + "\n";
}
case "LabelNode": {
LabelNode node = (LabelNode) n;
return "\t\t// label " + labels.get(node.getLabel()) + "\n";
}
case "FrameNode": {
FrameNode node = (FrameNode) n;
String type = "";
switch (node.type) {
case Opcodes.F_NEW:
type = "NEW";
break;
case Opcodes.F_FULL:
type = "FULL";
break;
case Opcodes.F_APPEND:
type = "APPEND";
break;
case Opcodes.F_CHOP:
type = "CHOP";
break;
case Opcodes.F_SAME:
type = "SAME";
break;
case Opcodes.F_SAME1:
type = "SAME1";
break;
} }
case "LabelNode": { String s = "\t\t// frame " + type + " l:";
LabelNode node = (LabelNode) n; ArrayList<String> arr = new ArrayList<>();
return "\t\t// label " + labels.get(node.getLabel()) + "\n"; if (node.local != null) {
} for (Object o : node.local) {
case "FrameNode": { if (o == null) {
FrameNode node = (FrameNode) n; arr.add(null);
String s = "\t\t// frame " + node.type + " l:";
ArrayList<String> arr = new ArrayList<>();
if (node.local != null) {
for (Object o : node.local) {
if (o == null) {
arr.add(null);
} else {
if (o instanceof String) {
arr.add(UnicodeUtils.escapeWithSpaces((String) o));
} else if (o instanceof LabelNode) {
arr.add("(label) " + labels.get(((LabelNode) o).getLabel()));
} else {
arr.add("(" + o.getClass().getName().replace(".", "/") + ") " + o);
}
}
}
s += arr.toString();
} else {
s += "null";
}
arr.clear();
s += " s:";
if (node.stack != null) {
for (Object o : node.stack) {
if (o == null) {
arr.add(null);
} else {
if (o instanceof String) {
arr.add(UnicodeUtils.escapeWithSpaces((String) o));
} else if (o instanceof LabelNode) {
arr.add("(label) " + labels.get(((LabelNode) o).getLabel()));
} else {
arr.add("(" + o.getClass().getName().replace(".", "/") + ") " + o);
}
}
}
s += arr.toString();
} else {
s += "null";
}
s += "\n";
return s;
}
case "LineNumberNode": {
LineNumberNode node = (LineNumberNode) n;
return "\t\t// line " + node.line + " " + labels.get(node.start.getLabel()) + "\n";
}
case "InvokeDynamicInsnNode": {
InvokeDynamicInsnNode node = (InvokeDynamicInsnNode) n;
String s = "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " [\n\t\t\tname: "
+ UnicodeUtils.escapeWithSpaces(node.name).replace("/", "\\u002F") + "\n\t\t\tdesc: "
+ UnicodeUtils.escapeWithSpaces(node.desc) + "\n\t\t\tHandle: [\n\t\t\t\tname: "
+ UnicodeUtils.escapeWithSpaces(node.bsm.getName()) + "\n\t\t\t\towner: " + UnicodeUtils.escapeWithSpaces(node.bsm.getOwner())
+ "\n\t\t\t\tdesc: " + UnicodeUtils.escapeWithSpaces(node.bsm.getDesc()) + "\n\t\t\t\tisInterface: " + node.bsm.isInterface()
+ "\n\t\t\t\ttag: " + node.bsm.getTag() + "\n\t\t\t]\n\t\t\targs: [\n";
for (Object l : node.bsmArgs) {
if (l.getClass().getName().equals("org.objectweb.asm.Type")) {
Type type = (Type) l;
int valueBegin = 0;
int valueEnd = 0;
String buf = null;
try {
Field f_off = Type.class.getDeclaredField("valueBegin");
f_off.setAccessible(true);
valueBegin = f_off.getInt(type);
Field f_len = Type.class.getDeclaredField("valueEnd");
f_len.setAccessible(true);
valueEnd = f_len.getInt(type);
Field f_buf = Type.class.getDeclaredField("valueBuffer");
f_buf.setAccessible(true);
buf = (String) f_buf.get(type);
} catch (Exception e) {}
s += "\t\t\t\tType: [\n\t\t\t\t\ttype: " + ClassUtil.getClassNameFromType(type) + "\n\t\t\t\t\tstart: " + valueBegin
+ "\n\t\t\t\t\tend: " + valueEnd + "\n\t\t\t\t\tbuf: " + ClassUtil.getDecompiledValue(buf, "");
s += "\n\t\t\t\t]\n";
} else if (l.getClass().getName().equals("org.objectweb.asm.Handle")) {
Handle h = (Handle) l;
s += "\t\t\t\tHandle: [\n\t\t\t\t\tname: " + UnicodeUtils.escapeWithSpaces(h.getName()).replace("/", "\\u002F")
+ "\n\t\t\t\t\towner: " + UnicodeUtils.escapeWithSpaces(h.getOwner()) + "\n\t\t\t\t\tdesc: "
+ UnicodeUtils.escapeWithSpaces(h.getDesc()) + "\n\t\t\t\t\tisInterface: " + h.isInterface() + "\n\t\t\t\t\ttag: "
+ h.getTag();
s += "\n\t\t\t\t]\n";
} else { } else {
s += "\t\t\t\t" + ClassUtil.getDecompiledValue(l, "") + "\n"; if (o instanceof String) {
arr.add(UnicodeUtils.escapeWithSpaces((String) o));
} else if (o instanceof LabelNode) {
arr.add("(label) " + labels.get(((LabelNode) o).getLabel()));
} else {
arr.add("(" + o.getClass().getName().replace(".", "/") + ") " + o);
}
} }
} }
s += "\t\t\t]\n\t\t]\n"; s += arr.toString();
return s; } else {
s += "null";
} }
case "MethodInsnNode": { arr.clear();
MethodInsnNode node = (MethodInsnNode) n; s += " s:";
return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " " + UnicodeUtils.escapeWithSpaces(node.desc) + " " if (node.stack != null) {
+ UnicodeUtils.escapeWithSpaces(node.owner) + "/" + UnicodeUtils.escapeWithSpaces(node.name).replace("/", "\\u002F") + "\n"; for (Object o : node.stack) {
} if (o == null) {
case "TypeInsnNode": { arr.add(null);
TypeInsnNode node = (TypeInsnNode) n; } else {
return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " " + UnicodeUtils.escapeWithSpaces(node.desc) + "\n"; if (o instanceof String) {
} arr.add(UnicodeUtils.escapeWithSpaces((String) o));
case "MultiANewArrayInsnNode": { } else if (o instanceof LabelNode) {
MultiANewArrayInsnNode node = (MultiANewArrayInsnNode) n; arr.add("(label) " + labels.get(((LabelNode) o).getLabel()));
return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " " + UnicodeUtils.escapeWithSpaces(node.desc) + " " + node.dims } else {
+ "\n"; arr.add("(" + o.getClass().getName().replace(".", "/") + ") " + o);
} }
case "LdcInsnNode": {
LdcInsnNode node = (LdcInsnNode) n;
switch (node.cst.getClass().getSimpleName()) {
case "String":
case "Double":
case "Integer":
case "Float":
case "Long": {
return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " " + ClassUtil.getDecompiledValue(node.cst, "") + "\n";
}
case "Type": {
Type type = (Type) node.cst;
int valueBegin = 0;
int valueEnd = 0;
String buf = null;
try {
Field f_off = Type.class.getDeclaredField("valueBegin");
f_off.setAccessible(true);
valueBegin = f_off.getInt(type);
Field f_len = Type.class.getDeclaredField("valueEnd");
f_len.setAccessible(true);
valueEnd = f_len.getInt(type);
Field f_buf = Type.class.getDeclaredField("valueBuffer");
f_buf.setAccessible(true);
buf = (String) f_buf.get(type);
} catch (Exception e) {}
String s = "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " Type: [\n\t\t\ttype: "
+ ClassUtil.getClassNameFromType(type) + "\n\t\t\tstart: " + valueBegin + "\n\t\t\tend: " + valueEnd + "\n\t\t\tbuf: "
+ ClassUtil.getDecompiledValue(buf, "");
s += "\n\t\t]\n";
return s;
}
default: {
return "\t\tUNRESOLVED TYPE! " + OpcodesReverse.reverseOpcode(node.getOpcode()) + " "
+ node.cst.getClass().getName().replace(".", "/") + " " + node.cst + "\n";
} }
} }
s += arr.toString();
} else {
s += "null";
} }
case "VarInsnNode": { s += "\n";
VarInsnNode node = (VarInsnNode) n; return s;
return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + node.var + "\n"; }
} case "LineNumberNode": {
case "InsnNode": { LineNumberNode node = (LineNumberNode) n;
InsnNode node = (InsnNode) n; return "\t\t// line " + node.line + " " + labels.get(node.start.getLabel()) + "\n";
return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + "\n"; }
} case "InvokeDynamicInsnNode": {
case "IntInsnNode": { InvokeDynamicInsnNode node = (InvokeDynamicInsnNode) n;
IntInsnNode node = (IntInsnNode) n; String s = "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " [\n\t\t\tname: "
if (n.getOpcode() == Opcodes.NEWARRAY) { + UnicodeUtils.escapeWithSpaces(node.name).replace("/", "\\u002F") + "\n\t\t\tdesc: "
return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + ClassUtil.getArrayTypeByID(node.operand) + "\n"; + UnicodeUtils.escapeWithSpaces(node.desc) + "\n\t\t\tHandle: [\n\t\t\t\tname: "
+ UnicodeUtils.escapeWithSpaces(node.bsm.getName()) + "\n\t\t\t\towner: "
+ UnicodeUtils.escapeWithSpaces(node.bsm.getOwner()) + "\n\t\t\t\tdesc: "
+ UnicodeUtils.escapeWithSpaces(node.bsm.getDesc()) + "\n\t\t\t\tisInterface: "
+ node.bsm.isInterface() + "\n\t\t\t\ttag: " + node.bsm.getTag() + "\n\t\t\t]\n\t\t\targs: [\n";
for (Object l : node.bsmArgs) {
if (l.getClass().getName().equals("org.objectweb.asm.Type")) {
Type type = (Type) l;
int valueBegin = 0;
int valueEnd = 0;
String buf = null;
try {
Field f_off = Type.class.getDeclaredField("valueBegin");
f_off.setAccessible(true);
valueBegin = f_off.getInt(type);
Field f_len = Type.class.getDeclaredField("valueEnd");
f_len.setAccessible(true);
valueEnd = f_len.getInt(type);
Field f_buf = Type.class.getDeclaredField("valueBuffer");
f_buf.setAccessible(true);
buf = (String) f_buf.get(type);
} catch (Exception e) {
}
s += "\t\t\t\tType: [\n\t\t\t\t\ttype: " + ClassUtil.getClassNameFromType(type)
+ "\n\t\t\t\t\tstart: " + valueBegin + "\n\t\t\t\t\tend: " + valueEnd + "\n\t\t\t\t\tbuf: "
+ ClassUtil.getDecompiledValue(buf, "");
s += "\n\t\t\t\t]\n";
} else if (l.getClass().getName().equals("org.objectweb.asm.Handle")) {
Handle h = (Handle) l;
s += "\t\t\t\tHandle: [\n\t\t\t\t\tname: "
+ UnicodeUtils.escapeWithSpaces(h.getName()).replace("/", "\\u002F") + "\n\t\t\t\t\towner: "
+ UnicodeUtils.escapeWithSpaces(h.getOwner()) + "\n\t\t\t\t\tdesc: "
+ UnicodeUtils.escapeWithSpaces(h.getDesc()) + "\n\t\t\t\t\tisInterface: " + h.isInterface()
+ "\n\t\t\t\t\ttag: " + h.getTag();
s += "\n\t\t\t\t]\n";
} else { } else {
return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + node.operand + "\n"; s += "\t\t\t\t" + ClassUtil.getDecompiledValue(l, "") + "\n";
} }
} }
case "JumpInsnNode": { s += "\t\t\t]\n\t\t]\n";
JumpInsnNode node = (JumpInsnNode) n; return s;
return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + labels.get(node.label.getLabel()) + "\n"; }
case "MethodInsnNode": {
MethodInsnNode node = (MethodInsnNode) n;
return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " "
+ UnicodeUtils.escapeWithSpaces(node.desc) + " " + UnicodeUtils.escapeWithSpaces(node.owner) + "/"
+ UnicodeUtils.escapeWithSpaces(node.name).replace("/", "\\u002F") + "\n";
}
case "TypeInsnNode": {
TypeInsnNode node = (TypeInsnNode) n;
return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " "
+ UnicodeUtils.escapeWithSpaces(node.desc) + "\n";
}
case "MultiANewArrayInsnNode": {
MultiANewArrayInsnNode node = (MultiANewArrayInsnNode) n;
return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " "
+ UnicodeUtils.escapeWithSpaces(node.desc) + " " + node.dims + "\n";
}
case "LdcInsnNode": {
LdcInsnNode node = (LdcInsnNode) n;
switch (node.cst.getClass().getSimpleName()) {
case "String":
case "Double":
case "Integer":
case "Float":
case "Long": {
return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " "
+ ClassUtil.getDecompiledValue(node.cst, "") + "\n";
} }
case "TableSwitchInsnNode": { case "Type": {
TableSwitchInsnNode node = (TableSwitchInsnNode) n; Type type = (Type) node.cst;
String s = "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " [\n\t\t\tmin: " + node.min + "\n\t\t\tmax: " + node.max int valueBegin = 0;
+ "\n\t\t\tdefault: " + labels.get(node.dflt.getLabel()) + "\n\t\t\tlabels: [\n"; int valueEnd = 0;
for (LabelNode l : node.labels) { String buf = null;
s += "\t\t\t\t" + labels.get(l.getLabel()) + "\n"; try {
Field f_off = Type.class.getDeclaredField("valueBegin");
f_off.setAccessible(true);
valueBegin = f_off.getInt(type);
Field f_len = Type.class.getDeclaredField("valueEnd");
f_len.setAccessible(true);
valueEnd = f_len.getInt(type);
Field f_buf = Type.class.getDeclaredField("valueBuffer");
f_buf.setAccessible(true);
buf = (String) f_buf.get(type);
} catch (Exception e) {
} }
s += "\t\t\t]\n\t\t]\n"; String s = "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " Type: [\n\t\t\ttype: "
+ ClassUtil.getClassNameFromType(type) + "\n\t\t\tstart: " + valueBegin + "\n\t\t\tend: "
+ valueEnd + "\n\t\t\tbuf: " + ClassUtil.getDecompiledValue(buf, "");
s += "\n\t\t]\n";
return s; return s;
} }
case "LookupSwitchInsnNode": { default: {
LookupSwitchInsnNode node = (LookupSwitchInsnNode) n; return "\t\tUNRESOLVED TYPE! " + OpcodesReverse.reverseOpcode(node.getOpcode()) + " "
String s = "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " [\n\t\t\tdefault: " + labels.get(node.dflt.getLabel()) + node.cst.getClass().getName().replace(".", "/") + " " + node.cst + "\n";
+ "\n\t\t\tkeys: [\n";
for (Integer l : node.keys) {
s += "\t\t\t\t" + l + "\n";
}
s += "\t\t\t]" + "\n\t\t\tlabels: [\n";
for (LabelNode l : node.labels) {
s += "\t\t\t\t" + labels.get(l.getLabel()) + "\n";
}
s += "\t\t\t]\n\t\t]\n";
return s;
} }
case "IincInsnNode": {
IincInsnNode node = (IincInsnNode) n;
return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + node.var + " " + node.incr + "\n";
} }
default: }
return "\t\tNOT HANDLED! " + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + n.getClass().getSimpleName() + "\n"; case "VarInsnNode": {
VarInsnNode node = (VarInsnNode) n;
return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + node.var + "\n";
}
case "InsnNode": {
InsnNode node = (InsnNode) n;
return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + "\n";
}
case "IntInsnNode": {
IntInsnNode node = (IntInsnNode) n;
if (n.getOpcode() == Opcodes.NEWARRAY) {
return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " "
+ ClassUtil.getArrayTypeByID(node.operand) + "\n";
} else {
return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + node.operand + "\n";
}
}
case "JumpInsnNode": {
JumpInsnNode node = (JumpInsnNode) n;
return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + labels.get(node.label.getLabel())
+ "\n";
}
case "TableSwitchInsnNode": {
TableSwitchInsnNode node = (TableSwitchInsnNode) n;
String s = "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " [\n\t\t\tmin: " + node.min
+ "\n\t\t\tmax: " + node.max + "\n\t\t\tdefault: " + labels.get(node.dflt.getLabel())
+ "\n\t\t\tlabels: [\n";
for (LabelNode l : node.labels) {
s += "\t\t\t\t" + labels.get(l.getLabel()) + "\n";
}
s += "\t\t\t]\n\t\t]\n";
return s;
}
case "LookupSwitchInsnNode": {
LookupSwitchInsnNode node = (LookupSwitchInsnNode) n;
String s = "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " [\n\t\t\tdefault: "
+ labels.get(node.dflt.getLabel()) + "\n\t\t\tkeys: [\n";
for (Integer l : node.keys) {
s += "\t\t\t\t" + l + "\n";
}
s += "\t\t\t]" + "\n\t\t\tlabels: [\n";
for (LabelNode l : node.labels) {
s += "\t\t\t\t" + labels.get(l.getLabel()) + "\n";
}
s += "\t\t\t]\n\t\t]\n";
return s;
}
case "IincInsnNode": {
IincInsnNode node = (IincInsnNode) n;
return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + node.var + " " + node.incr + "\n";
}
default:
return "\t\tNOT HANDLED! " + OpcodesReverse.reverseOpcode(n.getOpcode()) + " "
+ n.getClass().getSimpleName() + "\n";
} }
} }
+2
View File
@@ -178,6 +178,8 @@ public class Main extends JFrame {
provider.addCompletion(new ShorthandCompletion(provider, "method", provider.addCompletion(new ShorthandCompletion(provider, "method",
"// #Max: l:0 s:0\n\t// #TryCatch:\n\t// #LocalVars:\n\tpublic static method ()V {\n\t\treturn\n\t}", "// #Max: l:0 s:0\n\t// #TryCatch:\n\t// #LocalVars:\n\tpublic static method ()V {\n\t\treturn\n\t}",
null, "<html><b><u>method</u></b><br>Creates an example method</html>")); null, "<html><b><u>method</u></b><br>Creates an example method</html>"));
provider.addCompletion(new ShorthandCompletion(provider, "frame", "frame FULL l:[] s:[]", null,
"<html><b><u>frame</u></b><br>Creates a stack map frame</html>"));
return provider; return provider;
} }
@@ -26,7 +26,7 @@ import javax.swing.text.Segment;
* @see AbstractCompletionProvider * @see AbstractCompletionProvider
*/ */
public abstract class CompletionProviderBase implements CompletionProvider { public abstract class CompletionProviderBase implements CompletionProvider {
/** /**
* The parent completion provider. * The parent completion provider.
*/ */
@@ -66,11 +66,11 @@ public abstract class CompletionProviderBase implements CompletionProvider {
private Segment s = new Segment(); private Segment s = new Segment();
protected static final String EMPTY_STRING = ""; protected static final String EMPTY_STRING = "";
/** /**
* Comparator used to sort completions by their relevance before sorting * Comparator used to sort completions by their relevance before sorting them
* them lexicographically. * lexicographically.
*/ */
private static final Comparator<Completion> sortByRelevanceComparator = new SortByRelevanceComparator(); private static final Comparator<Completion> sortByRelevanceComparator = new SortByRelevanceComparator();
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -79,7 +79,7 @@ public abstract class CompletionProviderBase implements CompletionProvider {
paramListEnd = paramListStart = 0; paramListEnd = paramListStart = 0;
paramListSeparator = null; paramListSeparator = null;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -112,17 +112,15 @@ public abstract class CompletionProviderBase implements CompletionProvider {
} }
return completions; return completions;
} }
/** /**
* Does the dirty work of creating a list of completions. * Does the dirty work of creating a list of completions.
* *
* @param comp * @param comp The text component to look in.
* The text component to look in. * @return The list of possible completions, or an empty list if there are none.
* @return The list of possible completions, or an empty list if there
* are none.
*/ */
protected abstract List<Completion> getCompletionsImpl(JTextComponent comp); protected abstract List<Completion> getCompletionsImpl(JTextComponent comp);
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -130,7 +128,7 @@ public abstract class CompletionProviderBase implements CompletionProvider {
public ListCellRenderer getListCellRenderer() { public ListCellRenderer getListCellRenderer() {
return listCellRenderer; return listCellRenderer;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -138,7 +136,7 @@ public abstract class CompletionProviderBase implements CompletionProvider {
public ParameterChoicesProvider getParameterChoicesProvider() { public ParameterChoicesProvider getParameterChoicesProvider() {
return paramChoicesProvider; return paramChoicesProvider;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -146,7 +144,7 @@ public abstract class CompletionProviderBase implements CompletionProvider {
public char getParameterListEnd() { public char getParameterListEnd() {
return paramListEnd; return paramListEnd;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -154,7 +152,7 @@ public abstract class CompletionProviderBase implements CompletionProvider {
public String getParameterListSeparator() { public String getParameterListSeparator() {
return paramListSeparator; return paramListSeparator;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -162,7 +160,7 @@ public abstract class CompletionProviderBase implements CompletionProvider {
public char getParameterListStart() { public char getParameterListStart() {
return paramListStart; return paramListStart;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -170,7 +168,7 @@ public abstract class CompletionProviderBase implements CompletionProvider {
public CompletionProvider getParent() { public CompletionProvider getParent() {
return parent; return parent;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -186,38 +184,33 @@ public abstract class CompletionProviderBase implements CompletionProvider {
} }
return (autoActivateAfterLetters && Character.isLetter(ch)) || (autoActivateChars != null && autoActivateChars.indexOf(ch) > -1); return (autoActivateAfterLetters && Character.isLetter(ch)) || (autoActivateChars != null && autoActivateChars.indexOf(ch) > -1);
} }
/** /**
* Sets the characters that auto-activation should occur after. A Java * Sets the characters that auto-activation should occur after. A Java
* completion provider, for example, might want to set <code>others</code> * completion provider, for example, might want to set <code>others</code> to
* to "<code>.</code>", to allow auto-activation for members of an object. * "<code>.</code>", to allow auto-activation for members of an object.
* *
* @param letters * @param letters Whether auto-activation should occur after any letter.
* Whether auto-activation should occur after any letter. * @param others A string of (non-letter) chars that auto-activation should
* @param others * occur after. This may be <code>null</code>.
* A string of (non-letter) chars that auto-activation should
* occur after. This may be <code>null</code>.
*/ */
public void setAutoActivationRules(boolean letters, String others) { public void setAutoActivationRules(boolean letters, String others) {
autoActivateAfterLetters = letters; autoActivateAfterLetters = letters;
autoActivateChars = others; autoActivateChars = others;
} }
/** /**
* Sets the param choices provider. This is used when a user * Sets the param choices provider. This is used when a user code-completes a
* code-completes a parameterized completion, such as a function or method. * parameterized completion, such as a function or method. For any parameter to
* For any parameter to the function/method, this object can return * the function/method, this object can return possible completions.
* possible completions.
* *
* @param pcp * @param pcp The parameter choices provider, or <code>null</code> for none.
* The parameter choices provider, or <code>null</code> for
* none.
* @see #getParameterChoicesProvider() * @see #getParameterChoicesProvider()
*/ */
public void setParameterChoicesProvider(ParameterChoicesProvider pcp) { public void setParameterChoicesProvider(ParameterChoicesProvider pcp) {
paramChoicesProvider = pcp; paramChoicesProvider = pcp;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -225,7 +218,7 @@ public abstract class CompletionProviderBase implements CompletionProvider {
public void setListCellRenderer(ListCellRenderer r) { public void setListCellRenderer(ListCellRenderer r) {
listCellRenderer = r; listCellRenderer = r;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -244,7 +237,7 @@ public abstract class CompletionProviderBase implements CompletionProvider {
paramListSeparator = separator; paramListSeparator = separator;
paramListEnd = listEnd; paramListEnd = listEnd;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */