use of org.jf.dexlib2.ReferenceType in project smali by JesusFreke.
the class ClassPool method internCode.
private void internCode(@Nonnull Method method) {
// this also handles parameter names, which aren't directly tied to the MethodImplementation, even though the debug items are
boolean hasInstruction = false;
MethodImplementation methodImpl = method.getImplementation();
if (methodImpl != null) {
for (Instruction instruction : methodImpl.getInstructions()) {
hasInstruction = true;
if (instruction instanceof ReferenceInstruction) {
Reference reference = ((ReferenceInstruction) instruction).getReference();
switch(instruction.getOpcode().referenceType) {
case ReferenceType.STRING:
dexPool.stringSection.intern((StringReference) reference);
break;
case ReferenceType.TYPE:
dexPool.typeSection.intern(((TypeReference) reference).getType());
break;
case ReferenceType.FIELD:
dexPool.fieldSection.intern((FieldReference) reference);
break;
case ReferenceType.METHOD:
dexPool.methodSection.intern((MethodReference) reference);
break;
case ReferenceType.CALL_SITE:
dexPool.callSiteSection.intern((CallSiteReference) reference);
break;
default:
throw new ExceptionWithContext("Unrecognized reference type: %d", instruction.getOpcode().referenceType);
}
}
}
List<? extends TryBlock> tryBlocks = methodImpl.getTryBlocks();
if (!hasInstruction && tryBlocks.size() > 0) {
throw new ExceptionWithContext("Method %s has no instructions, but has try blocks.", method);
}
for (TryBlock<? extends ExceptionHandler> tryBlock : methodImpl.getTryBlocks()) {
for (ExceptionHandler handler : tryBlock.getExceptionHandlers()) {
dexPool.typeSection.internNullable(handler.getExceptionType());
}
}
}
}
use of org.jf.dexlib2.ReferenceType in project smali by JesusFreke.
the class ListReferencesCommand method run.
@Override
public void run() {
if (help || inputList == null || inputList.isEmpty()) {
usage();
return;
}
if (inputList.size() > 1) {
System.err.println("Too many files specified");
usage();
return;
}
String input = inputList.get(0);
loadDexFile(input);
BaksmaliFormatter formatter = new BaksmaliFormatter();
for (Reference reference : dexFile.getReferences(referenceType)) {
System.out.println(formatter.getReference(reference));
}
}
Aggregations