mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-17 11:05:06 +00:00
ASM cleanup
This commit is contained in:
8 files changed
+12
-347
No files matched your search
@@ -21,42 +21,6 @@ public class AsmUtil
|
||||
super();
|
||||
}
|
||||
|
||||
public static MethodNode findMethod(final ClassNode cn, final String name) {
|
||||
return findMethod(cn, name, false);
|
||||
}
|
||||
|
||||
public static MethodNode findMethod(final ClassNode cn, final String name, final boolean optional) {
|
||||
for (final MethodNode ret : cn.methods) {
|
||||
if (ret.name.equals(name)) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
if (optional) {
|
||||
return null;
|
||||
}
|
||||
throw new MethodNotFoundException(name);
|
||||
}
|
||||
|
||||
public static MethodNode findMethod(final ClassNode cn, final Name name) {
|
||||
return findMethod(cn, name, false);
|
||||
}
|
||||
|
||||
public static MethodNode findMethod(final ClassNode cn, final Name name, final boolean optional) {
|
||||
for (final MethodNode ret : cn.methods) {
|
||||
if (name.matches(ret)) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
if (optional) {
|
||||
return null;
|
||||
}
|
||||
throw new MethodNotFoundException(name.deobf);
|
||||
}
|
||||
|
||||
public static FieldNode findField(final ClassNode cn, final String name) {
|
||||
return findField(cn, name, false);
|
||||
}
|
||||
|
||||
public static FieldNode findField(final ClassNode cn, final String name, final boolean optional) {
|
||||
for (final FieldNode ret : cn.fields) {
|
||||
if (name.equals(ret.name)) {
|
||||
@@ -69,39 +33,11 @@ public class AsmUtil
|
||||
throw new FieldNotFoundException(name);
|
||||
}
|
||||
|
||||
public static FieldNode findField(final ClassNode cn, final Name name) {
|
||||
return findField(cn, name, false);
|
||||
}
|
||||
|
||||
public static FieldNode findField(final ClassNode cn, final Name name, final boolean optional) {
|
||||
for (final FieldNode ret : cn.fields) {
|
||||
if (name.matches(ret)) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
if (optional) {
|
||||
return null;
|
||||
}
|
||||
throw new FieldNotFoundException(name.deobf);
|
||||
}
|
||||
|
||||
public static void makePublic(final MethodNode x) {
|
||||
x.access = ((x.access & 0xFFFFFFF9) | 0x1);
|
||||
}
|
||||
|
||||
public static void makePublic(final FieldNode x) {
|
||||
x.access = ((x.access & 0xFFFFFFF9) | 0x1);
|
||||
}
|
||||
|
||||
public static boolean transformInlinedSizeMethod(final ClassNode cn, final MethodNode method, final int oldValue, final int newValue) {
|
||||
return transformInlinedSizeMethod(cn, method, oldValue, newValue, false);
|
||||
}
|
||||
|
||||
public static boolean transformInlinedSizeMethod(final ClassNode cn, final MethodNode method, final int oldValue, final int newValue, final boolean optional) {
|
||||
boolean found = false;
|
||||
boolean foundOnce = false;
|
||||
final int i = 0;
|
||||
final ListIterator<AbstractInsnNode> it = (ListIterator<AbstractInsnNode>)method.instructions.iterator();
|
||||
final ListIterator<AbstractInsnNode> it = method.instructions.iterator();
|
||||
while (it.hasNext()) {
|
||||
final AbstractInsnNode insn = it.next();
|
||||
if (insn.getOpcode() == 3 && oldValue == 0) {
|
||||
@@ -161,7 +97,7 @@ public class AsmUtil
|
||||
it.set(new IntInsnNode(17, newValue));
|
||||
}
|
||||
else {
|
||||
it.set(new LdcInsnNode((Object)Integer.valueOf(newValue)));
|
||||
it.set(new LdcInsnNode(newValue));
|
||||
}
|
||||
found = false;
|
||||
}
|
||||
@@ -172,12 +108,4 @@ public class AsmUtil
|
||||
return foundOnce;
|
||||
}
|
||||
|
||||
public static void dump(final InsnList list) {
|
||||
final Textifier textifier = new Textifier();
|
||||
final TraceMethodVisitor visitor = new TraceMethodVisitor((Printer)textifier);
|
||||
list.accept((MethodVisitor)visitor);
|
||||
final PrintWriter writer = new PrintWriter(System.out);
|
||||
textifier.print(writer);
|
||||
writer.flush();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user