Add blank line between is blocks

Seems to be a recent change in the IDEA formatter.

Signed-off-by: Graham <gpe@openrs2.org>
master
Graham 2 years ago
parent c0056f9cb1
commit 4ca7fab636
  1. 2
      archive/src/main/kotlin/org/openrs2/archive/cache/CacheDownloader.kt
  2. 1
      archive/src/main/kotlin/org/openrs2/archive/cache/nxt/Js5RequestEncoder.kt
  3. 2
      archive/src/main/kotlin/org/openrs2/archive/jav/JavConfig.kt
  4. 2
      archive/src/main/kotlin/org/openrs2/archive/key/JsonKeyReader.kt
  5. 2
      asm/src/main/kotlin/org/openrs2/asm/ClassNodeRemapper.kt
  6. 2
      asm/src/main/kotlin/org/openrs2/asm/InsnNodeUtils.kt
  7. 2
      asm/src/main/kotlin/org/openrs2/asm/MethodNodeUtils.kt
  8. 3
      asm/src/main/kotlin/org/openrs2/asm/StackMetadata.kt
  9. 1
      asm/src/main/kotlin/org/openrs2/asm/filter/Glob.kt
  10. 2
      asm/src/main/kotlin/org/openrs2/asm/packclass/ConstantPool.kt
  11. 22
      asm/src/main/kotlin/org/openrs2/asm/packclass/PackClass.kt
  12. 1
      buffer-generator/src/main/kotlin/org/openrs2/buffer/generator/ByteOrder.kt
  13. 2
      cache-550/src/main/kotlin/org/openrs2/cache/config/enum/EnumType.kt
  14. 3
      cache-550/src/main/kotlin/org/openrs2/cache/config/struct/StructType.kt
  15. 1
      cache-550/src/main/kotlin/org/openrs2/cache/config/varbit/VarbitType.kt
  16. 19
      cache-550/src/main/kotlin/org/openrs2/cache/midi/Song.kt
  17. 2
      cache/src/main/kotlin/org/openrs2/cache/Js5Compression.kt
  18. 2
      cache/src/main/kotlin/org/openrs2/cache/Js5MasterIndex.kt
  19. 1
      cache/src/main/kotlin/org/openrs2/cache/MutableNamedEntryCollection.kt
  20. 1
      compress/src/main/kotlin/org/openrs2/compress/gzip/GzipLaxInputStream.kt
  21. 6
      deob-ast/src/main/kotlin/org/openrs2/deob/ast/transform/AddSubTransformer.kt
  22. 4
      deob-ast/src/main/kotlin/org/openrs2/deob/ast/transform/BitMaskTransformer.kt
  23. 7
      deob-ast/src/main/kotlin/org/openrs2/deob/ast/transform/EncloseTransformer.kt
  24. 1
      deob-ast/src/main/kotlin/org/openrs2/deob/ast/transform/ForLoopConditionTransformer.kt
  25. 2
      deob-ast/src/main/kotlin/org/openrs2/deob/ast/transform/GlTransformer.kt
  26. 4
      deob-ast/src/main/kotlin/org/openrs2/deob/ast/transform/IdentityTransformer.kt
  27. 2
      deob-ast/src/main/kotlin/org/openrs2/deob/ast/transform/IfElseTransformer.kt
  28. 13
      deob-ast/src/main/kotlin/org/openrs2/deob/ast/util/ExprUtils.kt
  29. 1
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/analysis/CopyPropagationAnalyzer.kt
  30. 2
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/analysis/IntInterpreter.kt
  31. 1
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/analysis/LiveVariableAnalyzer.kt
  32. 2
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/remap/FieldMappingGenerator.kt
  33. 1
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/ConstantArgTransformer.kt
  34. 1
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/EmptyClassTransformer.kt
  35. 2
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/OpaquePredicateTransformer.kt
  36. 1
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/UnusedArgTransformer.kt
  37. 1
      deob-processor/src/main/kotlin/org/openrs2/deob/processor/NameMapProcessor.kt
  38. 3
      http/src/main/kotlin/org/openrs2/http/NetrcReader.kt
  39. 2
      patcher/src/main/kotlin/org/openrs2/patcher/transform/CachePathTransformer.kt
  40. 2
      patcher/src/main/kotlin/org/openrs2/patcher/transform/HighDpiTransformer.kt
  41. 1
      patcher/src/main/kotlin/org/openrs2/patcher/transform/PublicKeyTransformer.kt
  42. 3
      protocol/src/main/kotlin/org/openrs2/protocol/js5/upstream/Js5RequestEncoder.kt
  43. 3
      protocol/src/main/kotlin/org/openrs2/protocol/login/upstream/LoginRequest.kt
  44. 1
      util/src/main/kotlin/org/openrs2/util/charset/ModifiedUtf8Charset.kt
  45. 2
      util/src/main/kotlin/org/openrs2/util/collect/ForestDisjointSet.kt

