Edit AS 1/2 constant pool

This commit is contained in:
honfika@gmail.com
2015-05-07 16:14:22 +02:00
parent 732087f20f
commit 89f66fbcb2
3 changed files with 51 additions and 3 deletions

View File

@@ -594,11 +594,13 @@ public abstract class Action implements GraphSourceItem {
writer.appendNoHilight(Helper.constants).newLine();
for (Action a : list) {
if (a instanceof ActionConstantPool) {
if (poolIdx > 0) {
writer.appendNoHilight("---").newLine();
}
ActionConstantPool cPool = (ActionConstantPool) a;
int constIdx = 0;
for (String c : cPool.constantPool) {
writer.appendNoHilight(poolIdx);
writer.appendNoHilight("|");
writer.appendNoHilight(constIdx);
writer.appendNoHilight("|");
writer.appendNoHilight(c);

View File

@@ -848,6 +848,28 @@ public class Helper {
return data;
}
public static List<List<String>> getConstantPoolsFromText(String text) {
Scanner scanner = new Scanner(text);
scanner.nextLine(); // ignore first line
List<List<String>> result = new ArrayList<>();
List<String> cPool = new ArrayList<>();
result.add(cPool);
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
if (line.startsWith("---")) {
cPool = new ArrayList<>();
result.add(cPool);
}
String[] parts = line.split("\\|", 2);
if (parts.length >= 2) {
cPool.add(parts[1]);
}
}
return result;
}
public static boolean contains(int[] array, int value) {
if (array == null) {
return false;