Add separate bytecodeOffset variable to VarExprent

I think it's best not to conflate this with visibleOffset, as
visibleOffset is not always set to bytecode_offset and it is also used
for other things (e.g. looking up debug variable names).
master
Graham 5 years ago
parent 0d2a413b2a
commit b4c1bab1b6
  1. 6
      src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java
  2. 16
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/VarExprent.java

@ -323,7 +323,7 @@ public class ExprProcessor implements CodeConstants {
case opc_fload:
case opc_dload:
case opc_aload:
pushEx(stack, exprlist, new VarExprent(instr.operand(0), varTypes[instr.opcode - opc_iload], varProcessor, bytecode_offset));
pushEx(stack, exprlist, new VarExprent(instr.operand(0), varTypes[instr.opcode - opc_iload], varProcessor, bytecode_offset, bytecode_offset));
break;
case opc_iaload:
case opc_laload:
@ -354,7 +354,7 @@ public class ExprProcessor implements CodeConstants {
Exprent expr = stack.pop();
int varindex = instr.operand(0);
AssignmentExprent assign = new AssignmentExprent(
new VarExprent(varindex, varTypes[instr.opcode - opc_istore], varProcessor, nextMeaningfulOffset(block, i)), expr, bytecode_offsets);
new VarExprent(varindex, varTypes[instr.opcode - opc_istore], varProcessor, nextMeaningfulOffset(block, i), bytecode_offset), expr, bytecode_offsets);
exprlist.add(assign);
break;
case opc_iastore:
@ -416,7 +416,7 @@ public class ExprProcessor implements CodeConstants {
pushEx(stack, exprlist, new FunctionExprent(FunctionExprent.FUNCTION_NEG, stack, bytecode_offsets));
break;
case opc_iinc:
VarExprent vevar = new VarExprent(instr.operand(0), VarType.VARTYPE_INT, varProcessor, bytecode_offset);
VarExprent vevar = new VarExprent(instr.operand(0), VarType.VARTYPE_INT, varProcessor, bytecode_offset, bytecode_offset);
exprlist.add(new AssignmentExprent(vevar, new FunctionExprent(
instr.operand(1) < 0 ? FunctionExprent.FUNCTION_SUB : FunctionExprent.FUNCTION_ADD, Arrays
.asList(vevar.copy(), new ConstExprent(VarType.VARTYPE_INT, Math.abs(instr.operand(1)), null)),

@ -40,20 +40,28 @@ public class VarExprent extends Exprent {
private boolean definition = false;
private final VarProcessor processor;
private final int visibleOffset;
private final int bytecodeOffset;
private int version = 0;
private boolean classDef = false;
private boolean stack = false;
@Deprecated
public VarExprent(int index, VarType varType, VarProcessor processor) {
this(index, varType, processor, -1);
}
@Deprecated
public VarExprent(int index, VarType varType, VarProcessor processor, int visibleOffset) {
this(index, varType, processor, visibleOffset, -1);
}
public VarExprent(int index, VarType varType, VarProcessor processor, int visibleOffset, int bytecodeOffset) {
super(EXPRENT_VAR);
this.index = index;
this.varType = varType;
this.processor = processor;
this.visibleOffset = visibleOffset;
this.bytecodeOffset = bytecodeOffset;
}
@Override
@ -73,7 +81,7 @@ public class VarExprent extends Exprent {
@Override
public Exprent copy() {
VarExprent var = new VarExprent(index, getVarType(), processor, visibleOffset);
VarExprent var = new VarExprent(index, getVarType(), processor, visibleOffset, bytecodeOffset);
var.setDefinition(definition);
var.setVersion(version);
var.setClassDef(classDef);
@ -100,12 +108,12 @@ public class VarExprent extends Exprent {
}
if (definition) {
if (visibleOffset != -1) {
if (bytecodeOffset != -1) {
MethodWrapper method = (MethodWrapper) DecompilerContext.getProperty(DecompilerContext.CURRENT_METHOD_WRAPPER);
StructOriginalPcTableAttribute originalPcTable = method.methodStruct.getAttribute(StructGeneralAttribute.ATTRIBUTE_ORIGINAL_PC_TABLE);
if (originalPcTable != null && originalPcTable.hasOriginalPc(visibleOffset)) {
int pc = originalPcTable.getOriginalPc(visibleOffset);
if (originalPcTable != null && originalPcTable.hasOriginalPc(bytecodeOffset)) {
int pc = originalPcTable.getOriginalPc(bytecodeOffset);
buffer.append('@');
buffer.append(DecompilerContext.getImportCollector().getShortName("dev.openrs2.deob.annotation.Pc"));
buffer.append('(');

Loading…
Cancel
Save