-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2bd8c8
commit a3bc3eb
Showing
5 changed files
with
138 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/commonMain/kotlin/xyz/wagyourtail/unimined/mapping/formats/feather/ExceptionReader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package xyz.wagyourtail.unimined.mapping.formats.feather | ||
|
||
import okio.BufferedSource | ||
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 | ||
import xyz.wagyourtail.unimined.mapping.visitor.use | ||
|
||
object ExceptionReader : FormatReader { | ||
|
||
override fun isFormat(envType: EnvType, fileName: String, inputType: BufferedSource): Boolean { | ||
return fileName.endsWith(".excs") | ||
} | ||
|
||
override suspend fun read( | ||
envType: EnvType, | ||
input: CharReader, | ||
context: AbstractMappingTree?, | ||
into: MappingVisitor, | ||
nsMapping: Map<String, String> | ||
) { | ||
val ns = Namespace(nsMapping["source"] ?: "source") | ||
|
||
into.use { | ||
visitHeader(ns.name) | ||
|
||
var cls: ClassVisitor? = null | ||
|
||
while (!input.exhausted()) { | ||
if (input.peek() == '\n') { | ||
input.take() | ||
continue | ||
} | ||
val whitespace = input.takeWhitespace() | ||
if (whitespace.isEmpty()) { | ||
val name = InternalName.read(input.takeNextLiteral()!!) | ||
cls?.visitEnd() | ||
cls = visitClass(mapOf(ns to name)) | ||
} else { | ||
if (whitespace.length != 1) { | ||
throw IllegalArgumentException("invalid line: $whitespace") | ||
} | ||
val mName = input.takeNextLiteral()!! | ||
val desc = MethodDescriptor.read(input.takeNextLiteral()!!) | ||
val exceptions = mutableListOf<String>() | ||
while (true) { | ||
exceptions.add(input.takeNextLiteral() ?: break) | ||
} | ||
cls?.visitMethod(mapOf(ns to (mName to desc)))?.use { | ||
for (exc in exceptions) { | ||
visitException(ExceptionType.ADD, InternalName.read(exc), ns, setOf())?.visitEnd() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...mined/mapping/formats/nests/NestReader.kt → ...ned/mapping/formats/feather/NestReader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/commonMain/kotlin/xyz/wagyourtail/unimined/mapping/formats/feather/SignatureReader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package xyz.wagyourtail.unimined.mapping.formats.feather | ||
|
||
import okio.BufferedSource | ||
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.MappingVisitor | ||
import xyz.wagyourtail.unimined.mapping.visitor.use | ||
|
||
object SignatureReader : FormatReader { | ||
|
||
override fun isFormat(envType: EnvType, fileName: String, inputType: BufferedSource): Boolean { | ||
return fileName.endsWith(".sigs") | ||
} | ||
|
||
override suspend fun read( | ||
envType: EnvType, | ||
input: CharReader, | ||
context: AbstractMappingTree?, | ||
into: MappingVisitor, | ||
nsMapping: Map<String, String> | ||
) { | ||
val ns = Namespace(nsMapping["source"] ?: "source") | ||
|
||
into.use { | ||
visitHeader(ns.name) | ||
|
||
var cls: ClassVisitor? = null | ||
|
||
while (!input.exhausted()) { | ||
if (input.peek() == '\n') { | ||
input.take() | ||
continue | ||
} | ||
val whitespace = input.takeWhitespace() | ||
if (whitespace.isEmpty()) { | ||
val name = InternalName.read(input.takeNextLiteral()!!) | ||
cls?.visitEnd() | ||
cls = visitClass(mapOf(ns to name)) | ||
val sig = input.takeNextLiteral() | ||
if (sig != null) { | ||
cls?.visitSignature(mapOf(ns to sig)) | ||
} | ||
} else { | ||
if (whitespace.length != 1) { | ||
throw IllegalArgumentException("invalid line: $whitespace") | ||
} | ||
val mName = input.takeNextLiteral()!! | ||
val desc = MethodDescriptor.read(input.takeNextLiteral()!!) | ||
val sig = input.takeNextLiteral()!! | ||
cls?.visitMethod(mapOf(ns to (mName to desc)))?.use { | ||
visitSignature(mapOf(ns to sig)) | ||
} | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters