Fields Summary |
---|
private final com.android.dx.cf.iface.Method | method{@code non-null;} method being wrapped |
private final com.android.dx.rop.cst.CstString | sourceFile{@code null-ok;} the class's {@code SourceFile} attribute value,
if any |
private final boolean | accSuperwhether the class that this method is part of is defined with
{@code ACC_SUPER} |
private final com.android.dx.cf.attrib.AttCode | attCode{@code non-null;} the code attribute |
private final LineNumberList | lineNumbers{@code non-null;} line number list |
private final LocalVariableList | localVariables{@code non-null;} local variable list |
Constructors Summary |
---|
public ConcreteMethod(com.android.dx.cf.iface.Method method, com.android.dx.cf.iface.ClassFile cf, boolean keepLines, boolean keepLocals)Constructs an instance.
this(method, cf.getAccessFlags(), cf.getSourceFile(), keepLines, keepLocals);
|
public ConcreteMethod(com.android.dx.cf.iface.Method method, int accessFlags, com.android.dx.rop.cst.CstString sourceFile, boolean keepLines, boolean keepLocals)
this.method = method;
this.accSuper = (accessFlags & AccessFlags.ACC_SUPER) != 0;
this.sourceFile = sourceFile;
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());
}
if (typeList.size() != 0) {
localVariables =
LocalVariableList.mergeDescriptorsAndSignatures(
localVariables, typeList);
}
}
this.localVariables = localVariables;
|
Methods Summary |
---|
public boolean | getAccSuper()Gets whether the class that this method is part of is defined with
{@code ACC_SUPER}.
return accSuper;
|
public int | getAccessFlags(){@inheritDoc}
return method.getAccessFlags();
|
public com.android.dx.cf.iface.AttributeList | getAttributes(){@inheritDoc}
return method.getAttributes();
|
public ByteCatchList | getCatches()Gets the exception table.
return attCode.getCatches();
|
public BytecodeArray | getCode()Gets the bytecode array.
return attCode.getCode();
|
public com.android.dx.rop.cst.CstType | getDefiningClass(){@inheritDoc}
return method.getDefiningClass();
|
public com.android.dx.rop.cst.CstString | getDescriptor(){@inheritDoc}
return method.getDescriptor();
|
public com.android.dx.rop.type.Prototype | getEffectiveDescriptor(){@inheritDoc}
return method.getEffectiveDescriptor();
|
public LineNumberList | getLineNumbers()Gets the line number list.
return lineNumbers;
|
public LocalVariableList | getLocalVariables()Gets the local variable list.
return localVariables;
|
public int | getMaxLocals()Gets the number of locals.
return attCode.getMaxLocals();
|
public int | getMaxStack()Gets the maximum stack size.
return attCode.getMaxStack();
|
public com.android.dx.rop.cst.CstString | getName(){@inheritDoc}
return method.getName();
|
public com.android.dx.rop.cst.CstNat | getNat(){@inheritDoc}
return method.getNat();
|
public com.android.dx.rop.code.SourcePosition | makeSourcePosistion(int offset)Returns a {@link SourcePosition} instance corresponding to the
given bytecode offset.
return new SourcePosition(sourceFile, offset,
lineNumbers.pcToLine(offset));
|