Fix {read,write}LineNumbers

Signed-off-by: Graham <gpe@openrs2.org>
Graham 4 years ago
parent 2b3e9d318a
commit 0e1046d457
  1. 11
      asm/src/main/kotlin/org/openrs2/asm/packclass/PackClass.kt

@ -859,11 +859,12 @@ public object PackClass {
): Array<IntArray?> { ): Array<IntArray?> {
require(attributes.size == pcs.size) require(attributes.size == pcs.size)
var line = 0
return Array(attributes.size) { i -> return Array(attributes.size) { i ->
if (attributes[i].contains(ConstantPool.CODE)) { if (attributes[i].contains(ConstantPool.CODE)) {
var line = 0
IntArray(pcs[i]!!.size) { IntArray(pcs[i]!!.size) {
line += buf.readUnsignedShortSmart() line += buf.readUnsignedShort()
line and 0xFFFF line and 0xFFFF
} }
} else { } else {
@ -1442,20 +1443,20 @@ public object PackClass {
} }
private fun writeLineNumbers(buf: ByteBuf, clazz: ClassNode) { private fun writeLineNumbers(buf: ByteBuf, clazz: ClassNode) {
var prevLine = 0
for (method in clazz.methods) { for (method in clazz.methods) {
if (method.instructions.size() == 0) { if (method.instructions.size() == 0) {
continue continue
} }
var prevLine = 0
for (insn in method.instructions) { for (insn in method.instructions) {
if (insn !is LineNumberNode) { if (insn !is LineNumberNode) {
continue continue
} }
val line = insn.line val line = insn.line
buf.writeUnsignedShortSmart(line - prevLine) buf.writeShort(line - prevLine)
prevLine = line prevLine = line
} }
} }

Loading…
Cancel
Save