Skip to content

Commit

Permalink
switch to commons impl of char reader
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Sep 4, 2024
1 parent 687b0ce commit 320bf93
Show file tree
Hide file tree
Showing 126 changed files with 339,622 additions and 1,409 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import kotlinx.coroutines.runBlocking
import okio.buffer
import okio.sink
import okio.source
import xyz.wagyourtail.commonskt.utils.mutliAssociate
import xyz.wagyourtail.unimined.mapping.EnvType
import xyz.wagyourtail.unimined.mapping.Namespace
import xyz.wagyourtail.unimined.mapping.cli.Main.Companion.LOGGER
import xyz.wagyourtail.unimined.mapping.formats.FormatRegistry
import xyz.wagyourtail.unimined.mapping.propogator.Propagator
import xyz.wagyourtail.unimined.mapping.tree.MemoryMappingTree
import xyz.wagyourtail.unimined.mapping.util.mutliAssociate
import xyz.wagyourtail.unimined.mapping.visitor.delegate.copyTo
import kotlin.time.measureTime

Expand Down
Binary file added client.jar
Binary file not shown.
155,412 changes: 155,412 additions & 0 deletions preProp-intermediary-yarn-1-stubs-0641d60.umf

Large diffs are not rendered by default.

183,615 changes: 183,615 additions & 0 deletions propagated.umf

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package xyz.wagyourtail.unimined.mapping.formats

import okio.BufferedSource
import xyz.wagyourtail.commonskt.reader.CharReader
import xyz.wagyourtail.commonskt.reader.StringCharReader
import xyz.wagyourtail.unimined.mapping.EnvType
import xyz.wagyourtail.unimined.mapping.tree.AbstractMappingTree
import xyz.wagyourtail.unimined.mapping.tree.MemoryMappingTree
import xyz.wagyourtail.unimined.mapping.util.CharReader
import xyz.wagyourtail.unimined.mapping.visitor.MappingVisitor