@ -54,6 +54,7 @@ public class CacheDownloader @Inject constructor(
)
)
}
"runescape" -> {
val buildMinor = game.buildMinor ?: throw Exception("Current minor build not set")
@ -82,6 +83,7 @@ public class CacheDownloader @Inject constructor(
)
)
}
else -> throw UnsupportedOperationException()
}

@ -16,6 +16,7 @@ public object Js5RequestEncoder : MessageToByteEncoder<Js5Request>(Js5Request::c
out.writeShort(msg.build)
out.writeShort(0)
}
is Js5Request.Connected -> {
out.writeByte(6)
out.writeMedium(5)

@ -47,12 +47,14 @@ public data class JavConfig(
messages[parts[0]] = parts[1]
}
}
line.startsWith("param=") -> {
val parts = line.substring("param=".length).split("=", limit = 2)
if (parts.size == 2) {
params[parts[0]] = parts[1]
}
}
else -> {
val parts = line.split("=", limit = 2)
if (parts.size == 2) {

@ -24,11 +24,13 @@ public class JsonKeyReader @Inject constructor(
keys += mapper.treeToValue<XteaKey?>(key) ?: throw IOException("Key must be non-null")
}
}
root.isObject -> {
for (entry in root.fields()) {
keys += mapper.treeToValue<XteaKey?>(entry.value) ?: throw IOException("Key must be non-null")
}
}
else -> throw IOException("Root element must be an array or object")
}

@ -109,12 +109,14 @@ public fun AbstractInsnNode.remap(remapper: ExtendedRemapper) {
name = remapper.mapFieldName(originalOwner, name, desc)
desc = remapper.mapDesc(desc)
}
is MethodInsnNode -> {
val originalOwner = owner
owner = remapper.mapMethodOwner(originalOwner, name, desc)
name = remapper.mapMethodName(originalOwner, name, desc)
desc = remapper.mapDesc(desc)
}
is InvokeDynamicInsnNode -> throw UnsupportedOperationException()
is TypeInsnNode -> desc = remapper.mapType(desc)
is LdcInsnNode -> cst = remapper.mapValue(cst)

@ -245,6 +245,7 @@ public val AbstractInsnNode.intConstant: Int?
null
}
}
is LdcInsnNode -> {
val cst = cst
if (cst is Int) {
@ -253,6 +254,7 @@ public val AbstractInsnNode.intConstant: Int?
null
}
}
else -> when (opcode) {
Opcodes.ICONST_M1 -> -1
Opcodes.ICONST_0 -> 0

@ -99,6 +99,7 @@ public fun MethodNode.removeArgument(argIndex: Int) {
newLocalIndexUsed = true
}
}
is IincInsnNode -> {
insn.`var` = remap(insn.`var`, argType, localIndex, newLocalIndex)
@ -106,6 +107,7 @@ public fun MethodNode.removeArgument(argIndex: Int) {
newLocalIndexUsed = true
}
}
is FrameNode -> throw UnsupportedOperationException("SKIP_FRAMES and COMPUTE_FRAMES must be used")
}
}

@ -188,6 +188,7 @@ public val AbstractInsnNode.stackMetadata: StackMetadata
} else {
PUSH1
}
is FieldInsnNode -> {
val fieldSize = Type.getType(desc).size
var pushes = 0
@ -202,6 +203,7 @@ public val AbstractInsnNode.stackMetadata: StackMetadata
}
StackMetadata(pops, pushes)
}
is MethodInsnNode -> {
val argumentsAndReturnSizes = Type.getArgumentsAndReturnSizes(desc)
val pushes = argumentsAndReturnSizes and 0x3
@ -211,6 +213,7 @@ public val AbstractInsnNode.stackMetadata: StackMetadata
}
StackMetadata(pops, pushes)
}
is InvokeDynamicInsnNode -> throw UnsupportedOperationException()
is MultiANewArrayInsnNode -> StackMetadata(dims, 1)
else -> SIMPLE_OPCODES[opcode] ?: throw IllegalArgumentException()

@ -35,6 +35,7 @@ public object Glob {
} else {
regex.append(".*")
}
else -> regex.append(Regex.escape(ch.toString()))
}
}

