Package com.tonic.analysis.query.eval
Class EvalContext
- java.lang.Object
-
- com.tonic.analysis.query.eval.EvalContext
-
public final class EvalContext extends Object
Per-subject evaluation scope with lazy, cached views of a method so repeated accessors (everyarg(n),instructions,line) share one decode/analysis.
-
-
Constructor Summary
Constructors Constructor Description EvalContext(ClassFile classFile, MethodEntry method, EvidenceCollector evidence)Creates a scope with no class hierarchy, leaving subtype checks unresolvable.EvalContext(ClassFile classFile, MethodEntry method, EvidenceCollector evidence, Supplier<ClassHierarchy> hierarchySupplier)Creates a scope; all cached views start empty and are built on first use.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IRBlockblockForOffset(int offset)Finds the IR block containing a bytecode offset - the block with the greatest start offset not past it.ClassFileclassFile()CodeWritercodeWriter()DefUseChainsdefUse()EvidenceCollectorevidence()ClassHierarchyhierarchy()List<Instruction>instructions()IRMethodir()intlineForOffset(int offset)Resolves a bytecode offset to a source line using the nearest preceding LineNumberTable entry.LoopAnalysisloopAnalysis()<T> Tmemo(Object key, Supplier<T> supplier)Computes a value once per key and caches it for the life of this context.MethodEntrymethod()
-
-
-
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 scopemethod- the method in scope, or null for a class-scoped contextevidence- 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 scopemethod- the method in scope, or null for a class-scoped contextevidence- the collector match evidence is reported tohierarchySupplier- 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
-
-