mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-06 02:35:40 +08:00
Modify remove isMatch old conditions in ReflectionTool
This commit is contained in:
@@ -107,38 +107,33 @@ internal object ReflectionTool {
|
|||||||
val iLModify = modifiers?.let(matchIndex) { e -> declares.filter { e.contains(it) }.lastIndex } ?: -1
|
val iLModify = modifiers?.let(matchIndex) { e -> declares.filter { e.contains(it) }.lastIndex } ?: -1
|
||||||
val iLNameCds = nameConditions?.let(matchIndex) { e -> declares.filter { e.contains(it) }.lastIndex } ?: -1
|
val iLNameCds = nameConditions?.let(matchIndex) { e -> declares.filter { e.contains(it) }.lastIndex } ?: -1
|
||||||
declares.forEachIndexed { index, instance ->
|
declares.forEachIndexed { index, instance ->
|
||||||
var isMatched = false
|
|
||||||
conditions {
|
conditions {
|
||||||
type?.also {
|
type?.also {
|
||||||
and((it == instance.type).let { hold ->
|
and((it == instance.type).let { hold ->
|
||||||
if (hold) iType++
|
if (hold) iType++
|
||||||
isMatched = true
|
|
||||||
hold && matchIndex.compare(iType, iLType)
|
hold && matchIndex.compare(iType, iLType)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
name.takeIf { it.isNotBlank() }?.also {
|
name.takeIf { it.isNotBlank() }?.also {
|
||||||
and((it == instance.name).let { hold ->
|
and((it == instance.name).let { hold ->
|
||||||
if (hold) iName++
|
if (hold) iName++
|
||||||
isMatched = true
|
|
||||||
hold && matchIndex.compare(iName, iLName)
|
hold && matchIndex.compare(iName, iLName)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
modifiers?.also {
|
modifiers?.also {
|
||||||
and(it.contains(instance).let { hold ->
|
and(it.contains(instance).let { hold ->
|
||||||
if (hold) iModify++
|
if (hold) iModify++
|
||||||
isMatched = true
|
|
||||||
hold && matchIndex.compare(iModify, iLModify)
|
hold && matchIndex.compare(iModify, iLModify)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
nameConditions?.also {
|
nameConditions?.also {
|
||||||
and(it.contains(instance).let { hold ->
|
and(it.contains(instance).let { hold ->
|
||||||
if (hold) iNameCds++
|
if (hold) iNameCds++
|
||||||
isMatched = true
|
|
||||||
hold && matchIndex.compare(iNameCds, iLNameCds)
|
hold && matchIndex.compare(iNameCds, iLNameCds)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
orderIndex.compare(index, declares.lastIndex) { and(it); isMatched = it }
|
orderIndex.compare(index, declares.lastIndex) { and(it) }
|
||||||
}.finally { if (isMatched) fields.add(instance.apply { isAccessible = true }) }
|
}.finally { fields.add(instance.apply { isAccessible = true }) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.takeIf { it.isNotEmpty() }?.also { ReflectsCacheStore.putFields(hashCode(classSet), it) } ?: findSuperOrThrow(classSet)
|
}.takeIf { it.isNotEmpty() }?.also { ReflectsCacheStore.putFields(hashCode(classSet), it) } ?: findSuperOrThrow(classSet)
|
||||||
@@ -176,59 +171,51 @@ internal object ReflectionTool {
|
|||||||
val iLModify = modifiers?.let(matchIndex) { e -> declares.filter { e.contains(it) }.lastIndex } ?: -1
|
val iLModify = modifiers?.let(matchIndex) { e -> declares.filter { e.contains(it) }.lastIndex } ?: -1
|
||||||
val iLNameCds = nameConditions?.let(matchIndex) { e -> declares.filter { e.contains(it) }.lastIndex } ?: -1
|
val iLNameCds = nameConditions?.let(matchIndex) { e -> declares.filter { e.contains(it) }.lastIndex } ?: -1
|
||||||
declares.forEachIndexed { index, instance ->
|
declares.forEachIndexed { index, instance ->
|
||||||
var isMatched = false
|
|
||||||
conditions {
|
conditions {
|
||||||
name.takeIf { it.isNotBlank() }?.also {
|
name.takeIf { it.isNotBlank() }?.also {
|
||||||
and((it == instance.name).let { hold ->
|
and((it == instance.name).let { hold ->
|
||||||
if (hold) iName++
|
if (hold) iName++
|
||||||
isMatched = true
|
|
||||||
hold && matchIndex.compare(iName, iLName)
|
hold && matchIndex.compare(iName, iLName)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
returnType?.also {
|
returnType?.also {
|
||||||
and((it == instance.returnType).let { hold ->
|
and((it == instance.returnType).let { hold ->
|
||||||
if (hold) iReturnType++
|
if (hold) iReturnType++
|
||||||
isMatched = true
|
|
||||||
hold && matchIndex.compare(iReturnType, iLReturnType)
|
hold && matchIndex.compare(iReturnType, iLReturnType)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
paramCount.takeIf { it >= 0 }?.also {
|
paramCount.takeIf { it >= 0 }?.also {
|
||||||
and((instance.parameterTypes.size == it).let { hold ->
|
and((instance.parameterTypes.size == it).let { hold ->
|
||||||
if (hold) iParamCount++
|
if (hold) iParamCount++
|
||||||
isMatched = true
|
|
||||||
hold && matchIndex.compare(iParamCount, iLParamCount)
|
hold && matchIndex.compare(iParamCount, iLParamCount)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
paramCountRange.takeIf { it.isEmpty().not() }?.also {
|
paramCountRange.takeIf { it.isEmpty().not() }?.also {
|
||||||
and((instance.parameterTypes.size in it).let { hold ->
|
and((instance.parameterTypes.size in it).let { hold ->
|
||||||
if (hold) iParamCountRange++
|
if (hold) iParamCountRange++
|
||||||
isMatched = true
|
|
||||||
hold && matchIndex.compare(iParamCountRange, iLParamCountRange)
|
hold && matchIndex.compare(iParamCountRange, iLParamCountRange)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
paramTypes?.also {
|
paramTypes?.also {
|
||||||
and(arrayContentsEq(it, instance.parameterTypes).let { hold ->
|
and(arrayContentsEq(it, instance.parameterTypes).let { hold ->
|
||||||
if (hold) iParamTypes++
|
if (hold) iParamTypes++
|
||||||
isMatched = true
|
|
||||||
hold && matchIndex.compare(iParamTypes, iLParamTypes)
|
hold && matchIndex.compare(iParamTypes, iLParamTypes)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
modifiers?.also {
|
modifiers?.also {
|
||||||
and(it.contains(instance).let { hold ->
|
and(it.contains(instance).let { hold ->
|
||||||
if (hold) iModify++
|
if (hold) iModify++
|
||||||
isMatched = true
|
|
||||||
hold && matchIndex.compare(iModify, iLModify)
|
hold && matchIndex.compare(iModify, iLModify)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
nameConditions?.also {
|
nameConditions?.also {
|
||||||
and(it.contains(instance).let { hold ->
|
and(it.contains(instance).let { hold ->
|
||||||
if (hold) iNameCds++
|
if (hold) iNameCds++
|
||||||
isMatched = true
|
|
||||||
hold && matchIndex.compare(iNameCds, iLNameCds)
|
hold && matchIndex.compare(iNameCds, iLNameCds)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
orderIndex.compare(index, declares.lastIndex) { and(it); isMatched = it }
|
orderIndex.compare(index, declares.lastIndex) { and(it) }
|
||||||
}.finally { if (isMatched) methods.add(instance.apply { isAccessible = true }) }
|
}.finally { methods.add(instance.apply { isAccessible = true }) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.takeIf { it.isNotEmpty() }?.also { ReflectsCacheStore.putMethods(hashCode(classSet), it) } ?: findSuperOrThrow(classSet)
|
}.takeIf { it.isNotEmpty() }?.also { ReflectsCacheStore.putMethods(hashCode(classSet), it) } ?: findSuperOrThrow(classSet)
|
||||||
@@ -259,38 +246,33 @@ internal object ReflectionTool {
|
|||||||
val iLParamTypes = paramTypes?.let(matchIndex) { e -> declares.filter { arrayContentsEq(e, it.parameterTypes) }.lastIndex } ?: -1
|
val iLParamTypes = paramTypes?.let(matchIndex) { e -> declares.filter { arrayContentsEq(e, it.parameterTypes) }.lastIndex } ?: -1
|
||||||
val iLModify = modifiers?.let(matchIndex) { e -> declares.filter { e.contains(it) }.lastIndex } ?: -1
|
val iLModify = modifiers?.let(matchIndex) { e -> declares.filter { e.contains(it) }.lastIndex } ?: -1
|
||||||
declares.forEachIndexed { index, instance ->
|
declares.forEachIndexed { index, instance ->
|
||||||
var isMatched = false
|
|
||||||
conditions {
|
conditions {
|
||||||
paramCount.takeIf { it >= 0 }?.also {
|
paramCount.takeIf { it >= 0 }?.also {
|
||||||
and((instance.parameterTypes.size == it).let { hold ->
|
and((instance.parameterTypes.size == it).let { hold ->
|
||||||
if (hold) iParamCount++
|
if (hold) iParamCount++
|
||||||
isMatched = true
|
|
||||||
hold && matchIndex.compare(iParamCount, iLParamCount)
|
hold && matchIndex.compare(iParamCount, iLParamCount)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
paramCountRange.takeIf { it.isEmpty().not() }?.also {
|
paramCountRange.takeIf { it.isEmpty().not() }?.also {
|
||||||
and((instance.parameterTypes.size in it).let { hold ->
|
and((instance.parameterTypes.size in it).let { hold ->
|
||||||
if (hold) iParamCountRange++
|
if (hold) iParamCountRange++
|
||||||
isMatched = true
|
|
||||||
hold && matchIndex.compare(iParamCountRange, iLParamCountRange)
|
hold && matchIndex.compare(iParamCountRange, iLParamCountRange)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
paramTypes?.also {
|
paramTypes?.also {
|
||||||
and(arrayContentsEq(it, instance.parameterTypes).let { hold ->
|
and(arrayContentsEq(it, instance.parameterTypes).let { hold ->
|
||||||
if (hold) iParamTypes++
|
if (hold) iParamTypes++
|
||||||
isMatched = true
|
|
||||||
hold && matchIndex.compare(iParamTypes, iLParamTypes)
|
hold && matchIndex.compare(iParamTypes, iLParamTypes)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
modifiers?.also {
|
modifiers?.also {
|
||||||
and(it.contains(instance).let { hold ->
|
and(it.contains(instance).let { hold ->
|
||||||
if (hold) iModify++
|
if (hold) iModify++
|
||||||
isMatched = true
|
|
||||||
hold && matchIndex.compare(iModify, iLModify)
|
hold && matchIndex.compare(iModify, iLModify)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
orderIndex.compare(index, declares.lastIndex) { and(it); isMatched = it }
|
orderIndex.compare(index, declares.lastIndex) { and(it) }
|
||||||
}.finally { if (isMatched) constructors.add(instance.apply { isAccessible = true }) }
|
}.finally { constructors.add(instance.apply { isAccessible = true }) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.takeIf { it.isNotEmpty() }?.also { ReflectsCacheStore.putConstructors(hashCode(classSet), it) } ?: findSuperOrThrow(classSet)
|
}.takeIf { it.isNotEmpty() }?.also { ReflectsCacheStore.putConstructors(hashCode(classSet), it) } ?: findSuperOrThrow(classSet)
|
||||||
|
Reference in New Issue
Block a user