Add hasCode() method

master
Graham 5 years ago
parent 3f1d2dc4a3
commit eec9279a2c
  1. 4
      asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.java
  2. 4
      asm/src/main/java/dev/openrs2/asm/classpath/Library.java
  3. 4
      asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt
  4. 4
      bundler/src/main/java/dev/openrs2/bundler/transform/BufferSizeTransformer.java
  5. 3
      deob/src/main/java/dev/openrs2/deob/transform/BitwiseOpTransformer.java
  6. 4
      deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.java
  7. 3
      deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.java
  8. 2
      deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.java
  9. 4
      deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.java

@ -163,6 +163,10 @@ public final class MethodNodeUtils {
} while (changed);
}
public static boolean hasCode(MethodNode method) {
return (method.access & (Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT)) == 0;
}
private MethodNodeUtils() {
/* empty */
}

@ -15,13 +15,13 @@ import java.util.jar.JarOutputStream;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import dev.openrs2.asm.MethodNodeUtils;
import dev.openrs2.asm.remap.ClassForNameRemapper;
import dev.openrs2.util.io.DeterministicJarOutputStream;
import dev.openrs2.util.io.SkipOutputStream;
import org.apache.harmony.pack200.Pack200;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.commons.ClassRemapper;
import org.objectweb.asm.commons.Remapper;
import org.objectweb.asm.tree.ClassNode;
@ -119,7 +119,7 @@ public final class Library implements Iterable<ClassNode> {
for (var clazz : classes.values()) {
for (var method : clazz.methods) {
if ((method.access & (Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT)) == 0) {
if (MethodNodeUtils.hasCode(method)) {
ClassForNameRemapper.remap(remapper, method);
}
}

@ -1,8 +1,8 @@
package dev.openrs2.asm.transform
import dev.openrs2.asm.MethodNodeUtils.hasCode
import dev.openrs2.asm.classpath.ClassPath
import dev.openrs2.asm.classpath.Library
import org.objectweb.asm.Opcodes
import org.objectweb.asm.tree.ClassNode
import org.objectweb.asm.tree.FieldNode
import org.objectweb.asm.tree.MethodNode
@ -29,7 +29,7 @@ abstract class Transformer {
for (method in clazz.methods) {
changed = changed or preTransformMethod(classPath, library, clazz, method)
if (method.access and (Opcodes.ACC_NATIVE or Opcodes.ACC_ABSTRACT) == 0) {
if (hasCode(method)) {
changed = changed or transformCode(classPath, library, clazz, method)
}

@ -5,10 +5,10 @@ import java.util.Optional;
import dev.openrs2.asm.InsnMatcher;
import dev.openrs2.asm.InsnNodeUtils;
import dev.openrs2.asm.MemberRef;
import dev.openrs2.asm.MethodNodeUtils;
import dev.openrs2.asm.classpath.ClassPath;
import dev.openrs2.asm.classpath.Library;
import dev.openrs2.asm.transform.Transformer;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.LdcInsnNode;
@ -46,7 +46,7 @@ public final class BufferSizeTransformer extends Transformer {
for (var library : classPath.getLibraries()) {
for (var clazz : library) {
for (var method : clazz.methods) {
if ((method.access & (Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT)) != 0) {
if (!MethodNodeUtils.hasCode(method)) {
continue;
}

@ -5,6 +5,7 @@ import java.util.Map;
import dev.openrs2.asm.InsnMatcher;
import dev.openrs2.asm.MemberRef;
import dev.openrs2.asm.MethodNodeUtils;
import dev.openrs2.asm.classpath.ClassPath;
import dev.openrs2.asm.classpath.Library;
import dev.openrs2.asm.transform.Transformer;
@ -34,7 +35,7 @@ public final class BitwiseOpTransformer extends Transformer {
for (var library : classPath.getLibraries()) {
for (var clazz : library) {
for (var method : clazz.methods) {
if ((method.access & (Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT)) != 0) {
if (!MethodNodeUtils.hasCode(method)) {
continue;
}

@ -7,10 +7,10 @@ import java.util.Set;
import dev.openrs2.asm.InsnMatcher;
import dev.openrs2.asm.MemberRef;
import dev.openrs2.asm.MethodNodeUtils;
import dev.openrs2.asm.classpath.ClassPath;
import dev.openrs2.asm.classpath.Library;
import dev.openrs2.asm.transform.Transformer;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
@ -37,7 +37,7 @@ public final class CounterTransformer extends Transformer {
for (var library : classPath.getLibraries()) {
for (var clazz : library) {
for (var method : clazz.methods) {
if ((method.access & (Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT)) == 0) {
if (MethodNodeUtils.hasCode(method)) {
findCounters(method, references, resets, increments);
}
}

@ -6,6 +6,7 @@ import java.util.Set;
import dev.openrs2.asm.InsnMatcher;
import dev.openrs2.asm.MemberRef;
import dev.openrs2.asm.MethodNodeUtils;
import dev.openrs2.asm.classpath.ClassPath;
import dev.openrs2.asm.classpath.Library;
import dev.openrs2.asm.transform.Transformer;
@ -38,7 +39,7 @@ public final class OpaquePredicateTransformer extends Transformer {
for (var library : classPath.getLibraries()) {
for (var clazz : library) {
for (var method : clazz.methods) {
if ((method.access & (Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT)) == 0) {
if (MethodNodeUtils.hasCode(method)) {
findFlowObstructors(library, method);
}
}

@ -87,7 +87,7 @@ public final class ResetTransformer extends Transformer {
for (var library : classPath.getLibraries()) {
for (var clazz : library) {
for (var method : clazz.methods) {
if ((method.access & (Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT)) != 0) {
if (!MethodNodeUtils.hasCode(method)) {
continue;
}

@ -66,7 +66,7 @@ public final class UnusedArgTransformer extends Transformer {
for (var library : classPath.getLibraries()) {
for (var clazz : library) {
for (var method : clazz.methods) {
if ((method.access & (Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT)) == 0) {
if (MethodNodeUtils.hasCode(method)) {
populateRetainedArgs(classPath, clazz, method);
}
}
@ -123,7 +123,7 @@ public final class UnusedArgTransformer extends Transformer {
@Override
protected boolean preTransformMethod(ClassPath classPath, Library library, ClassNode clazz, MethodNode method) throws AnalyzerException {
/* delete unused int args from call sites */
if ((method.access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_NATIVE)) == 0) {
if (MethodNodeUtils.hasCode(method)) {
var analyzer = new Analyzer<>(new ConstSourceInterpreter());
var frames = analyzer.analyze(clazz.name, method);
var deadInsns = new ArrayList<AbstractInsnNode>();

Loading…
Cancel
Save