Class EvalContext


  • public final class EvalContext
    extends Object
    Per-subject evaluation scope with lazy, cached views of a method so repeated accessors (every arg(n), instructions, line) share one decode/analysis.
    • Constructor Detail

      • EvalContext

        public EvalContext​(ClassFile classFile,
                           MethodEntry method,
                           EvidenceCollector evidence)
        Creates a scope with no class hierarchy, leaving subtype checks unresolvable.
        Parameters:
        classFile - the class in scope
        method - the method in scope, or null for a class-scoped context
        evidence - the collector match evidence is reported to
      • EvalContext

        public EvalContext​(ClassFile classFile,
                           MethodEntry method,
                           EvidenceCollector evidence,
                           Supplier<ClassHierarchy> hierarchySupplier)
        Creates a scope; all cached views start empty and are built on first use.
        Parameters:
        classFile - the class in scope
        method - the method in scope, or null for a class-scoped context
        evidence - the collector match evidence is reported to
        hierarchySupplier - supplies the shared class hierarchy, or null when none is available
    • Method Detail

      • classFile

        public ClassFile classFile()
        Returns:
        the class in scope
      • hierarchy

        public ClassHierarchy hierarchy()
        Returns:
        the shared class hierarchy used for transitive subtype checks, or null when none was supplied
      • method

        public MethodEntry method()
        Returns:
        the method in scope, or null for a class-scoped context
      • evidence

        public EvidenceCollector evidence()
        Returns:
        the collector that match evidence is reported to
      • codeWriter

        public CodeWriter codeWriter()
        Returns:
        the decoded code, built on first use, or null for abstract or native methods and class-scoped contexts
      • instructions

        public List<Instruction> instructions()
        Returns:
        the decoded instructions, cached, or an empty list when there is no code
      • ir

        public IRMethod ir()
        Returns:
        the method lifted to SSA IR, built on first use, or null if it cannot be lifted
      • loopAnalysis

        public LoopAnalysis loopAnalysis()
        Returns:
        loop analysis over the SSA IR, built on first use, or null if the method cannot be lifted
      • defUse

        public DefUseChains defUse()
        Returns:
        def-use chains over the SSA IR, built on first use, or null if the method cannot be lifted
      • blockForOffset

        public IRBlock blockForOffset​(int offset)
        Finds the IR block containing a bytecode offset - the block with the greatest start offset not past it.
        Parameters:
        offset - the bytecode offset
        Returns:
        the containing block, or null when the method cannot be lifted
      • lineForOffset

        public int lineForOffset​(int offset)
        Resolves a bytecode offset to a source line using the nearest preceding LineNumberTable entry.
        Parameters:
        offset - the bytecode offset
        Returns:
        the source line, or -1 when no LineNumberTable is present
      • memo

        public <T> T memo​(Object key,
                          Supplier<T> supplier)
        Computes a value once per key and caches it for the life of this context.
        Type Parameters:
        T - the cached value type
        Parameters:
        key - identifies the cached value
        supplier - produces the value on first use
        Returns:
        the cached value