diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.java b/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.java deleted file mode 100644 index 2e4450f9..00000000 --- a/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.java +++ /dev/null @@ -1,72 +0,0 @@ -package dev.openrs2.asm.classpath; - -import com.google.common.collect.ImmutableList; -import dev.openrs2.asm.MemberDesc; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.tree.ClassNode; - -public final class AsmClassMetadata extends ClassMetadata { - private final ClassPath classPath; - private final ClassNode clazz; - private final boolean dependency; - - public AsmClassMetadata(ClassPath classPath, ClassNode clazz, boolean dependency) { - this.classPath = classPath; - this.clazz = clazz; - this.dependency = dependency; - } - - @Override - public String getName() { - return clazz.name; - } - - @Override - public boolean getDependency() { - return dependency; - } - - @Override - public boolean getInterface() { - return (clazz.access & Opcodes.ACC_INTERFACE) != 0; - } - - @Override - public ClassMetadata getSuperClass() { - if (clazz.superName != null) { - return classPath.get(clazz.superName); - } - return null; - } - - @Override - public ImmutableList getSuperInterfaces() { - return clazz.interfaces.stream() - .map(classPath::get) - .collect(ImmutableList.toImmutableList()); - } - - @Override - public ImmutableList getFields() { - return clazz.fields.stream() - .map(MemberDesc::new) - .collect(ImmutableList.toImmutableList()); - } - - @Override - public ImmutableList getMethods() { - return clazz.methods.stream() - .map(MemberDesc::new) - .collect(ImmutableList.toImmutableList()); - } - - @Override - public boolean isNative(MemberDesc method) { - for (var m : clazz.methods) { - if (m.name.equals(method.getName()) && m.desc.equals(method.getDesc())) { - return (m.access & Opcodes.ACC_NATIVE) != 0; - } - } - return false; - } -} diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.kt b/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.kt new file mode 100644 index 00000000..f98ce568 --- /dev/null +++ b/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.kt @@ -0,0 +1,34 @@ +package dev.openrs2.asm.classpath + +import dev.openrs2.asm.MemberDesc +import org.objectweb.asm.Opcodes +import org.objectweb.asm.tree.ClassNode + +class AsmClassMetadata( + private val classPath: ClassPath, + private val clazz: ClassNode, + override val dependency: Boolean +) : ClassMetadata() { + override val name: String + get() = clazz.name + + override val `interface` + get() = clazz.access and Opcodes.ACC_INTERFACE != 0 + + override val superClass + get() = if (clazz.superName != null) classPath[clazz.superName] else null + + override val superInterfaces + get() = clazz.interfaces.map { classPath[it] }.toList() + + override val fields + get() = clazz.fields.map { MemberDesc(it) }.toList() + + override val methods + get() = clazz.methods.map { MemberDesc(it) }.toList() + + override fun isNative(method: MemberDesc): Boolean { + val m = clazz.methods.find { it.name == method.name && it.desc == method.desc } ?: return false + return m.access and Opcodes.ACC_NATIVE != 0 + } +}