Parser

private inner class Parser

Reads one mappings FILE into the enclosing table. Its own class because format knowledge — tiny v2's column math, TSRG2's indentation rules — is not what the lookup API below is about, and the two change for different reasons. inner, so the accumulating tables need no plumbing.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
private fun locateNamespaces(header: String): Pair<Int, Int>?

The 'named' and 'intermediary' column indices of a tiny v2 header ("tiny \t 2 \t 0 \t \t \t ..." — namespace names start at column 3, and the returned indices are relative to that). Null when either namespace is absent.

Link copied to clipboard
private fun parseTinyV2(header: String, r: BufferedReader)

tiny v2 -> named->intermediary. The namespace ORDER is read from the header, not assumed: loom emits official intermediary named but the auto-assembled bundle emits named intermediary official. Locating the 'named'/'intermediary' columns by name makes both parse correctly. The header line is already consumed.

Link copied to clipboard
private fun parseTsrg2(r: BufferedReader)

forge TSRG2 ("tsrg2 left right": col0=left=SRG runtime, col1=right=named; space-separated columns, tab-indented members) -> named->srg. Which member rows survive is recordTsrg2Member's call.

Link copied to clipboard
private fun pruneExact()

Settle the exact-reverse index. Run by read once the file is exhausted — the earliest point where ambiguous and classN2I are both final, which is what both edits below need. One linear pass over rows we just parsed, cheaper than the parse itself, and both sit behind a download on a background thread.

Link copied to clipboard
fun read(header: String, isTsrg: Boolean, r: BufferedReader)

Parse r to exhaustion, then settle the tables. The header line is already consumed.

Link copied to clipboard
private fun recordClass(named: String, runtime: String): String?

Record one class row. Returns the named owner the member rows following it belong to — null for a nameless class, which MUST clear the owner or those members would attach to the PREVIOUS class.

Link copied to clipboard
private fun recordField(owner: String, named: String, runtime: String)

Record one field row under owner. Forward only: the reverse tables exist to demap stack traces, and a frame names a method, never a field.

Link copied to clipboard
private fun recordMethod(owner: String, named: String, runtime: String, desc: String)

Record one method row under owner. Overloads share a mojmap name but carry DISTINCT runtime names, so the forward direction accumulates into a list. The reverse direction is single-valued and so COLLIDES on an obf runtime: a second, differing row poisons the entry into ambiguous instead of overwriting it.

Link copied to clipboard
private fun recordTinyMember(owner: String, line: String, namedNs: Int, interNs: Int, maxNs: Int)

One tiny v2 member row under owner: \t<m|f>\t<desc>\t<ns0>\t<ns1>.... Both kinds carry that one shape, so the tag char is the whole discriminator, and a field's type column goes unread — the field table keys on name alone. Split out for the reason recordTsrg2Member is, on the other parser.

Link copied to clipboard
private fun recordTsrg2Member(owner: String, line: String)

One TSRG2 member line belonging to owner — the leading tab is already established by the caller. The column count discriminates: 3 is a method, whose middle column is the descriptor, and 2 is a field. Skipped: depth >= 2, a param row or the static marker. Since we are past the first tab, testing line[1] IS the depth test.