@ -94,6 +94,7 @@ public class ConstantPool private constructor(
addMethodRef(methodRef)
}
}
is FieldInsnNode -> addFieldRef(MemberRef(insn.owner, insn.name, insn.desc))
is TypeInsnNode -> strings += insn.desc
}
@ -155,6 +156,7 @@ public class ConstantPool private constructor(
throw IllegalArgumentException("Unsupported constant type: ${value.sort}")
}
}
else -> throw IllegalArgumentException("Unsupported constant type: ${value.javaClass.name}")
}
}

@ -503,11 +503,13 @@ public object PackClass {
branchLen += (cases + 2) * 4
sipushAndSwitchLen += 4
}
Opcodes.LOOKUPSWITCH -> {
val cases = buf.readVarInt()
branchLen += (cases + 1) * 4
sipushAndSwitchLen += cases * 4
}
Opcodes.INVOKEINTERFACE -> interfaceMethodRefLen += 2
Opcodes.NEWARRAY -> newArrayLen++
Opcodes.MULTIANEWARRAY -> multiNewArrayLen++
@ -1155,10 +1157,12 @@ public object PackClass {
)
}
}
insn.`var` < 256 -> {
buf.writeByte(insn.opcode)
localVarBuf.writeByte(insn.`var`)
}
else -> {
buf.writeByte(WIDE)
buf.writeByte(insn.opcode)
@ -1166,28 +1170,34 @@ public object PackClass {
}
}
}
is LdcInsnNode -> {
when (val value = insn.cst) {
is Int -> {
buf.writeByte(LDC_INT)
constantPool.writeInt(constantBuf, value)
}
is Long -> {
buf.writeByte(LDC_LONG)
constantPool.writeLong(wideConstantBuf, value)
}
is Float -> {
buf.writeByte(LDC_FLOAT)
constantPool.writeFloat(constantBuf, value)
}
is Double -> {
buf.writeByte(LDC_DOUBLE)
constantPool.writeDouble(wideConstantBuf, value)
}
is String -> {
buf.writeByte(LDC_STRING)
constantPool.writeString(constantBuf, value)
}
is Type -> {
if (value.sort == Type.OBJECT) {
buf.writeByte(LDC_CLASS)
@ -1198,19 +1208,23 @@ public object PackClass {
)
}
}
else -> throw IllegalArgumentException(
"Unsupported constant type: ${value.javaClass.name}"
)
}
}
is TypeInsnNode -> {
buf.writeByte(insn.opcode)
constantPool.writeString(classBuf, insn.desc)
}
is FieldInsnNode -> {
buf.writeByte(insn.opcode)
constantPool.writeFieldRef(fieldRefBuf, MemberRef(insn.owner, insn.name, insn.desc))
}
is MethodInsnNode -> {
buf.writeByte(insn.opcode)
@ -1221,6 +1235,7 @@ public object PackClass {
constantPool.writeMethodRef(methodRefBuf, methodRef)
}
}
is JumpInsnNode -> {
val targetPc = insns[i].indexOf(insn.label.nextReal)
val delta = targetPc - pc
@ -1239,6 +1254,7 @@ public object PackClass {
branchBuf.writeInt(delta)
}
}
is IntInsnNode -> {
buf.writeByte(insn.opcode)
@ -1249,6 +1265,7 @@ public object PackClass {
else -> throw IllegalArgumentException("Unsupported IntInsnNode opcode: ${insn.opcode}")
}
}
is IincInsnNode -> {
if (insn.`var` < 256 && (insn.incr >= -128 && insn.incr <= 127)) {
buf.writeByte(insn.opcode)
@ -1261,6 +1278,7 @@ public object PackClass {
wideIincBuf.writeShort(insn.incr)
}
}
is TableSwitchInsnNode -> {
buf.writeByte(insn.opcode)
@ -1275,6 +1293,7 @@ public object PackClass {
branchBuf.writeInt(targetPc - pc)
}
}
is LookupSwitchInsnNode -> {
buf.writeByte(insn.opcode)
@ -1295,11 +1314,13 @@ public object PackClass {
branchBuf.writeInt(targetPc - pc)
}
}
is MultiANewArrayInsnNode -> {
buf.writeByte(insn.opcode)
constantPool.writeString(classBuf, insn.desc)
multiNewArrayBuf.writeByte(insn.dims)
}
is InsnNode -> buf.writeByte(insn.opcode)
else -> throw IllegalArgumentException("Unsupported instruction type: ${insn.javaClass.name}")
}
@ -1552,6 +1573,7 @@ public object PackClass {
throw IllegalArgumentException("Unsupported constant type: ${value.sort}")
}
}
else -> throw IllegalArgumentException("Unsupported constant type: ${value.javaClass.name}")
}
}

