Skip to content

Commit

Permalink
comments in tinyv1, translateEscapes in sigs
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Aug 21, 2024
1 parent 97cc37a commit ae7f437
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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 Down Expand Up @@ -39,20 +40,20 @@ object SignatureReader : FormatReader {
}
val whitespace = input.takeWhitespace()
if (whitespace.isEmpty()) {
val name = InternalName.read(input.takeNextLiteral()!!)
val name = InternalName.read(input.takeNextLiteral()!!.translateEscapes())
cls?.visitEnd()
cls = visitClass(mapOf(ns to name))
val sig = input.takeNextLiteral()
if (sig != null) {
cls?.visitSignature(sig, ns, emptySet())
cls?.visitSignature(sig.translateEscapes(), ns, emptySet())
}
} else {
if (whitespace.length != 1) {
throw IllegalArgumentException("invalid line: $whitespace")
}
val mName = input.takeNextLiteral()!!
val desc = MethodDescriptor.read(input.takeNextLiteral()!!)
val sig = input.takeNextLiteral()!!
val mName = input.takeNextLiteral()!!.translateEscapes()
val desc = MethodDescriptor.read(input.takeNextLiteral()!!.translateEscapes())
val sig = input.takeNextLiteral()!!.translateEscapes()
cls?.visitMethod(mapOf(ns to (mName to desc)))?.use {
visitSignature(sig, ns, emptySet())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ object TinyV1Reader : FormatReader {
continue
}
val col = input.takeNextLiteral() ?: continue
if (col.startsWith("#")) {
input.takeLine()
continue
}
when (col) {
"CLASS" -> {
val names = input.takeRemainingOnLine().map { it.second }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import xyz.wagyourtail.unimined.mapping.visitor.*
*/
object TinyV2Reader : FormatReader {

fun String.translateEscapes(leinient: Boolean = false): String {
/**
* translate escapes function that only does the ones actually allowed by tinyv2
*/
private fun String.translateEscapes(leinient: Boolean = false): String {
if (this.isEmpty() || !this.contains("\\")) {
return this
}
Expand Down

0 comments on commit ae7f437

Please sign in to comment.