diff --git a/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java b/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java index 5c6da7c..5b4395f 100644 --- a/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java +++ b/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.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.StructLocalVariableTableAttribute; 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.util.InterpreterUtil; 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 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(); diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/VarExprent.java b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/VarExprent.java index 1c86bb4..665b5d1 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/VarExprent.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/VarExprent.java @@ -123,11 +123,6 @@ public class VarExprent extends Exprent { buffer.append('('); buffer.append(Integer.toString(pc)); buffer.append(") "); - - if (originalPcTable.hasName(pc) && processor != null) { - name = originalPcTable.getName(pc); - processor.setVarName(varVersion, name); - } } }