@ -19,6 +19,7 @@ public enum class ByteOrder(public val suffix: String) {
else -> 8
}
}
ALT3_REVERSE -> {
require(width == 4)
when (i) {

@ -37,6 +37,7 @@ public class EnumType(id: Int) : ConfigType(id) {
this.strings = strings
}
6 -> {
val size = buf.readUnsignedShort()
val ints = Int2IntOpenHashMap()
@ -48,6 +49,7 @@ public class EnumType(id: Int) : ConfigType(id) {
this.ints = ints
}
else -> throw IllegalArgumentException("Unsupported config code: $code")
}
}

@ -26,6 +26,7 @@ public class StructType(id: Int) : ConfigType(id) {
}
}
}
else -> throw IllegalArgumentException("Unsupported config code: $code")
}
}
@ -42,11 +43,13 @@ public class StructType(id: Int) : ConfigType(id) {
buf.writeMedium(id)
buf.writeString(value)
}
is Int -> {
buf.writeBoolean(false)
buf.writeMedium(id)
buf.writeInt(value)
}
else -> throw IllegalStateException()
}
}

@ -15,6 +15,7 @@ public class VarbitType(id: Int) : ConfigType(id) {
startBit = buf.readUnsignedByte().toInt()
endBit = buf.readUnsignedByte().toInt()
}
else -> throw IllegalArgumentException("Unsupported config code: $code")
}
}

@ -196,11 +196,13 @@ public object Song {
onVelocity = (onVelocity + onVelocityBuf.readUnsignedByte().toInt()) and 0x7F
ShortMessage(ShortMessage.NOTE_ON, channel, key, onVelocity)
}
NOTE_OFF -> {
key = (key + keyBuf.readUnsignedByte().toInt()) and 0x7F
offVelocity = (offVelocity + offVelocityBuf.readUnsignedByte().toInt()) and 0x7F
ShortMessage(ShortMessage.NOTE_OFF, channel, key, offVelocity)
}
CONTROL_CHANGE -> {
controller = (controller + controllerBuf.readUnsignedByte()) and 0x7F
@ -218,6 +220,7 @@ public object Song {
REGISTERED_LSB -> registeredLsbBuf.readUnsignedByte().toInt()
DAMPER, PORTAMENTO, ALL_SOUND_OFF, RESET_CONTROLLERS, ALL_NOTES_OFF ->
otherKnownControllerBuf.readUnsignedByte().toInt()
else -> unknownControllerBuf.readUnsignedByte().toInt()
}
@ -225,25 +228,30 @@ public object Song {
values[controller] = value
ShortMessage(ShortMessage.CONTROL_CHANGE, channel, controller, value and 0x7F)
}
PITCH_WHEEL_CHANGE -> {
pitchWheel += pitchWheelLsbBuf.readUnsignedByte().toInt()
pitchWheel += (pitchWheelMsbBuf.readUnsignedByte().toInt() shl 7)
pitchWheel = pitchWheel and 0x3FFF
ShortMessage(ShortMessage.PITCH_BEND, channel, pitchWheel and 0x7F, pitchWheel shr 7)
}
CHANNEL_PRESSURE_CHANGE -> {
channelPressure = (channelPressure + channelPressureBuf.readUnsignedByte().toInt()) and 0x7F
ShortMessage(ShortMessage.CHANNEL_PRESSURE, channel, channelPressure, 0)
}
KEY_PRESSURE_CHANGE -> {
key = (key + keyBuf.readUnsignedByte().toInt()) and 0x7F
keyPressure = (keyPressure + keyPressureBuf.readUnsignedByte().toInt()) and 0x7F
ShortMessage(ShortMessage.POLY_PRESSURE, channel, key, keyPressure)
}
PROGRAM_CHANGE -> {
val bankSelect = bankSelectBuf.readUnsignedByte().toInt()
ShortMessage(ShortMessage.PROGRAM_CHANGE, channel, bankSelect, 0)
}
else -> throw IllegalStateException()
}
@ -317,9 +325,11 @@ public object Song {
require(message.data.size == 3)
tempoBuf.writeBytes(message.data)
}
else -> throw IllegalArgumentException("Unsupported meta type: $type")
}
}
is ShortMessage -> {
val command = message.status and 0xF0
val channel = message.status and 0xF
@ -354,11 +364,13 @@ public object Song {
onVelocityBuf.writeByte((onVelocity - prevOnVelocity) and 0x7F)
prevOnVelocity = onVelocity
}
ShortMessage.NOTE_OFF -> {
val offVelocity = message.data2
offVelocityBuf.writeByte((offVelocity - prevOffVelocity) and 0x7F)
prevOffVelocity = offVelocity
}
ShortMessage.CONTROL_CHANGE -> {
val controller = message.data1
controllerBuf.writeByte((controller - prevController) and 0x7F)
@ -381,11 +393,13 @@ public object Song {
REGISTERED_LSB -> registeredLsbBuf.writeByte(valueDelta)
DAMPER, PORTAMENTO, ALL_SOUND_OFF, RESET_CONTROLLERS, ALL_NOTES_OFF ->
otherKnownControllerBuf.writeByte(valueDelta)
else -> unknownControllerBuf.writeByte(valueDelta)
}
prevValues[controller] = value
}
ShortMessage.PITCH_BEND -> {
val pitchWheel = message.data1 or (message.data2 shl 7)
val pitchWheelDelta = (pitchWheel - prevPitchWheel) and 0x3FFF
@ -393,22 +407,27 @@ public object Song {
pitchWheelMsbBuf.writeByte(pitchWheelDelta shr 7)
prevPitchWheel = pitchWheel
}
ShortMessage.CHANNEL_PRESSURE -> {
val channelPressure = message.data1
channelPressureBuf.writeByte((channelPressure - prevChannelPressure) and 0x7F)
prevChannelPressure = channelPressure
}
ShortMessage.POLY_PRESSURE -> {
val keyPressure = message.data2
keyPressureBuf.writeByte((keyPressure - prevKeyPressure) and 0x7F)
prevKeyPressure = keyPressure
}
ShortMessage.PROGRAM_CHANGE -> {
bankSelectBuf.writeByte(message.data1)
}
else -> throw IllegalStateException()
}
}
else -> throw IllegalArgumentException("Unsupported message type: ${message.javaClass.name}")
}
}

