Don't convert integer literals in char arithmetic to char literals

On balance, I think in most cases this is harder to read.

Signed-off-by: Graham <gpe@openrs2.dev>
Graham 4 years ago
parent ea9f212fe1
commit 0ae1ffb51d
  1. 4
      deob-ast/src/main/java/dev/openrs2/deob/ast/transform/CharLiteralTransformer.kt

@ -8,9 +8,7 @@ import com.github.javaparser.ast.expr.BinaryExpr.Operator.GREATER
import com.github.javaparser.ast.expr.BinaryExpr.Operator.GREATER_EQUALS import com.github.javaparser.ast.expr.BinaryExpr.Operator.GREATER_EQUALS
import com.github.javaparser.ast.expr.BinaryExpr.Operator.LESS import com.github.javaparser.ast.expr.BinaryExpr.Operator.LESS
import com.github.javaparser.ast.expr.BinaryExpr.Operator.LESS_EQUALS import com.github.javaparser.ast.expr.BinaryExpr.Operator.LESS_EQUALS
import com.github.javaparser.ast.expr.BinaryExpr.Operator.MINUS
import com.github.javaparser.ast.expr.BinaryExpr.Operator.NOT_EQUALS import com.github.javaparser.ast.expr.BinaryExpr.Operator.NOT_EQUALS
import com.github.javaparser.ast.expr.BinaryExpr.Operator.PLUS
import com.github.javaparser.ast.expr.CharLiteralExpr import com.github.javaparser.ast.expr.CharLiteralExpr
import com.github.javaparser.ast.expr.Expression import com.github.javaparser.ast.expr.Expression
import com.github.javaparser.ast.expr.IntegerLiteralExpr import com.github.javaparser.ast.expr.IntegerLiteralExpr
@ -33,7 +31,7 @@ import javax.inject.Singleton
class CharLiteralTransformer : Transformer() { class CharLiteralTransformer : Transformer() {
override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) {
unit.walk { expr: BinaryExpr -> unit.walk { expr: BinaryExpr ->
if (expr.operator in COMPARISON_OPERATORS || expr.operator == PLUS || expr.operator == MINUS) { if (expr.operator in COMPARISON_OPERATORS) {
convertToCharLiteral(expr.left, expr.right) convertToCharLiteral(expr.left, expr.right)
convertToCharLiteral(expr.right, expr.left) convertToCharLiteral(expr.right, expr.left)
} }

Loading…
Cancel
Save