use of org.jf.dexlib2.analysis.AnalyzedInstruction in project smali by JesusFreke.
the class MethodAnalyzer method canPropagateTypeAfterInstanceOf.
static boolean canPropagateTypeAfterInstanceOf(AnalyzedInstruction analyzedInstanceOfInstruction, AnalyzedInstruction analyzedIfInstruction, ClassPath classPath) {
if (!classPath.isArt()) {
return false;
}
Instruction ifInstruction = analyzedIfInstruction.instruction;
if (((Instruction21t) ifInstruction).getRegisterA() == analyzedInstanceOfInstruction.getDestinationRegister()) {
Reference reference = ((Instruction22c) analyzedInstanceOfInstruction.getInstruction()).getReference();
RegisterType registerType = RegisterType.getRegisterType(classPath, (TypeReference) reference);
try {
if (registerType.type != null && !registerType.type.isInterface()) {
int objectRegister = ((TwoRegisterInstruction) analyzedInstanceOfInstruction.getInstruction()).getRegisterB();
RegisterType originalType = analyzedIfInstruction.getPreInstructionRegisterType(objectRegister);
return isNotWideningConversion(originalType, registerType);
}
} catch (UnresolvedClassException ex) {
return false;
}
}
return false;
}
use of org.jf.dexlib2.analysis.AnalyzedInstruction in project smali by JesusFreke.
the class MethodAnalyzer method analyzeNewArray.
private void analyzeNewArray(@Nonnull AnalyzedInstruction analyzedInstruction) {
ReferenceInstruction instruction = (ReferenceInstruction) analyzedInstruction.instruction;
TypeReference type = (TypeReference) instruction.getReference();
if (type.getType().charAt(0) != '[') {
throw new AnalysisException("new-array used with non-array type");
}
RegisterType arrayType = RegisterType.getRegisterType(classPath, type);
setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, arrayType);
}
use of org.jf.dexlib2.analysis.AnalyzedInstruction in project smali by JesusFreke.
the class MethodAnalyzer method analyzeCheckCast.
private void analyzeCheckCast(@Nonnull AnalyzedInstruction analyzedInstruction) {
ReferenceInstruction instruction = (ReferenceInstruction) analyzedInstruction.instruction;
TypeReference reference = (TypeReference) instruction.getReference();
RegisterType castRegisterType = RegisterType.getRegisterType(classPath, reference);
setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, castRegisterType);
}
use of org.jf.dexlib2.analysis.AnalyzedInstruction in project smali by JesusFreke.
the class MethodAnalyzer method analyzePutGetVolatile.
private boolean analyzePutGetVolatile(@Nonnull AnalyzedInstruction analyzedInstruction, boolean analyzeResult) {
FieldReference field = (FieldReference) ((ReferenceInstruction) analyzedInstruction.instruction).getReference();
String fieldType = field.getType();
Opcode originalOpcode = analyzedInstruction.instruction.getOpcode();
Opcode opcode = classPath.getFieldInstructionMapper().getAndCheckDeodexedOpcode(fieldType, originalOpcode);
Instruction deodexedInstruction;
if (originalOpcode.isStaticFieldAccessor()) {
OneRegisterInstruction instruction = (OneRegisterInstruction) analyzedInstruction.instruction;
deodexedInstruction = new ImmutableInstruction21c(opcode, instruction.getRegisterA(), field);
} else {
TwoRegisterInstruction instruction = (TwoRegisterInstruction) analyzedInstruction.instruction;
deodexedInstruction = new ImmutableInstruction22c(opcode, instruction.getRegisterA(), instruction.getRegisterB(), field);
}
analyzedInstruction.setDeodexedInstruction(deodexedInstruction);
if (analyzeResult) {
analyzeInstruction(analyzedInstruction);
}
return true;
}
use of org.jf.dexlib2.analysis.AnalyzedInstruction in project atlas by alibaba.
the class MethodDefinition method addAnalyzedInstructionMethodItems.
private void addAnalyzedInstructionMethodItems(List<MethodItem> methodItems) {
MethodAnalyzer methodAnalyzer = new MethodAnalyzer(classDef.options.classPath, method, classDef.options.inlineResolver);
AnalysisException analysisException = methodAnalyzer.getAnalysisException();
if (analysisException != null) {
// TODO: need to keep track of whether any errors occurred, so we can exit with a non-zero result
methodItems.add(new CommentMethodItem(String.format("AnalysisException: %s", analysisException.getMessage()), analysisException.codeAddress, Integer.MIN_VALUE));
analysisException.printStackTrace(System.err);
}
List<AnalyzedInstruction> instructions = methodAnalyzer.getAnalyzedInstructions();
int currentCodeAddress = 0;
for (int i = 0; i < instructions.size(); i++) {
AnalyzedInstruction instruction = instructions.get(i);
MethodItem methodItem = InstructionMethodItemFactory.makeInstructionFormatMethodItem(this, currentCodeAddress, instruction.getInstruction());
methodItems.add(methodItem);
if (instruction.getInstruction().getOpcode().format == Format.UnresolvedOdexInstruction) {
methodItems.add(new CommentedOutMethodItem(InstructionMethodItemFactory.makeInstructionFormatMethodItem(this, currentCodeAddress, instruction.getOriginalInstruction())));
}
if (i != instructions.size() - 1) {
methodItems.add(new BlankMethodItem(currentCodeAddress));
}
if (classDef.options.addCodeOffsets) {
methodItems.add(new MethodItem(currentCodeAddress) {
@Override
public double getSortOrder() {
return -1000;
}
@Override
public boolean writeTo(IndentingWriter writer) throws IOException {
writer.write("#@");
writer.printUnsignedLongAsHex(codeAddress & 0xFFFFFFFFL);
return true;
}
});
}
if (classDef.options.registerInfo != 0 && !instruction.getInstruction().getOpcode().format.isPayloadFormat) {
methodItems.add(new PreInstructionRegisterInfoMethodItem(classDef.options.registerInfo, methodAnalyzer, registerFormatter, instruction, currentCodeAddress));
methodItems.add(new PostInstructionRegisterInfoMethodItem(registerFormatter, instruction, currentCodeAddress));
}
currentCodeAddress += instruction.getInstruction().getCodeUnits();
}
}
Aggregations