@ -255,6 +255,7 @@ public object Js5Compression {
return null
}
}
Js5CompressionType.GZIP -> {
val magic = plaintext.readUnsignedShort()
if (magic != GZIP_MAGIC) {
@ -269,6 +270,7 @@ public object Js5Compression {
return null
}
}
Js5CompressionType.LZMA -> {
val properties = plaintext.readUnsignedByte()

@ -210,12 +210,14 @@ public data class Js5MasterIndex(
}
len / 4
}
MasterIndexFormat.VERSIONED -> {
require(len % 8 == 0) {
"Length is not a multiple of 8 bytes"
}
len / 8
}
else -> {
buf.readUnsignedByte().toInt()
}

@ -251,6 +251,7 @@ public abstract class MutableNamedEntryCollection<T : MutableNamedEntry>(
newSet.add(id)
nameHashTable[newNameHash] = newSet
}
else -> set.add(id)
}

@ -65,6 +65,7 @@ public class GzipLaxInputStream(
checkTrailer()
return -1
}
inflater.needsInput() -> fill()
inflater.needsDictionary() -> throw IOException("Dictionaries not supported")
}

@ -80,18 +80,22 @@ public class AddSubTransformer : Transformer() {
negate -> terms += expr.negate()
else -> terms += expr
}
expr is BinaryExpr -> when {
expr.operator == BinaryExpr.Operator.PLUS -> {
addTerms(terms, expr.left, negate)
addTerms(terms, expr.right, negate)
}
expr.operator == BinaryExpr.Operator.MINUS -> {
addTerms(terms, expr.left, negate)
addTerms(terms, expr.right, !negate)
}
negate -> terms += expr.negate()
else -> terms += expr
}
negate -> terms += expr.negate()
else -> terms += expr
}
@ -105,11 +109,13 @@ public class AddSubTransformer : Transformer() {
is Int -> n < 0
else -> error("Invalid IntegerLiteralExpr type")
}
is LongLiteralExpr -> when (val n = asNumber()) {
LongLiteralExpr.MAX_63_BIT_UNSIGNED_VALUE_AS_BIG_INTEGER -> false
is Long -> n < 0
else -> error("Invalid LongLiteralExpr type")
}
else -> false
}
}

