Skip to content

Commit 8205015

Browse files
committed
optional sorting, fix constants
1 parent 4100479 commit 8205015

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+194
-132
lines changed

.idea/artifacts/unimined_mapping_library_js_1_0_1.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/artifacts/unimined_mapping_library_jvm_1_0_1.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/kotlinc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

kotlin-js-store/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
"@jridgewell/resolve-uri" "^3.1.0"
4848
"@jridgewell/sourcemap-codec" "^1.4.14"
4949

50+
"@js-joda/core@3.2.0":
51+
version "3.2.0"
52+
resolved "https://registry.yarnpkg.com/@js-joda/core/-/core-3.2.0.tgz#3e61e21b7b2b8a6be746df1335cf91d70db2a273"
53+
integrity sha512-PMqgJ0sw5B7FKb2d5bWYIoxjri+QlW/Pys7+Rw82jSH0QN3rB05jZ/VrrsUdh1w4+i2kw9JOejXGq/KhDOX7Kg==
54+
5055
"@leichtgewicht/ip-codec@^2.0.1":
5156
version "2.0.4"
5257
resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz#b2ac626d6cb9c8718ab459166d4bb405b8ffa78b"

src/commonMain/kotlin/xyz/wagyourtail/unimined/mapping/jvms/ext/constant/Constant.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,18 @@ value class Constant private constructor(val value: String) : Type {
6060

6161
fun getString() = if (isString()) StringConstant.unchecked(value) else null
6262

63-
fun getBoolean() = value.first() == 't'
63+
fun getBoolean() = if (isBoolean()) BooleanConstant.unchecked(value) else null
6464

6565
fun getNumber() = if (isNumber()) NumberConstant.unchecked(value) else null
6666

67+
fun getValue(): Any? = when {
68+
isNull() -> null
69+
isString() -> getString()!!.unescape()
70+
isBoolean() -> getBoolean()!!.value
71+
isNumber() -> getNumber()!!.asNumber()
72+
else -> throw IllegalStateException()
73+
}
74+
6775
override fun accept(visitor: (Any) -> Boolean) {
6876
if (visitor(this)) {
6977
when {

src/commonMain/kotlin/xyz/wagyourtail/unimined/mapping/jvms/ext/constant/NumberConstant.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ value class NumberConstant private constructor(val value: String) : Type {
3030

3131
override fun shouldRead(reader: CharReader<*>): Boolean {
3232
val first = reader.take()
33-
return first == '-' || first?.isDigit() == true || first == 'N' || first == 'I'
33+
return first == '-' || first?.isDigit() == true || first == 'N' || first == 'I' || first == '.'
3434
}
3535

3636
override fun read(reader: CharReader<*>, append: (Any) -> Unit) {

src/commonMain/kotlin/xyz/wagyourtail/unimined/mapping/jvms/ext/constant/number/BinaryConstant.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ value class BinaryConstant private constructor(val value: String): Type {
2020

2121
override fun read(reader: CharReader<*>, append: (Any) -> Unit) {
2222
val first = reader.peek()
23-
if (first?.isDigit() != true) {
23+
if (first !in '0' .. '1') {
2424
throw IllegalArgumentException("Invalid binary constant, cannot start with ${first ?: "null"}")
2525
}
2626
append(reader.takeWhile { it in '0' .. '1' })

src/commonMain/kotlin/xyz/wagyourtail/unimined/mapping/jvms/ext/constant/number/HexConstant.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ value class HexConstant private constructor(val value: String): Type {
2020

2121
override fun read(reader: CharReader<*>, append: (Any) -> Unit) {
2222
val first = reader.peek()
23-
if (first?.isDigit() != true) {
23+
if (first?.isDigit() == true || first?.lowercaseChar() in 'a'..'f') {
24+
append(reader.takeWhile { it.isDigit() || it.lowercaseChar() in 'a'..'f' })
25+
} else {
2426
throw IllegalArgumentException("Invalid hex constant, cannot start with ${first ?: "null"}")
2527
}
26-
append(reader.takeWhile { it.isDigit() || it.lowercaseChar() in 'a'..'f' })
2728
}
2829

2930
override fun unchecked(value: String): HexConstant {

src/commonMain/kotlin/xyz/wagyourtail/unimined/mapping/jvms/ext/constant/number/OctalConstant.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ value class OctalConstant private constructor(val value: String): Type {
2020

2121
override fun read(reader: CharReader<*>, append: (Any) -> Unit) {
2222
val first = reader.peek()
23-
if (first?.isDigit() != true) {
23+
if (first !in '0' .. '7') {
2424
throw IllegalArgumentException("Invalid octal constant, cannot start with ${first ?: "null"}")
2525
}
2626
append(reader.takeWhile { it.isDigit() && it != '8' && it != '9' })

0 commit comments

Comments
 (0)