Add char literal type inference to add/sub operators

master
Graham 5 years ago
parent 24c93c3c50
commit 317e26e299
  1. 26
      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) { public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) {
tracer.addMapping(bytecode); 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) { if (funcType <= FUNCTION_USHR) {
return wrapOperandString(lstOperands.get(0), false, indent, tracer) return wrapOperandString(lstOperands.get(0), false, indent, tracer)
.append(OPERATORS[funcType]) .append(OPERATORS[funcType])
.append(wrapOperandString(lstOperands.get(1), true, indent, tracer)); .append(wrapOperandString(lstOperands.get(1), true, indent, tracer));
} }
// try to determine more accurate type for 'char' literals
if (funcType >= FUNCTION_EQ) { 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) return wrapOperandString(lstOperands.get(0), false, indent, tracer)
.append(OPERATORS[funcType - FUNCTION_EQ + 11]) .append(OPERATORS[funcType - FUNCTION_EQ + 11])
.append(wrapOperandString(lstOperands.get(1), true, indent, tracer)); .append(wrapOperandString(lstOperands.get(1), true, indent, tracer));

Loading…
Cancel
Save