@ -62,6 +62,7 @@ public class BitMaskTransformer : Transformer() {
maskExpr = IntegerLiteralExpr(mask.toString())
}
is LongLiteralExpr -> {
var mask = maskExpr.checkedAsLong()
@ -73,6 +74,7 @@ public class BitMaskTransformer : Transformer() {
maskExpr = mask.toLongLiteralExpr()
}
else -> return@walk
}
@ -124,6 +126,7 @@ public class BitMaskTransformer : Transformer() {
mask = mask ushr shamt
IntegerLiteralExpr(mask.toString())
}
is LongLiteralExpr -> {
var mask = maskExpr.checkedAsLong()
if (shamt > java.lang.Long.numberOfTrailingZeros(mask)) {
@ -133,6 +136,7 @@ public class BitMaskTransformer : Transformer() {
mask = mask ushr shamt
mask.toLongLiteralExpr()
}
else -> return@walk
}

@ -76,6 +76,7 @@ public class EncloseTransformer : Transformer() {
BinaryExpr.Operator.OR -> LOGICAL_OR
else -> null
}
is InstanceOfExpr -> RELATIONAL
is ConditionalExpr -> TERNARY
is AssignExpr -> ASSIGNMENT
@ -95,6 +96,7 @@ public class EncloseTransformer : Transformer() {
encloseLeft(expr, scope)
}
}
is UnaryExpr -> encloseRight(expr, expr.expression)
is CastExpr -> encloseRight(expr, expr.expression)
is ObjectCreationExpr -> {
@ -102,16 +104,19 @@ public class EncloseTransformer : Transformer() {
encloseLeft(expr, scope)
}
}
is BinaryExpr -> {
encloseLeft(expr, expr.left)
encloseRight(expr, expr.right)
}
is InstanceOfExpr -> encloseLeft(expr, expr.expression)
is ConditionalExpr -> {
encloseLeft(expr, expr.condition)
encloseLeft(expr, expr.thenExpr)
encloseRight(expr, expr.elseExpr)
}
is AssignExpr -> {
encloseLeft(expr, expr.target)
encloseRight(expr, expr.value)
@ -131,6 +136,7 @@ public class EncloseTransformer : Transformer() {
parent.replace(child, EnclosedExpr(child.clone()))
}
}
Associativity.NONE, Associativity.RIGHT -> {
if (childOp.isPrecedenceLessEqual(parentOp)) {
parent.replace(child, EnclosedExpr(child.clone()))
@ -149,6 +155,7 @@ public class EncloseTransformer : Transformer() {
parent.replace(child, EnclosedExpr(child.clone()))
}
}
Associativity.RIGHT -> {
if (childOp.isPrecedenceLess(parentOp)) {
parent.replace(child, EnclosedExpr(child.clone()))

@ -45,6 +45,7 @@ public class ForLoopConditionTransformer : Transformer() {
PREFIX_INCREMENT, PREFIX_DECREMENT, POSTFIX_INCREMENT, POSTFIX_DECREMENT -> expression
else -> null
}
is AssignExpr -> target
else -> null
}

@ -244,10 +244,12 @@ public class GlTransformer @Inject constructor(private val registry: GlRegistry)
transformExpr(unit, command, parameter, expr.left)
transformExpr(unit, command, parameter, expr.right)
}
is ConditionalExpr -> {
transformExpr(unit, command, parameter, expr.thenExpr)
transformExpr(unit, command, parameter, expr.elseExpr)
}
is IntegerLiteralExpr -> {
transformIntegerLiteralExpr(unit, command, parameter, expr)
}

@ -27,6 +27,7 @@ public class IdentityTransformer : Transformer() {
expr.replace(expr.left)
}
}
BinaryExpr.Operator.MINUS -> {
if (expr.left.isZero()) {
// 0 - x => -x
@ -36,6 +37,7 @@ public class IdentityTransformer : Transformer() {
expr.replace(expr.left)
}
}
BinaryExpr.Operator.MULTIPLY -> {
if (expr.left.isOne()) {
// 1 * x => x
@ -45,12 +47,14 @@ public class IdentityTransformer : Transformer() {
expr.replace(expr.left)
}
}
BinaryExpr.Operator.DIVIDE -> {
if (expr.right.isOne()) {
// x / 1 => x
expr.replace(expr.left)
}
}
else -> Unit
}
}

@ -458,6 +458,7 @@ public class IfElseTransformer : Transformer() {
null
}
}
else -> null
}
}
@ -477,6 +478,7 @@ public class IfElseTransformer : Transformer() {
val tail = statements.lastOrNull()
tail is ThrowStmt || tail is ReturnStmt
}
else -> false
}
}

