Class PartialEvaluator

    • Field Detail

      • ENABLE_NEW_EXCEPTIONS

        public static boolean ENABLE_NEW_EXCEPTIONS
        Enables new exceptions to be thrown during evaluation. These are exceptions that are not thrown by the original ProGuard code. This is a temporary flag to allow the new exceptions to be tested. TODO: Remove this flag when the new exceptions are stable and will not break any dependent code.
    • Constructor Detail

      • PartialEvaluator

        public PartialEvaluator()
        Creates a simple PartialEvaluator.
      • PartialEvaluator

        public PartialEvaluator​(ValueFactory valueFactory)
        Creates a new PartialEvaluator.
        Parameters:
        valueFactory - the value factory that will create all values during evaluation.
      • PartialEvaluator

        public PartialEvaluator​(ValueFactory valueFactory,
                                InvocationUnit invocationUnit,
                                boolean evaluateAllCode)
        Creates a new PartialEvaluator.
        Parameters:
        valueFactory - the value factory that will create all values during the evaluation.
        invocationUnit - the invocation unit that will handle all communication with other fields and methods.
        evaluateAllCode - a flag that specifies whether all casts, branch targets, and exception handlers should be evaluated, even if they are unnecessary or unreachable.
      • PartialEvaluator

        public PartialEvaluator​(ValueFactory valueFactory,
                                InvocationUnit invocationUnit,
                                boolean evaluateAllCode,
                                InstructionVisitor extraInstructionVisitor)
        Creates a new PartialEvaluator.
        Parameters:
        valueFactory - the value factory that will create all values during the evaluation.
        invocationUnit - the invocation unit that will handle all communication with other fields and methods.
        evaluateAllCode - a flag that specifies whether all branch targets and exception handlers should be evaluated, even if they are unreachable.
        extraInstructionVisitor - an optional extra visitor for all instructions right before they are executed.
    • Method Detail

      • visitAnyAttribute

        public void visitAnyAttribute​(Clazz clazz,
                                      Attribute attribute)
        Description copied from interface: AttributeVisitor
        Visits any Attribute instance. The more specific default implementations of this interface delegate to this method.
        Specified by:
        visitAnyAttribute in interface AttributeVisitor
      • isTraced

        public boolean isTraced​(int startOffset,
                                int endOffset)
        Returns whether a block of instructions is ever used.
      • isTraced

        public boolean isTraced​(int instructionOffset)
        Returns whether the instruction at the given offset has ever been executed during the partial evaluation.
      • isInstruction

        public boolean isInstruction​(int instructionOffset)
        Returns whether there is an instruction at the given offset.
      • isTarget

        public boolean isTarget​(int instructionOffset)
        Returns whether the instruction at the given offset is the target of any kind.
      • isBranchOrigin

        public boolean isBranchOrigin​(int instructionOffset)
        Returns whether the instruction at the given offset is the origin of a branch instruction.
      • isBranchTarget

        public boolean isBranchTarget​(int instructionOffset)
        Returns whether the instruction at the given offset is the target of a branch instruction.
      • isBranchOrExceptionTarget

        public boolean isBranchOrExceptionTarget​(int instructionOffset)
        Returns whether the instruction at the given offset is the target of a branch instruction or an exception.
      • isExceptionHandler

        public boolean isExceptionHandler​(int instructionOffset)
        Returns whether the instruction at the given offset is the start of an exception handler.
      • isSubroutineStart

        public boolean isSubroutineStart​(int instructionOffset)
        Returns whether the instruction at the given offset is the start of a subroutine.
      • isSubroutineInvocation

        public boolean isSubroutineInvocation​(int instructionOffset)
        Returns whether the instruction at the given offset is a subroutine invocation.
      • isSubroutine

        public boolean isSubroutine​(int instructionOffset)
        Returns whether the instruction at the given offset is part of a subroutine.
      • isSubroutineReturning

        public boolean isSubroutineReturning​(int instructionOffset)
        Returns whether the subroutine at the given offset is ever returning by means of a regular 'ret' instruction.
      • subroutineEnd

        public int subroutineEnd​(int instructionOffset)
        Returns the offset after the subroutine that starts at the given offset.
      • isCreation

        public boolean isCreation​(int offset)
        Returns whether the instruction at the given offset creates a new, uninitialized instance.
      • isInitializer

        public boolean isInitializer​(int offset)
        Returns whether the instruction at the given offset is the special invocation of an instance initializer.
      • getVariablesBefore

        public TracedVariables getVariablesBefore​(int instructionOffset)
        Returns the variables before execution of the instruction at the given offset.
      • getVariablesAfter

        public TracedVariables getVariablesAfter​(int instructionOffset)
        Returns the variables after execution of the instruction at the given offset.
      • getStackBefore

        public TracedStack getStackBefore​(int instructionOffset)
        Returns the stack before execution of the instruction at the given offset.
      • getStackAfter

        public TracedStack getStackAfter​(int instructionOffset)
        Returns the stack after execution of the instruction at the given offset.
      • branchOrigins

        public InstructionOffsetValue branchOrigins​(int instructionOffset)
        Returns the instruction offsets that branch to the given instruction offset.
      • branchTargets

        public InstructionOffsetValue branchTargets​(int instructionOffset)
        Returns the instruction offsets to which the given instruction offset branches.
      • tracedInstructionFilter

        public InstructionVisitor tracedInstructionFilter​(InstructionVisitor instructionVisitor)
        Returns a filtering version of the given instruction visitor that only visits traced instructions.
      • tracedInstructionFilter

        public InstructionVisitor tracedInstructionFilter​(boolean traced,
                                                          InstructionVisitor instructionVisitor)
        Returns a filtering version of the given instruction visitor that only visits traced or untraced instructions.
      • stopAnalysisAfterNEvaluations

        public PartialEvaluator stopAnalysisAfterNEvaluations​(int stopAnalysisAfterNEvaluations)
        It the analysis visits an instruction this many times (this can happen e.g. for big switches), the analysis of this method is forcibly stopped and a ExcessiveComplexityException is thrown.