Skip to content

Commit

Permalink
tab and space in aw
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Jun 10, 2024
1 parent d366ef5 commit 5edcc93
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ object AWReader : FormatReader {
into: MappingVisitor,
nsMapping: Map<String, String>
) {
val aw = input.takeNextLiteral()
val version = input.takeNextLiteral()
val namespace = input.takeNextLiteral()!!
val aw = input.takeNextLiteral { it.isWhitespace() }
val version = input.takeNextLiteral { it.isWhitespace() }
val namespace = input.takeNextLiteral { it.isWhitespace() }!!

if (aw != "accessWidener") {
throw IllegalArgumentException("Invalid access widener file")
Expand All @@ -60,8 +60,8 @@ object AWReader : FormatReader {
continue
}

val target = input.takeNextLiteral()!!
val access = input.takeNextLiteral()!!
val target = input.takeNextLiteral { it.isWhitespace() }!!
val access = input.takeNextLiteral { it.isWhitespace() }!!

if (!access.startsWith("transitive-")) {
if (!allowNonTransitive) {
Expand Down Expand Up @@ -105,7 +105,7 @@ object AWReader : FormatReader {

when (target) {
"class" -> {
val cls = InternalName.read(input.takeNextLiteral()!!)
val cls = InternalName.read(input.takeNextLiteral { it.isWhitespace() }!!)
val visitor = into.visitClass(mapOf(ns to cls))
for ((flag, conditions) in addAccess) {
visitor?.visitAccess(AccessType.ADD, flag, conditions, setOf(ns))
Expand All @@ -115,9 +115,9 @@ object AWReader : FormatReader {
}
}
"method" -> {
val cls = InternalName.read(input.takeNextLiteral()!!)
val method = input.takeNextLiteral()!!
val desc = MethodDescriptor.read(input.takeNextLiteral()!!)
val cls = InternalName.read(input.takeNextLiteral { it.isWhitespace() }!!)
val method = input.takeNextLiteral { it.isWhitespace() }!!
val desc = MethodDescriptor.read(input.takeNextLiteral { it.isWhitespace() }!!)
val visitor = into.visitClass(mapOf(ns to cls))?.visitMethod(mapOf(ns to (method to desc)))
for ((flag, conditions) in addAccess) {
visitor?.visitAccess(AccessType.ADD, flag, conditions, setOf(ns))
Expand All @@ -127,9 +127,9 @@ object AWReader : FormatReader {
}
}
"field" -> {
val cls = InternalName.read(input.takeNextLiteral()!!)
val field = input.takeNextLiteral()!!
val desc = FieldDescriptor.read(input.takeNextLiteral()!!)
val cls = InternalName.read(input.takeNextLiteral { it.isWhitespace() }!!)
val field = input.takeNextLiteral { it.isWhitespace() }!!
val desc = FieldDescriptor.read(input.takeNextLiteral { it.isWhitespace() }!!)
val visitor = into.visitClass(mapOf(ns to cls))?.visitField(mapOf(ns to (field to desc)))
for ((flag, conditions) in addAccess) {
visitor?.visitAccess(AccessType.ADD, flag, conditions, setOf(ns))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@ class CharReader(buf: String, var pos: Int = 0) {
}
}

fun takeNextLiteral(sep: (Char) -> Boolean): String? {
if (exhausted()) return null
if (peek() == '\n') {
return null
}
return buildString {
while (!exhausted()) {
val b = peek()
if (b == '\n') break
val c = take()
if (sep(c!!)) break
append(c)
}
}
}

fun takeNonNewlineWhitespace(): String {
return takeUntil { !it.isWhitespace() || it == '\n' }
}
Expand Down

0 comments on commit 5edcc93

Please sign in to comment.