本文整理汇总了Java中org.jf.dexlib2.iface.instruction.Instruction.getCodeUnits方法的典型用法代码示例。如果您正苦于以下问题:Java Instruction.getCodeUnits方法的具体用法?Java Instruction.getCodeUnits怎么用?Java Instruction.getCodeUnits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jf.dexlib2.iface.instruction.Instruction
的用法示例。
在下文中一共展示了Instruction.getCodeUnits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DexBody
import org.jf.dexlib2.iface.instruction.Instruction; //导入方法依赖的package包/类
/**
* @param code the codeitem that is contained in this body
* @param method the method that is associated with this body
*/
public DexBody(DexFile dexFile, Method method, RefType declaringClassType) {
MethodImplementation code = method.getImplementation();
if (code == null)
throw new RuntimeException("error: no code for method "+ method.getName());
this.declaringClassType = declaringClassType;
tries = code.getTryBlocks();
methodSignature = method.getDefiningClass() +": "+ method.getReturnType() +" "+ method.getName() +"(";
for (MethodParameter mp: method.getParameters())
methodSignature += mp.getType() +",";
List<? extends CharSequence> paramTypes = method.getParameterTypes();
if (paramTypes != null) {
parameterTypes = new ArrayList<Type>();
for (CharSequence type : paramTypes)
parameterTypes.add(DexType.toSoot(type.toString()));
} else {
parameterTypes = Collections.emptyList();
}
isStatic = Modifier.isStatic(method.getAccessFlags());
numRegisters = code.getRegisterCount();
numParameterRegisters = MethodUtil.getParameterRegisterCount(method);
if (!isStatic)
numParameterRegisters--;
instructions = new ArrayList<DexlibAbstractInstruction>();
instructionAtAddress = new HashMap<Integer, DexlibAbstractInstruction>();
registerLocals = new Local[numRegisters];
int address = 0;
for (Instruction instruction : code.getInstructions()) {
DexlibAbstractInstruction dexInstruction = fromInstruction(instruction, address);
instructions.add(dexInstruction);
instructionAtAddress.put(address, dexInstruction);
Debug.printDbg(" put instruction '", dexInstruction ,"' at 0x", Integer.toHexString(address));
address += instruction.getCodeUnits();
}
// Check taken from Android's dalvik/libdex/DexSwapVerify.cpp
if (numParameterRegisters > numRegisters)
throw new RuntimeException("Malformed dex file: insSize (" + numParameterRegisters
+ ") > registersSize (" + numRegisters + ")");
for (DebugItem di: code.getDebugItems()) {
if (di instanceof ImmutableLineNumber) {
ImmutableLineNumber ln = (ImmutableLineNumber)di;
DexlibAbstractInstruction ins = instructionAtAddress(ln.getCodeAddress());
if (ins == null) {
Debug.printDbg("Line number tag pointing to invalid offset: " + ln.getCodeAddress());
continue;
}
ins.setLineNumber(ln.getLineNumber());
Debug.printDbg("Add line number tag " + ln.getLineNumber() + " for instruction: "
+ instructionAtAddress(ln.getCodeAddress()));
}
}
this.dexFile = dexFile;
}