Add getFieldAccess

Signed-off-by: Graham <gpe@openrs2.dev>
master
Graham 5 years ago
parent 8b5f3402e2
commit 8cac7a48b5
  1. 4
      asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.kt
  2. 1
      asm/src/main/java/dev/openrs2/asm/classpath/ClassMetadata.kt
  3. 5
      asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.kt

@ -27,6 +27,10 @@ class AsmClassMetadata(
override val methods override val methods
get() = clazz.methods.map(::MemberDesc) get() = clazz.methods.map(::MemberDesc)
override fun getFieldAccess(field: MemberDesc): Int? {
return clazz.fields.find { it.name == field.name && it.desc == field.desc }?.access
}
override fun getMethodAccess(method: MemberDesc): Int? { override fun getMethodAccess(method: MemberDesc): Int? {
return clazz.methods.find { it.name == method.name && it.desc == method.desc }?.access return clazz.methods.find { it.name == method.name && it.desc == method.desc }?.access
} }

@ -11,6 +11,7 @@ abstract class ClassMetadata {
abstract val fields: List<MemberDesc> abstract val fields: List<MemberDesc>
abstract val methods: List<MemberDesc> abstract val methods: List<MemberDesc>
abstract fun getFieldAccess(field: MemberDesc): Int?
abstract fun getMethodAccess(method: MemberDesc): Int? abstract fun getMethodAccess(method: MemberDesc): Int?
fun isOverride(method: MemberDesc): Boolean { fun isOverride(method: MemberDesc): Boolean {

@ -29,6 +29,11 @@ class ReflectionClassMetadata(private val classPath: ClassPath, private val claz
override val methods override val methods
get() = clazz.declaredMethods.map { MemberDesc(it.name, Type.getMethodDescriptor(it)) } get() = clazz.declaredMethods.map { MemberDesc(it.name, Type.getMethodDescriptor(it)) }
override fun getFieldAccess(field: MemberDesc): Int? {
return clazz.declaredFields.find { it.name == field.name && Type.getDescriptor(it.type) == field.desc }
?.modifiers
}
override fun getMethodAccess(method: MemberDesc): Int? { override fun getMethodAccess(method: MemberDesc): Int? {
return clazz.declaredMethods.find { it.name == method.name && Type.getMethodDescriptor(it) == method.desc } return clazz.declaredMethods.find { it.name == method.name && Type.getMethodDescriptor(it) == method.desc }
?.modifiers ?.modifiers

Loading…
Cancel
Save