Add OriginalPcTable attribute decoder

master
Graham 5 years ago
parent 9b04d3ea36
commit 52a8a00698
  1. 4
      src/org/jetbrains/java/decompiler/struct/attr/StructGeneralAttribute.java
  2. 31
      src/org/jetbrains/java/decompiler/struct/attr/StructOriginalPcTableAttribute.java

@ -34,6 +34,7 @@ public class StructGeneralAttribute {
public static final Key<StructGeneralAttribute> ATTRIBUTE_DEPRECATED = new Key<>("Deprecated"); public static final Key<StructGeneralAttribute> ATTRIBUTE_DEPRECATED = new Key<>("Deprecated");
public static final Key<StructLineNumberTableAttribute> ATTRIBUTE_LINE_NUMBER_TABLE = new Key<>("LineNumberTable"); public static final Key<StructLineNumberTableAttribute> ATTRIBUTE_LINE_NUMBER_TABLE = new Key<>("LineNumberTable");
public static final Key<StructMethodParametersAttribute> ATTRIBUTE_METHOD_PARAMETERS = new Key<>("MethodParameters"); public static final Key<StructMethodParametersAttribute> ATTRIBUTE_METHOD_PARAMETERS = new Key<>("MethodParameters");
public static final Key<StructOriginalPcTableAttribute> ATTRIBUTE_ORIGINAL_PC_TABLE = new Key<>("OriginalPcTable");
public static class Key<T extends StructGeneralAttribute> { public static class Key<T extends StructGeneralAttribute> {
private final String name; private final String name;
@ -97,6 +98,9 @@ public class StructGeneralAttribute {
else if (ATTRIBUTE_METHOD_PARAMETERS.getName().equals(name)) { else if (ATTRIBUTE_METHOD_PARAMETERS.getName().equals(name)) {
attr = new StructMethodParametersAttribute(); attr = new StructMethodParametersAttribute();
} }
else if (ATTRIBUTE_ORIGINAL_PC_TABLE.getName().equals(name)) {
attr = new StructOriginalPcTableAttribute();
}
else { else {
// unsupported attribute // unsupported attribute
return null; return null;

@ -0,0 +1,31 @@
package org.jetbrains.java.decompiler.struct.attr;
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
import org.jetbrains.java.decompiler.util.DataInputFullStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public final class StructOriginalPcTableAttribute extends StructGeneralAttribute {
private final Map<Integer, Integer> pcs = new HashMap<>();
@Override
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException {
int len = data.readUnsignedShort();
for (int i = 0; i < len; i++) {
int pc = data.readUnsignedShort();
int originalPc = data.readUnsignedShort();
pcs.put(pc, originalPc);
}
}
public boolean hasOriginalPc(int pc) {
return pcs.containsKey(pc);
}
public int getOriginalPc(int pc) {
return pcs.get(pc);
}
}
Loading…
Cancel
Save