boolean keepLocals) {
this.method = method;
this.accSuper = (cf.getAccessFlags() & AccessFlags.ACC_SUPER) != 0;
this.sourceFile = cf.getSourceFile();
AttributeList attribs = method.getAttributes();
this.attCode = (AttCode) attribs.findFirst(AttCode.ATTRIBUTE_NAME);
AttributeList codeAttribs = attCode.getAttributes();
/*
* Combine all LineNumberTable attributes into one, with the
* combined result saved into the instance. The following code
* isn't particularly efficient for doing merges, but as far
* as I know, this situation rarely occurs "in the
* wild," so there's not much point in optimizing for it.
*/
LineNumberList lineNumbers = LineNumberList.EMPTY;
if (keepLines) {
for (AttLineNumberTable lnt = (AttLineNumberTable)
codeAttribs.findFirst(AttLineNumberTable.ATTRIBUTE_NAME);
lnt != null;
lnt = (AttLineNumberTable) codeAttribs.findNext(lnt)) {
lineNumbers = LineNumberList.concat(lineNumbers,
lnt.getLineNumbers());
}
}
this.lineNumbers = lineNumbers;
LocalVariableList localVariables = LocalVariableList.EMPTY;
if (keepLocals) {
/*
* Do likewise (and with the same caveat) for
* LocalVariableTable and LocalVariableTypeTable attributes.
* This combines both of these kinds of attribute into a
* single LocalVariableList.
*/
for (AttLocalVariableTable lvt = (AttLocalVariableTable)
codeAttribs.findFirst(
AttLocalVariableTable.ATTRIBUTE_NAME);
lvt != null;
lvt = (AttLocalVariableTable) codeAttribs.findNext(lvt)) {
localVariables =
LocalVariableList.concat(localVariables,
lvt.getLocalVariables());
}
LocalVariableList typeList = LocalVariableList.EMPTY;
for (AttLocalVariableTypeTable lvtt = (AttLocalVariableTypeTable)
codeAttribs.findFirst(
AttLocalVariableTypeTable.ATTRIBUTE_NAME);
lvtt != null;
lvtt =
(AttLocalVariableTypeTable) codeAttribs.findNext(lvtt)) {
typeList =
LocalVariableList.concat(typeList,
lvtt.getLocalVariables());
}