From 317e26e2995427f9ce9c21d28de7c6536344a534 Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 2 Feb 2020 11:36:12 +0000 Subject: [PATCH] Add char literal type inference to add/sub operators --- .../decompiler/exps/FunctionExprent.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/FunctionExprent.java b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/FunctionExprent.java index 6bdd8db..08bf31b 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/FunctionExprent.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/FunctionExprent.java @@ -433,26 +433,26 @@ public class FunctionExprent extends Exprent { public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) { tracer.addMapping(bytecode); + // try to determine more accurate type for 'char' literals + if (funcType <= FUNCTION_SUB || (funcType >= FUNCTION_EQ && funcType <= FUNCTION_LE)) { + Exprent left = lstOperands.get(0); + Exprent right = lstOperands.get(1); + + if (right.type == EXPRENT_CONST) { + ((ConstExprent) right).adjustConstType(left.getExprType()); + } + else if (left.type == EXPRENT_CONST) { + ((ConstExprent) left).adjustConstType(right.getExprType()); + } + } + if (funcType <= FUNCTION_USHR) { return wrapOperandString(lstOperands.get(0), false, indent, tracer) .append(OPERATORS[funcType]) .append(wrapOperandString(lstOperands.get(1), true, indent, tracer)); } - // try to determine more accurate type for 'char' literals if (funcType >= FUNCTION_EQ) { - if (funcType <= FUNCTION_LE) { - Exprent left = lstOperands.get(0); - Exprent right = lstOperands.get(1); - - if (right.type == EXPRENT_CONST) { - ((ConstExprent) right).adjustConstType(left.getExprType()); - } - else if (left.type == EXPRENT_CONST) { - ((ConstExprent) left).adjustConstType(right.getExprType()); - } - } - return wrapOperandString(lstOperands.get(0), false, indent, tracer) .append(OPERATORS[funcType - FUNCTION_EQ + 11]) .append(wrapOperandString(lstOperands.get(1), true, indent, tracer));