@ -51,16 +51,19 @@ public fun Expression.negate(): Expression {
UnaryExpr.Operator.MINUS -> expression.clone()
else -> UnaryExpr(clone(), UnaryExpr.Operator.MINUS)
}
is IntegerLiteralExpr -> when (val n = asNumber()) {
IntegerLiteralExpr.MAX_31_BIT_UNSIGNED_VALUE_AS_LONG -> IntegerLiteralExpr(Integer.MIN_VALUE.toString())
is Int -> IntegerLiteralExpr((-n.toInt()).toString())
else -> error("Invalid IntegerLiteralExpr type")
}
is LongLiteralExpr -> when (val n = asNumber()) {
LongLiteralExpr.MAX_63_BIT_UNSIGNED_VALUE_AS_BIG_INTEGER -> Long.MIN_VALUE.toLongLiteralExpr()
is Long -> (-n).toLongLiteralExpr()
else -> error("Invalid LongLiteralExpr type")
}
else -> UnaryExpr(clone(), UnaryExpr.Operator.MINUS)
}
}
@ -72,27 +75,37 @@ public fun Expression.not(): Expression {
return expression.clone()
}
}
is BinaryExpr -> {
when (operator) {
BinaryExpr.Operator.EQUALS ->
return BinaryExpr(left.clone(), right.clone(), BinaryExpr.Operator.NOT_EQUALS)
BinaryExpr.Operator.NOT_EQUALS ->
return BinaryExpr(left.clone(), right.clone(), BinaryExpr.Operator.EQUALS)
BinaryExpr.Operator.GREATER ->
return BinaryExpr(left.clone(), right.clone(), BinaryExpr.Operator.LESS_EQUALS)
BinaryExpr.Operator.GREATER_EQUALS ->
return BinaryExpr(left.clone(), right.clone(), BinaryExpr.Operator.LESS)
BinaryExpr.Operator.LESS ->
return BinaryExpr(left.clone(), right.clone(), BinaryExpr.Operator.GREATER_EQUALS)
BinaryExpr.Operator.LESS_EQUALS ->
return BinaryExpr(left.clone(), right.clone(), BinaryExpr.Operator.GREATER)
BinaryExpr.Operator.AND ->
return BinaryExpr(left.not(), right.not(), BinaryExpr.Operator.OR)
BinaryExpr.Operator.OR ->
return BinaryExpr(left.not(), right.not(), BinaryExpr.Operator.AND)
else -> Unit
}
}
is BooleanLiteralExpr -> return BooleanLiteralExpr(!value)
}

@ -51,6 +51,7 @@ public class CopyPropagationAnalyzer(owner: String, method: MethodNode) :
newSet
}
}
insn is IincInsnNode -> set.minusKilledByAssignmentTo(insn.`var`)
else -> set
}

@ -84,12 +84,14 @@ public class IntInterpreter(private val args: Array<IntValueSet>) : Interpreter<
}
v1 / v2
}
Opcodes.IREM -> {
if (v2 == 0) {
return IntValue(basicValue)
}
v1 % v2
}
Opcodes.ISHL -> v1 shl v2
Opcodes.ISHR -> v1 shr v2
Opcodes.IUSHR -> v1 ushr v2

@ -27,6 +27,7 @@ public class LiveVariableAnalyzer(owner: String, method: MethodNode) :
Opcodes.ISTORE, Opcodes.LSTORE, Opcodes.FSTORE, Opcodes.DSTORE, Opcodes.ASTORE -> set.minus(insn.`var`)
else -> set
}
is IincInsnNode -> set.plus(insn.`var`)
else -> set
}

@ -60,10 +60,12 @@ public class FieldMappingGenerator(
Type.BOOLEAN, Type.BYTE, Type.CHAR, Type.SHORT, Type.INT, Type.LONG, Type.FLOAT, Type.DOUBLE -> {
elementType.className + dimensions
}
Type.OBJECT -> {
val className = classMapping.getOrDefault(elementType.internalName, elementType.internalName)
className.getClassName() + dimensions
}
else -> throw IllegalArgumentException("Unknown field type $elementType")
}

@ -212,6 +212,7 @@ public class ConstantArgTransformer @Inject constructor(private val profile: Pro
else -> Unit
}
}
IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE -> {
val value1 = frame.getStack(frame.stackSize - 2)
val value2 = frame.getStack(frame.stackSize - 1)

@ -79,6 +79,7 @@ public class EmptyClassTransformer : Transformer() {
addTypeReference(cst)
}
}
is TypeInsnNode -> referencedClasses.add(insn.desc)
}
}

