Skip to content

Commit

Permalink
propagator refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Jul 17, 2024
1 parent 673078f commit e72c6be
Showing 1 changed file with 12 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ abstract class MappingResolver<T : MappingResolver<T>>(val name: String) {

open val unmappedNs = Namespace("official")

open val propogator: (MemoryMappingTree.() -> Unit)? = null
open fun propogator(tree: MemoryMappingTree) {

}

open suspend fun finalize() {
_entries.finalize()
Expand Down Expand Up @@ -125,35 +127,16 @@ abstract class MappingResolver<T : MappingResolver<T>>(val name: String) {
}
}

if (propogator != null) {
propogator?.invoke(resolved)
val filled = mutableSetOf<Namespace>()
for (entry in sorted) {
val toFill = entry.provides.map { it.first }.toSet() - filled
if (toFill.isNotEmpty()) {
resolved.accept(resolved.copyTo(entry.requires, toFill, resolved))
filled.addAll(toFill)
}
for (afterPropogate in entry.afterPropogate) {
afterPropogate(resolved)
}
propogator(resolved)
val filled = mutableSetOf<Namespace>()
for (entry in sorted) {
val toFill = entry.provides.map { it.first }.toSet() - filled
if (toFill.isNotEmpty()) {
resolved.accept(resolved.copyTo(entry.requires, toFill, resolved))
filled.addAll(toFill)
}
} else {
// at least copy the class names
val filled = mutableSetOf<Namespace>()
for (entry in sorted) {
val toFill = entry.provides.map { it.first }.toSet() - filled
if (toFill.isNotEmpty()) {
resolved.accept(resolved.copyTo(entry.requires, toFill, resolved).delegator(object : NullDelegator() {
override fun visitClass(
delegate: MappingVisitor,
names: Map<Namespace, InternalName>
): ClassVisitor? {
return default.visitClass(delegate, names)
}
}))
filled.addAll(toFill)
}
for (afterPropogate in entry.afterPropogate) {
afterPropogate(resolved)
}
}

Expand Down

0 comments on commit e72c6be

Please sign in to comment.