java-decompiler: unwanted dependency dropped
This commit is contained in:
@@ -15,12 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.java.decompiler.struct.attr;
|
package org.jetbrains.java.decompiler.struct.attr;
|
||||||
|
|
||||||
import com.intellij.openapi.util.Pair;
|
|
||||||
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
|
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
|
||||||
import org.jetbrains.java.decompiler.util.DataInputFullStream;
|
import org.jetbrains.java.decompiler.util.DataInputFullStream;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* u2 line_number_table_length;
|
* u2 line_number_table_length;
|
||||||
@@ -31,37 +29,33 @@ import java.util.*;
|
|||||||
* Created by Egor on 05.10.2014.
|
* Created by Egor on 05.10.2014.
|
||||||
*/
|
*/
|
||||||
public class StructLineNumberTableAttribute extends StructGeneralAttribute {
|
public class StructLineNumberTableAttribute extends StructGeneralAttribute {
|
||||||
private List<Pair<Integer, Integer>> myLineInfo = Collections.emptyList();
|
private int[] myLineInfo = new int[0];
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initContent(ConstantPool pool) throws IOException {
|
public void initContent(ConstantPool pool) throws IOException {
|
||||||
DataInputFullStream data = stream();
|
DataInputFullStream data = stream();
|
||||||
|
|
||||||
int len = data.readUnsignedShort();
|
int len = data.readUnsignedShort() * 2;
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
myLineInfo = new ArrayList<Pair<Integer, Integer>>(len);
|
myLineInfo = new int[len];
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i += 2) {
|
||||||
int startPC = data.readUnsignedShort();
|
myLineInfo[i] = data.readUnsignedShort();
|
||||||
int lineNumber = data.readUnsignedShort();
|
myLineInfo[i + 1] = data.readUnsignedShort();
|
||||||
myLineInfo.add(Pair.create(startPC, lineNumber));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (myLineInfo.length > 0) {
|
||||||
myLineInfo = Collections.emptyList();
|
myLineInfo = new int[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFirstLine() {
|
public int getFirstLine() {
|
||||||
if (!myLineInfo.isEmpty()) {
|
return myLineInfo.length > 0 ? myLineInfo[1] : -1;
|
||||||
return myLineInfo.get(0).getSecond();
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int findLineNumber(int pc) {
|
public int findLineNumber(int pc) {
|
||||||
for (Pair<Integer, Integer> pair : myLineInfo) {
|
for (int i = 0; i < myLineInfo.length; i += 2) {
|
||||||
if (pc >= pair.getFirst()) {
|
if (pc >= myLineInfo[i]) {
|
||||||
return pair.getSecond();
|
return myLineInfo[i + 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user