forked from openrs2/openrs2
parent
e5af454815
commit
3ee6d57ba9
@ -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<ClassMetadata> getSuperInterfaces() { |
||||
return clazz.interfaces.stream() |
||||
.map(classPath::get) |
||||
.collect(ImmutableList.toImmutableList()); |
||||
} |
||||
|
||||
@Override |
||||
public ImmutableList<MemberDesc> getFields() { |
||||
return clazz.fields.stream() |
||||
.map(MemberDesc::new) |
||||
.collect(ImmutableList.toImmutableList()); |
||||
} |
||||
|
||||
@Override |
||||
public ImmutableList<MemberDesc> 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; |
||||
} |
||||
} |
@ -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 |
||||
} |
||||
} |
Loading…
Reference in new issue