Use names from OriginalPcTable earlier during the decompilation process

master
Graham 5 years ago
parent eaa8533e74
commit 9addbd6349
  1. 35
      src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java
  2. 5
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/VarExprent.java

@ -17,6 +17,7 @@ import org.jetbrains.java.decompiler.struct.StructMethod;
import org.jetbrains.java.decompiler.struct.attr.StructGeneralAttribute; import org.jetbrains.java.decompiler.struct.attr.StructGeneralAttribute;
import org.jetbrains.java.decompiler.struct.attr.StructLocalVariableTableAttribute; import org.jetbrains.java.decompiler.struct.attr.StructLocalVariableTableAttribute;
import org.jetbrains.java.decompiler.struct.attr.StructMethodParametersAttribute; import org.jetbrains.java.decompiler.struct.attr.StructMethodParametersAttribute;
import org.jetbrains.java.decompiler.struct.attr.StructOriginalPcTableAttribute;
import org.jetbrains.java.decompiler.struct.gen.MethodDescriptor; import org.jetbrains.java.decompiler.struct.gen.MethodDescriptor;
import org.jetbrains.java.decompiler.util.InterpreterUtil; import org.jetbrains.java.decompiler.util.InterpreterUtil;
import org.jetbrains.java.decompiler.util.VBStyleCollection; import org.jetbrains.java.decompiler.util.VBStyleCollection;
@ -187,6 +188,40 @@ public class ClassWrapper {
}); });
} }
} }
StructOriginalPcTableAttribute originalPcTable = mt.getAttribute(StructGeneralAttribute.ATTRIBUTE_ORIGINAL_PC_TABLE);
if (originalPcTable != null) {
methodWrapper.getOrBuildGraph().iterateExprents(rootExpr -> {
List<Exprent> exprs = rootExpr.getAllExprents(true);
exprs.add(rootExpr);
for (Exprent expr : exprs) {
if (expr.type != Exprent.EXPRENT_VAR) {
continue;
}
VarExprent varExpr = (VarExprent) expr;
if (!varExpr.isDefinition()) {
continue;
}
int bytecodeOffset = varExpr.getBytecodeOffset();
if (bytecodeOffset == -1 || !originalPcTable.hasOriginalPc(bytecodeOffset)) {
continue;
}
int pc = originalPcTable.getOriginalPc(bytecodeOffset);
if (!originalPcTable.hasName(pc)) {
continue;
}
String name = originalPcTable.getName(pc);
varProc.setVarName(varExpr.getVarVersionPair(), name);
}
return 0;
});
}
} }
DecompilerContext.getLogger().endMethod(); DecompilerContext.getLogger().endMethod();

@ -123,11 +123,6 @@ public class VarExprent extends Exprent {
buffer.append('('); buffer.append('(');
buffer.append(Integer.toString(pc)); buffer.append(Integer.toString(pc));
buffer.append(") "); buffer.append(") ");
if (originalPcTable.hasName(pc) && processor != null) {
name = originalPcTable.getName(pc);
processor.setVarName(varVersion, name);
}
} }
} }

Loading…
Cancel
Save