@ -111,10 +111,12 @@ public class OpaquePredicateTransformer : Transformer() {
method.instructions.remove(match[0])
branch.opcode = Opcodes.GOTO
}
Opcodes.IFNE -> {
// branch is never taken
match.forEach(method.instructions::remove)
}
else -> error("Invalid opcode")
}

@ -85,6 +85,7 @@ public class UnusedArgTransformer @Inject constructor(private val profile: Profi
retainArg(partition, localToArgMap, frame, insn.`var`)
}
}
is IincInsnNode -> retainArg(partition, localToArgMap, frame, insn.`var`)
is MethodInsnNode -> {
val invokePartition = inheritedMethodSets[MemberRef(insn)]

@ -101,6 +101,7 @@ public class NameMapProcessor : AbstractProcessor() {
map.methods[ref] = Method(owner, name, arguments, locals)
}
else -> error("Unexpected element type")
}
}

@ -49,10 +49,12 @@ public class NetrcReader(private val scanner: Scanner) {
state = State.READ_MACHINE
host = scanner.next()
}
"default" -> {
state = State.READ_MACHINE
host = null
}
"login", "password", "account" -> {
if (state != State.READ_MACHINE) {
throw IOException("Unexpected token '$token'")
@ -66,6 +68,7 @@ public class NetrcReader(private val scanner: Scanner) {
password = scanner.next()
}
}
"macdef" -> skipMacro()
}
}

@ -32,10 +32,12 @@ public class CachePathTransformer @Inject constructor(
insn.cst = ".${config.internalOperator}_cache_"
paths++
}
"jagex_" -> {
insn.cst = ".${config.internalOperator}_"
paths++
}
"runescape" -> {
insn.cst = config.internalGame
paths++

@ -63,10 +63,12 @@ public class HighDpiTransformer : Transformer() {
addCanvasScaleField(clazz)
newMembers++
}
in GL_INTERFACES -> {
addPixelZoomMethod(clazz, Opcodes.ACC_ABSTRACT)
newMembers++
}
in GL_IMPLS -> {
addPixelZoomMethod(clazz, Opcodes.ACC_FINAL or Opcodes.ACC_NATIVE)
newMembers++

@ -32,6 +32,7 @@ public class PublicKeyTransformer @Inject constructor(private val key: RSAPrivat
insn.cst = key.publicExponent.toString()
exponents++
}
JAGEX_MODULUS -> {
insn.cst = key.modulus.toString()
moduli++

@ -14,17 +14,20 @@ public object Js5RequestEncoder : MessageToByteEncoder<Js5Request>(Js5Request::c
out.writeByte(msg.archive)
out.writeShort(msg.group)
}
is Js5Request.Rekey -> {
out.writeByte(4)
out.writeByte(msg.key)
out.writeZero(2)
}
is Js5Request.LoggedIn -> encodeSimple(out, 2)
is Js5Request.LoggedOut -> encodeSimple(out, 3)
is Js5Request.Connected -> {
out.writeByte(6)
out.writeMedium(3)
}
is Js5Request.Disconnect -> encodeSimple(out, 7)
}
}

@ -12,6 +12,7 @@ public sealed class LoginRequest : Packet {
public val day: Int,
public val country: Int
) : LoginRequest()
public data class CreateCheckName(public val username: String) : LoginRequest()
public data class CreateAccount(
public val build: Int,
@ -27,11 +28,13 @@ public sealed class LoginRequest : Packet {
public val country: Int,
public val email: String
) : LoginRequest()
public data class RequestWorldList(public val checksum: Int) : LoginRequest()
public data class CheckWorldSuitability(
public val build: Int,
public val username: String,
public val password: String
) : LoginRequest()
public object InitCrossDomainConnection : LoginRequest()
}

@ -37,6 +37,7 @@ public object ModifiedUtf8Charset : Charset("ModifiedUtf8", null) {
output.put((0xC0 or ((char.code shr 6) and 0x1F)).toByte())
output.put((0x80 or (char.code and 0x3F)).toByte())
}
else -> {
output.put((0xE0 or ((char.code shr 12) and 0x1F)).toByte())
output.put((0x80 or ((char.code shr 6) and 0x1F)).toByte())

@ -105,9 +105,11 @@ public class ForestDisjointSet<T> : DisjointSet<T> {
xRoot.rank < yRoot.rank -> {
xRoot.parent = yRoot
}
xRoot.rank > yRoot.rank -> {
yRoot.parent = xRoot
}
else -> {
yRoot.parent = xRoot
xRoot.rank++

Loading…
Cancel
Save