if (a instanceof LineNumberTable) {
LineNumber[] ln = ((LineNumberTable) a).getLineNumberTable();
if (useTags) {
// abracadabra, lets create tags rather than linenumbergens.
for (int k = 0; k < ln.length; k++) {
LineNumber l = ln[k];
int lnum = l.getLineNumber();
if (lnum > highestLineNumber) {
highestLineNumber = lnum;
}
LineNumberTag lt = new LineNumberTag(lnum);
il.findHandle(l.getStartPC(), arrayOfInstructions, true).addTargeter(lt);
}
} else {
for (int k = 0; k < ln.length; k++) {
LineNumber l = ln[k];
addLineNumber(il.findHandle(l.getStartPC(), arrayOfInstructions, true), l.getLineNumber());
}
}
} else if (a instanceof LocalVariableTable) {
// Lets have a go at creating Tags directly
if (useTags) {
LocalVariable[] lv = ((LocalVariableTable) a).getLocalVariableTable();
for (int k = 0; k < lv.length; k++) {
LocalVariable l = lv[k];
Type t = Type.getType(l.getSignature());
LocalVariableTag lvt = new LocalVariableTag(t, l.getSignature(), l.getName(), l.getIndex(), l
.getStartPC());
InstructionHandle start = il.findHandle(l.getStartPC(), arrayOfInstructions, true);
byte b = t.getType();
if (b != Constants.T_ADDRESS) {
int increment = t.getSize();
if (l.getIndex() + increment > maxLocals) {
maxLocals = l.getIndex() + increment;
}
}
int end = l.getStartPC() + l.getLength();
do {
start.addTargeter(lvt);
start = start.getNext();
} while (start != null && start.getPosition() < end);
}
} else {
LocalVariable[] lv = ((LocalVariableTable) a).getLocalVariableTable();
removeLocalVariables();
for (int k = 0; k < lv.length; k++) {
LocalVariable l = lv[k];
InstructionHandle start = il.findHandle(l.getStartPC(), arrayOfInstructions);
InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength(), arrayOfInstructions);
// AMC, this actually gives us the first instruction AFTER the range,
// so move back one... (findHandle can't cope with mid-instruction indices)
if (end != null) {
end = end.getPrev();
}
// Repair malformed handles
if (null == start) {
start = il.getStart();
}
if (null == end) {
end = il.getEnd();
}
addLocalVariable(l.getName(), Type.getType(l.getSignature()), l.getIndex(), start, end);
}
}
} else {
addCodeAttribute(a);
}