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_fload:
case opc_dload: case opc_dload:
case opc_aload: 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; break;
case opc_iaload: case opc_iaload:
case opc_laload: case opc_laload:
@ -354,7 +354,7 @@ public class ExprProcessor implements CodeConstants {
Exprent expr = stack.pop(); Exprent expr = stack.pop();
int varindex = instr.operand(0); int varindex = instr.operand(0);
AssignmentExprent assign = new AssignmentExprent( 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); exprlist.add(assign);
break; break;
case opc_iastore: case opc_iastore:
@ -416,7 +416,7 @@ public class ExprProcessor implements CodeConstants {
pushEx(stack, exprlist, new FunctionExprent(FunctionExprent.FUNCTION_NEG, stack, bytecode_offsets)); pushEx(stack, exprlist, new FunctionExprent(FunctionExprent.FUNCTION_NEG, stack, bytecode_offsets));
break; break;
case opc_iinc: 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( exprlist.add(new AssignmentExprent(vevar, new FunctionExprent(
instr.operand(1) < 0 ? FunctionExprent.FUNCTION_SUB : FunctionExprent.FUNCTION_ADD, Arrays 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)), .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 boolean definition = false;
private final VarProcessor processor; private final VarProcessor processor;
private final int visibleOffset; private final int visibleOffset;
private final int bytecodeOffset;
private int version = 0; private int version = 0;
private boolean classDef = false; private boolean classDef = false;
private boolean stack = false; private boolean stack = false;
@Deprecated
public VarExprent(int index, VarType varType, VarProcessor processor) { public VarExprent(int index, VarType varType, VarProcessor processor) {
this(index, varType, processor, -1); this(index, varType, processor, -1);
} }
@Deprecated
public VarExprent(int index, VarType varType, VarProcessor processor, int visibleOffset) { 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); super(EXPRENT_VAR);
this.index = index; this.index = index;
this.varType = varType; this.varType = varType;
this.processor = processor; this.processor = processor;
this.visibleOffset = visibleOffset; this.visibleOffset = visibleOffset;
this.bytecodeOffset = bytecodeOffset;
} }
@Override @Override
@ -73,7 +81,7 @@ public class VarExprent extends Exprent {
@Override @Override
public Exprent copy() { public Exprent copy() {
VarExprent var = new VarExprent(index, getVarType(), processor, visibleOffset); VarExprent var = new VarExprent(index, getVarType(), processor, visibleOffset, bytecodeOffset);
var.setDefinition(definition); var.setDefinition(definition);
var.setVersion(version); var.setVersion(version);
var.setClassDef(classDef); var.setClassDef(classDef);
@ -100,12 +108,12 @@ public class VarExprent extends Exprent {
} }
if (definition) { if (definition) {
if (visibleOffset != -1) { if (bytecodeOffset != -1) {
MethodWrapper method = (MethodWrapper) DecompilerContext.getProperty(DecompilerContext.CURRENT_METHOD_WRAPPER); MethodWrapper method = (MethodWrapper) DecompilerContext.getProperty(DecompilerContext.CURRENT_METHOD_WRAPPER);
StructOriginalPcTableAttribute originalPcTable = method.methodStruct.getAttribute(StructGeneralAttribute.ATTRIBUTE_ORIGINAL_PC_TABLE); StructOriginalPcTableAttribute originalPcTable = method.methodStruct.getAttribute(StructGeneralAttribute.ATTRIBUTE_ORIGINAL_PC_TABLE);
if (originalPcTable != null && originalPcTable.hasOriginalPc(visibleOffset)) { if (originalPcTable != null && originalPcTable.hasOriginalPc(bytecodeOffset)) {
int pc = originalPcTable.getOriginalPc(visibleOffset); int pc = originalPcTable.getOriginalPc(bytecodeOffset);
buffer.append('@'); buffer.append('@');
buffer.append(DecompilerContext.getImportCollector().getShortName("dev.openrs2.deob.annotation.Pc")); buffer.append(DecompilerContext.getImportCollector().getShortName("dev.openrs2.deob.annotation.Pc"));
buffer.append('('); buffer.append('(');

Loading…
Cancel
Save