Open-source multiplayer game server compatible with the RuneScape client https://www.openrs2.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
openrs2/deob/src/main/java/dev/openrs2/deob/analysis/IntValueSet.kt

42 lines
1.0 KiB

package dev.openrs2.deob.analysis
sealed class IntValueSet {
data class Constant(val values: Set<Int>) : IntValueSet() {
init {
require(values.isNotEmpty())
}
override val singleton: Int?
get() = if (values.size == 1) {
values.first()
} else {
null
}
override fun union(other: IntValueSet): IntValueSet {
return if (other is Constant) {
Constant(values union other.values)
} else {
Unknown
}
}
}
object Unknown : IntValueSet() {
override val singleton: Int?
get() = null
override fun union(other: IntValueSet): IntValueSet {
return Unknown
}
}
abstract val singleton: Int?
abstract infix fun union(other: IntValueSet): IntValueSet
companion object {
fun singleton(value: Int): IntValueSet {
return Constant(setOf(value))
}
}
}