REACHING DEFINITIONS IN FLEX
![](grayLine4.gif)
FLEX provides two classes named ReachingDefs
; the template call graph implementation uses the one in the package harpoon.Analysis. ReachingDefs
is an abstract class implemented by several classes, but our focus is on ReachingDefsImpl
. The constructors create a ReachingDefsImpl
object for a provided HCode
argument and perform reaching definitions analysis. (An HCode
object corresponds to a list of instructions, with each statement represented by an HCodeElement
). The method with which we are most concerned during type inference is reachingDefs
:
public Set reachingDefs(HCodeElement hce, Temp t)
Invoking this method on a ReachingDefsImpl
object returns the set of HCodeElement
s that provide definitions for the Temp t
that reach HCodeElement hce
. If hce
is unreachable, the method returns the empty set. (Temp
s represent temporary variables. Each Temp
is guaranteed to have a unique name, regardless of the different contexts in which a programmer may have reused a variable name.)
Relationships to keep in mind:
- Definition - DEF - initialization or assignment
- Use - USE - variable read/access
- Reaching definitions - ReachingDefs - def-use chains