interface FormatReader {
Expand All @@ -21,7 +22,7 @@ interface FormatReader {
envType: EnvType = EnvType.JOINED,
nsMapping: Map<String, String> = mapOf()
): MemoryMappingTree = MemoryMappingTree().also {
read(CharReader(content), null, it, envType, nsMapping)
read(StringCharReader(content), null, it, envType, nsMapping)
}

suspend fun read(
Expand All @@ -30,7 +31,7 @@ interface FormatReader {
envType: EnvType = EnvType.JOINED,
nsMapping: Map<String, String> = mapOf()
) {
read(CharReader(content), into, into, envType, nsMapping)
read(StringCharReader(content), into, into, envType, nsMapping)
}

suspend fun read(
Expand All @@ -39,7 +40,7 @@ interface FormatReader {
into: MappingVisitor,
envType: EnvType = EnvType.JOINED,
nsMapping: Map<String, String> = mapOf()
) = read(CharReader(content), context, into, envType, nsMapping)
) = read(StringCharReader(content), context, into, envType, nsMapping)

suspend fun read(
input: BufferedSource,
Expand All @@ -55,7 +56,7 @@ interface FormatReader {
envType: EnvType = EnvType.JOINED,
nsMapping: Map<String, String> = mapOf()
) {
read(CharReader(input.readUtf8()), into, into, envType, nsMapping)
read(StringCharReader(input.readUtf8()), into, into, envType, nsMapping)
}

suspend fun read(
Expand All @@ -65,19 +66,19 @@ interface FormatReader {
envType: EnvType = EnvType.JOINED,
nsMapping: Map<String, String> = mapOf()
) {
read(CharReader(input.readUtf8()), context, into, envType, nsMapping)
read(StringCharReader(input.readUtf8()), context, into, envType, nsMapping)
}

suspend fun read(
input: CharReader,
input: CharReader<*>,
envType: EnvType = EnvType.JOINED,
nsMapping: Map<String, String> = mapOf()
): MemoryMappingTree = MemoryMappingTree().also {
read(input, null, it, envType, nsMapping)
}

suspend fun read(
input: CharReader,
input: CharReader<*>,
into: AbstractMappingTree,
envType: EnvType = EnvType.JOINED,
nsMapping: Map<String, String> = mapOf()
Expand All @@ -86,7 +87,7 @@ interface FormatReader {
}

suspend fun read(
input: CharReader,
input: CharReader<*>,
context: AbstractMappingTree?,
into: MappingVisitor,
envType: EnvType = EnvType.JOINED,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package xyz.wagyourtail.unimined.mapping.formats.at

import okio.BufferedSource
import xyz.wagyourtail.commonskt.reader.CharReader
import xyz.wagyourtail.unimined.mapping.EnvType
import xyz.wagyourtail.unimined.mapping.Namespace
import xyz.wagyourtail.unimined.mapping.formats.FormatReader
Expand All @@ -10,7 +11,6 @@ import xyz.wagyourtail.unimined.mapping.jvms.four.three.three.MethodDescriptor
import xyz.wagyourtail.unimined.mapping.jvms.four.two.one.InternalName
import xyz.wagyourtail.unimined.mapping.tree.AbstractMappingTree
import xyz.wagyourtail.unimined.mapping.tree.node._class.member.WildcardNode
import xyz.wagyourtail.unimined.mapping.util.CharReader
import xyz.wagyourtail.unimined.mapping.visitor.AccessParentVisitor
import xyz.wagyourtail.unimined.mapping.visitor.AccessType
import xyz.wagyourtail.unimined.mapping.visitor.MappingVisitor
Expand Down Expand Up @@ -94,7 +94,7 @@ object ATReader : FormatReader {
}

override suspend fun read(
input: CharReader,
input: CharReader<*>,
context: AbstractMappingTree?,
into: MappingVisitor,
envType: EnvType,
Expand All @@ -105,7 +105,7 @@ object ATReader : FormatReader {
applyData(data, into, ns)
}

fun readData(input: CharReader): List<ATData> {
fun readData(input: CharReader<*>): List<ATData> {
val data = mutableListOf<ATData>()
while (!input.exhausted()) {
if (input.peek() == '\n') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package xyz.wagyourtail.unimined.mapping.formats.at

import xyz.wagyourtail.commonskt.collection.defaultedMapOf
import xyz.wagyourtail.unimined.mapping.EnvType
import xyz.wagyourtail.unimined.mapping.Namespace
import xyz.wagyourtail.unimined.mapping.formats.FormatWriter
Expand All @@ -17,7 +18,6 @@ import xyz.wagyourtail.unimined.mapping.jvms.four.two.one.InternalName
import xyz.wagyourtail.unimined.mapping.jvms.four.two.two.UnqualifiedName
import xyz.wagyourtail.unimined.mapping.tree.AbstractMappingTree
import xyz.wagyourtail.unimined.mapping.tree.node._class.member.WildcardNode
import xyz.wagyourtail.unimined.mapping.util.defaultedMapOf
import xyz.wagyourtail.unimined.mapping.visitor.*
import xyz.wagyourtail.unimined.mapping.visitor.delegate.NullDelegator
import xyz.wagyourtail.unimined.mapping.visitor.delegate.delegator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package xyz.wagyourtail.unimined.mapping.formats.at

import okio.BufferedSource
import xyz.wagyourtail.commonskt.reader.CharReader
import xyz.wagyourtail.unimined.mapping.EnvType
import xyz.wagyourtail.unimined.mapping.Namespace
import xyz.wagyourtail.unimined.mapping.formats.FormatReader
import xyz.wagyourtail.unimined.mapping.formats.at.ATReader.ATData
import xyz.wagyourtail.unimined.mapping.formats.at.ATReader.parseAccess
import xyz.wagyourtail.unimined.mapping.jvms.four.two.one.InternalName
import xyz.wagyourtail.unimined.mapping.tree.AbstractMappingTree
import xyz.wagyourtail.unimined.mapping.util.CharReader
import xyz.wagyourtail.unimined.mapping.visitor.MappingVisitor

/**
Expand All @@ -23,7 +23,7 @@ object LegacyATReader : FormatReader {
}

override suspend fun read(
input: CharReader,
input: CharReader<*>,
context: AbstractMappingTree?,
into: MappingVisitor,
envType: EnvType,
Expand All @@ -34,7 +34,7 @@ object LegacyATReader : FormatReader {
ATReader.applyData(data, into, ns)
}

fun readData(input: CharReader): List<ATData> {
fun readData(input: CharReader<*>): List<ATData> {
val data = mutableListOf<ATData>()
while (!input.exhausted()) {
if (input.peek() == '\n') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package xyz.wagyourtail.unimined.mapping.formats.aw

import okio.BufferedSource
import xyz.wagyourtail.commonskt.reader.CharReader
import xyz.wagyourtail.unimined.mapping.EnvType
import xyz.wagyourtail.unimined.mapping.Namespace
import xyz.wagyourtail.unimined.mapping.formats.FormatReader
Expand All @@ -15,7 +16,6 @@ import xyz.wagyourtail.unimined.mapping.jvms.four.three.two.ObjectType
import xyz.wagyourtail.unimined.mapping.jvms.four.two.one.InternalName
import xyz.wagyourtail.unimined.mapping.jvms.four.two.two.UnqualifiedName
import xyz.wagyourtail.unimined.mapping.tree.AbstractMappingTree
import xyz.wagyourtail.unimined.mapping.util.CharReader
import xyz.wagyourtail.unimined.mapping.visitor.AccessType
import xyz.wagyourtail.unimined.mapping.visitor.MappingVisitor
import xyz.wagyourtail.unimined.mapping.visitor.use
Expand All @@ -41,7 +41,7 @@ object AWReader: FormatReader {
)

override suspend fun read(
input: CharReader,
input: CharReader<*>,
context: AbstractMappingTree?,
into: MappingVisitor,
envType: EnvType,
Expand Down Expand Up @@ -156,7 +156,7 @@ object AWReader: FormatReader {
}
}

fun readData(input: CharReader): AWMappings {
fun readData(input: CharReader<*>): AWMappings {
val aw = input.takeNextLiteral { it.isWhitespace() }
val version = input.takeNextLiteral { it.isWhitespace() }
val namespace = input.takeNextLiteral { it.isWhitespace() }!!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package xyz.wagyourtail.unimined.mapping.formats.aw

import xyz.wagyourtail.commonskt.collection.defaultedMapOf
import xyz.wagyourtail.commonskt.utils.ListCompare
import xyz.wagyourtail.commonskt.utils.comparable
import xyz.wagyourtail.unimined.mapping.EnvType
import xyz.wagyourtail.unimined.mapping.Namespace
import xyz.wagyourtail.unimined.mapping.formats.FormatWriter
Expand All @@ -17,8 +20,6 @@ import xyz.wagyourtail.unimined.mapping.jvms.four.two.one.InternalName
import xyz.wagyourtail.unimined.mapping.jvms.four.two.two.UnqualifiedName
import xyz.wagyourtail.unimined.mapping.tree.AbstractMappingTree
import xyz.wagyourtail.unimined.mapping.tree.node._class.member.WildcardNode
import xyz.wagyourtail.unimined.mapping.util.ListCompare
import xyz.wagyourtail.unimined.mapping.util.defaultedMapOf
import xyz.wagyourtail.unimined.mapping.visitor.*
import xyz.wagyourtail.unimined.mapping.visitor.delegate.NullDelegator
import xyz.wagyourtail.unimined.mapping.visitor.delegate.delegator
Expand Down Expand Up @@ -242,7 +243,7 @@ object AWWriter : FormatWriter {
override fun visitFooter(delegate: MappingVisitor) {
writeData(AWReader.AWMappings(ns!!, mappings.values.map { map ->
map.sortedBy {
ListCompare(it.target.toString(), it.access)
listOf(it.target.toString(), it.access).comparable()
} }.flatten().toSet()), append)
}
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package xyz.wagyourtail.unimined.mapping.formats.csrg

import okio.BufferedSource
import xyz.wagyourtail.commonskt.reader.CharReader
import xyz.wagyourtail.unimined.mapping.EnvType
import xyz.wagyourtail.unimined.mapping.Namespace
import xyz.wagyourtail.unimined.mapping.formats.FormatReader
import xyz.wagyourtail.unimined.mapping.jvms.four.three.three.MethodDescriptor
import xyz.wagyourtail.unimined.mapping.jvms.four.two.one.InternalName
import xyz.wagyourtail.unimined.mapping.jvms.four.two.one.PackageName
import xyz.wagyourtail.unimined.mapping.tree.AbstractMappingTree
import xyz.wagyourtail.unimined.mapping.util.CharReader
import xyz.wagyourtail.unimined.mapping.visitor.MappingVisitor
import xyz.wagyourtail.unimined.mapping.visitor.use

Expand Down Expand Up @@ -54,7 +54,7 @@ object CsrgReader : FormatReader {
}

override suspend fun read(
input: CharReader,
input: CharReader<*>,
context: AbstractMappingTree?,
into: MappingVisitor,
envType: EnvType,
Expand All @@ -72,35 +72,35 @@ object CsrgReader : FormatReader {
input.takeLine()
continue
}
val parts = input.takeRemainingOnLine()
val parts = input.takeRemainingLiteralOnLine()
when (parts.size) {
CLASS_MAPPING -> {
val src = InternalName.read(parts[0].second)
val dst = context.mapPackage(srcNs, dstNs, InternalName.read(parts[1].second))
val src = InternalName.read(parts[0])
val dst = context.mapPackage(srcNs, dstNs, InternalName.read(parts[1]))
visitClass(mapOf(srcNs to src, dstNs to dst))?.visitEnd()
}

FIELD_MAPPING -> {
val dstCls = context.mapPackage(srcNs, dstNs, InternalName.read(parts[0].second))
val srcName = parts[1].second
val dstName = parts[2].second
val dstCls = context.mapPackage(srcNs, dstNs, InternalName.read(parts[0]))
val srcName = parts[1]
val dstName = parts[2]
visitClass(mapOf(dstNs to dstCls))?.use {
visitField(mapOf(srcNs to (srcName to null), dstNs to (dstName to null)))?.visitEnd()
}
}

METHOD_MAPPING -> {
val dstCls = context.mapPackage(srcNs, dstNs, InternalName.read(parts[0].second))
val srcName = parts[1].second
val dstDesc = context.mapDescPackages(srcNs, dstNs, MethodDescriptor.read(parts[2].second))
val dstName = parts[3].second
val dstCls = context.mapPackage(srcNs, dstNs, InternalName.read(parts[0]))
val srcName = parts[1]
val dstDesc = context.mapDescPackages(srcNs, dstNs, MethodDescriptor.read(parts[2]))
val dstName = parts[3]
into.visitClass(mapOf(dstNs to dstCls))?.use {
visitMethod(mapOf(srcNs to (srcName to null), dstNs to (dstName to dstDesc)))?.visitEnd()
}
}

else -> {
throw IllegalArgumentException("Invalid line: ${parts.joinToString(" ") { it.second }}")
throw IllegalArgumentException("Invalid line: ${parts.joinToString(" ") { it }}")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package xyz.wagyourtail.unimined.mapping.formats.feather

import okio.BufferedSource
import xyz.wagyourtail.commonskt.reader.CharReader
import xyz.wagyourtail.unimined.mapping.EnvType
import xyz.wagyourtail.unimined.mapping.Namespace
import xyz.wagyourtail.unimined.mapping.formats.FormatReader
import xyz.wagyourtail.unimined.mapping.jvms.four.three.three.MethodDescriptor
import xyz.wagyourtail.unimined.mapping.jvms.four.two.one.InternalName
import xyz.wagyourtail.unimined.mapping.tree.AbstractMappingTree
import xyz.wagyourtail.unimined.mapping.util.CharReader
import xyz.wagyourtail.unimined.mapping.visitor.ClassVisitor
import xyz.wagyourtail.unimined.mapping.visitor.ExceptionType
import xyz.wagyourtail.unimined.mapping.visitor.MappingVisitor
Expand All @@ -20,7 +20,7 @@ object ExceptionReader : FormatReader {
}

override suspend fun read(
input: CharReader,
input: CharReader<*>,
context: AbstractMappingTree?,
into: MappingVisitor,
envType: EnvType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package xyz.wagyourtail.unimined.mapping.formats.feather

import okio.BufferedSource
import xyz.wagyourtail.commonskt.reader.CharReader
import xyz.wagyourtail.unimined.mapping.EnvType
import xyz.wagyourtail.unimined.mapping.Namespace
import xyz.wagyourtail.unimined.mapping.formats.FormatReader
Expand All @@ -16,7 +17,6 @@ import xyz.wagyourtail.unimined.mapping.jvms.four.two.one.InternalName
import xyz.wagyourtail.unimined.mapping.jvms.four.two.two.UnqualifiedName
import xyz.wagyourtail.unimined.mapping.tree.AbstractMappingTree
import xyz.wagyourtail.unimined.mapping.tree.node._class.InnerClassNode
import xyz.wagyourtail.unimined.mapping.util.CharReader
import xyz.wagyourtail.unimined.mapping.visitor.AccessType
import xyz.wagyourtail.unimined.mapping.visitor.MappingVisitor
import xyz.wagyourtail.unimined.mapping.visitor.use
Expand All @@ -32,7 +32,7 @@ object NestReader : FormatReader {
}

override suspend fun read(
input: CharReader,
input: CharReader<*>,
context: AbstractMappingTree?,
into: MappingVisitor,
envType: EnvType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package xyz.wagyourtail.unimined.mapping.formats.feather

import okio.BufferedSource
import xyz.wagyourtail.commonskt.reader.CharReader
import xyz.wagyourtail.commonskt.utils.translateEscapes
import xyz.wagyourtail.unimined.mapping.EnvType
import xyz.wagyourtail.unimined.mapping.Namespace
import xyz.wagyourtail.unimined.mapping.formats.FormatReader
import xyz.wagyourtail.unimined.mapping.jvms.four.three.three.MethodDescriptor
import xyz.wagyourtail.unimined.mapping.jvms.four.two.one.InternalName
import xyz.wagyourtail.unimined.mapping.tree.AbstractMappingTree
import xyz.wagyourtail.unimined.mapping.util.CharReader
import xyz.wagyourtail.unimined.mapping.util.translateEscapes
import xyz.wagyourtail.unimined.mapping.visitor.ClassVisitor
import xyz.wagyourtail.unimined.mapping.visitor.MappingVisitor
import xyz.wagyourtail.unimined.mapping.visitor.use
Expand All @@ -20,7 +20,7 @@ object SignatureReader : FormatReader {
}

override suspend fun read(
input: CharReader,
input: CharReader<*>,
context: AbstractMappingTree?,
into: MappingVisitor,
envType: EnvType,
Expand Down
Loading

0 comments on commit 320bf93

Please sign in to comment.