Package org.jf.dexlib2.analysis

Examples of org.jf.dexlib2.analysis.RegisterType


        List<Task> switchPayloadTasks = Lists.newArrayList();
        index = 0;
        for (final Instruction instruction: methodImplementation.getInstructions()) {
            final MethodLocation location = instructionList.get(index);
            final Opcode opcode = instruction.getOpcode();
            if (opcode == Opcode.PACKED_SWITCH_PAYLOAD || opcode == Opcode.SPARSE_SWITCH_PAYLOAD) {
                switchPayloadTasks.add(new Task() {
                    @Override public void perform() {
                        convertAndSetInstruction(location, codeAddressToIndex, instruction);
                    }
View Full Code Here


            opcode == Opcode.THROW_VERIFICATION_ERROR;
    }

    @Override
    public boolean writeTo(IndentingWriter writer) throws IOException {
        Opcode opcode = instruction.getOpcode();
        String verificationErrorName = null;
        String referenceString = null;

        boolean commentOutInstruction = false;

        if (instruction instanceof Instruction20bc) {
            int verificationError = ((Instruction20bc)instruction).getVerificationError();
            verificationErrorName = VerificationError.getVerificationErrorName(verificationError);
            if (verificationErrorName == null) {
                writer.write("#was invalid verification error type: ");
                writer.printSignedIntAsDec(verificationError);
                writer.write("\n");
                verificationErrorName = "generic-error";
            }
        }

        if (instruction instanceof ReferenceInstruction) {
            ReferenceInstruction referenceInstruction = (ReferenceInstruction)instruction;
            try {
                Reference reference = referenceInstruction.getReference();

                String classContext = null;
                if (methodDef.classDef.options.useImplicitReferences) {
                    classContext = methodDef.method.getDefiningClass();
                }

                referenceString = ReferenceUtil.getReferenceString(reference, classContext);
                assert referenceString != null;
            } catch (InvalidItemIndex ex) {
                writer.write("#");
                writer.write(ex.getMessage());
                writer.write("\n");
                commentOutInstruction = true;

                referenceString = String.format("%s@%d",
                    ReferenceType.toString(referenceInstruction.getReferenceType()),
                    ex.getInvalidIndex());
            } catch (ReferenceType.InvalidReferenceTypeException ex) {
                writer.write("#invalid reference type: ");
                writer.printSignedIntAsDec(ex.getReferenceType());
                commentOutInstruction = true;

                referenceString = "invalid_reference";
            }
        }

        if (instruction instanceof Instruction31t) {
            Opcode payloadOpcode;
            switch (instruction.getOpcode()) {
                case PACKED_SWITCH:
                    payloadOpcode = Opcode.PACKED_SWITCH_PAYLOAD;
                    break;
                case SPARSE_SWITCH:
View Full Code Here

    public LabelMethodItem getLabel() {
        return label;
    }

    private String getLabelPrefix() {
        Opcode opcode = instruction.getOpcode();
        switch (opcode.format) {
            case Format10t:
            case Format20t:
            case Format30t:
                return "goto_";
View Full Code Here

            return false;
        }

        writer.write('#');
        for (; registerNum >= 0; registerNum = registers.nextSetBit(registerNum + 1)) {
            RegisterType registerType = analyzedInstruction.getPostInstructionRegisterType(registerNum);

            registerFormatter.writeTo(writer, registerNum);
            writer.write('=');
            registerType.writeTo(writer);
            writer.write(';');
        }
        return true;
    }
View Full Code Here

            //post-instruction registers
            return;
        }

        for (int registerNum=0; registerNum<registerCount; registerNum++) {
            RegisterType mergedRegisterType = analyzedInstruction.getPreInstructionRegisterType(registerNum);

            for (AnalyzedInstruction predecessor: analyzedInstruction.getPredecessors()) {
                RegisterType predecessorRegisterType = predecessor.getPostInstructionRegisterType(registerNum);
                if (predecessorRegisterType.category != RegisterType.UNKNOWN &&
                        !predecessorRegisterType.equals(mergedRegisterType)) {
                    registers.set(registerNum);
                }
            }
        }
    }
View Full Code Here

        writer.write(":merge{");

        boolean first = true;

        for (AnalyzedInstruction predecessor: analyzedInstruction.getPredecessors()) {
            RegisterType predecessorRegisterType = predecessor.getPostInstructionRegisterType(registerNum);

            if (!first) {
                writer.write(',');
            }

            if (predecessor.getInstructionIndex() == -1) {
                //the fake "StartOfMethod" instruction
                writer.write("Start:");
            } else {
                writer.write("0x");
                writer.printUnsignedLongAsHex(methodAnalyzer.getInstructionAddress(predecessor));
                writer.write(':');
            }
            predecessorRegisterType.writeTo(writer);

            first = false;
        }
        writer.write('}');
    }
View Full Code Here

                    writer.write('\n');
                    writer.write('#');
                    previousWasFullMerge = false;
                }

                RegisterType registerType = analyzedInstruction.getPreInstructionRegisterType(registerNum);

                registerFormatter.writeTo(writer, registerNum);
                writer.write('=');

                registerType.writeTo(writer);
                writer.write(';');
            }

            firstRegister = false;
        }
View Full Code Here

        };
    }

    public static TypeReference rewriteTypeReference(@Nonnull final Rewriter<String> typeRewriter,
                                                     @Nonnull final TypeReference typeReference) {
        return new BaseTypeReference() {
            @Nonnull @Override public String getType() {
                return typeRewriter.rewrite(typeReference.getType());
            }
        };
    }
View Full Code Here

        final String exceptionType = getExceptionType();
        if (exceptionType == null) {
            return null;
        }

        return new BaseTypeReference() {
            @Nonnull @Override public String getType() {
                return exceptionType;
            }
        };
    }
View Full Code Here

                            }
                        }
                    }

                    if (needsFix) {
                        MutableMethodImplementation mutableMethodImplementation =
                                classSection.makeMutableMethodImplementation(methodKey);
                        fixInstructions(mutableMethodImplementation);

                        instructions = mutableMethodImplementation.getInstructions();
                        tryBlocks = mutableMethodImplementation.getTryBlocks();
                        debugItems = mutableMethodImplementation.getDebugItems();
                    }
                }

                int debugItemOffset = writeDebugItem(offsetWriter, debugWriter,
                        classSection.getParameterNames(methodKey), debugItems);
View Full Code Here

TOP

Related Classes of org.jf.dexlib2.analysis.RegisterType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.