Add assignment operator support to HexLiteralTransformer

Signed-off-by: Graham <gpe@openrs2.org>
Graham 4 years ago
parent 99b725dc8f
commit 853f2cff91
  1. 15
      deob-ast/src/main/kotlin/org/openrs2/deob/ast/transform/HexLiteralTransformer.kt

@ -1,6 +1,7 @@
package org.openrs2.deob.ast.transform
import com.github.javaparser.ast.CompilationUnit
import com.github.javaparser.ast.expr.AssignExpr
import com.github.javaparser.ast.expr.BinaryExpr
import com.github.javaparser.ast.expr.Expression
import com.github.javaparser.ast.expr.IntegerLiteralExpr
@ -26,6 +27,12 @@ public class HexLiteralTransformer : Transformer() {
convertToHex(expr.right)
}
}
unit.walk { expr: AssignExpr ->
if (expr.operator in ASSIGN_OPS) {
convertToHex(expr.value)
}
}
}
private fun convertToHex(expr: Expression) {
@ -46,5 +53,13 @@ public class HexLiteralTransformer : Transformer() {
BinaryExpr.Operator.BINARY_OR,
BinaryExpr.Operator.XOR
)
private val ASSIGN_OPS = setOf(
AssignExpr.Operator.BINARY_AND,
AssignExpr.Operator.BINARY_OR,
AssignExpr.Operator.LEFT_SHIFT,
AssignExpr.Operator.SIGNED_RIGHT_SHIFT,
AssignExpr.Operator.UNSIGNED_RIGHT_SHIFT,
AssignExpr.Operator.XOR
)
}
}

Loading…
Cancel
Save