ic.dfa
Class ReachableAnalysis

java.lang.Object
  extended by ic.dfa.DataFlowAnalysis<Boolean>
      extended by ic.dfa.ReachableAnalysis

public class ReachableAnalysis
extends DataFlowAnalysis<Boolean>

A simple analysis to determine whether there are unreachable statements in a program. That is it, determines whether there is a path from the entry to each program point. For example:

 void main(string[] a) {
   boolean b;
   int y,z;
   if (b) {
      return;
      z = z + 1;  // NOT REACHABLE
   } 
   y = y + 1;
 }
 
In this code, the assignment following the return is not reachable. The analysis is defined as follows:
   D  : forward
   V  : { true, false }  where true < false.  
   Top: false.
   /\ : boolean ||
   f  : f_I(s) = s for all instructions I
   boundary:  OUT[in] = true
 
After dataflow analysis, unreachable blocks will have IN[b] == false.


Field Summary
 
Fields inherited from class ic.dfa.DataFlowAnalysis
cfg, in, out
 
Constructor Summary
ReachableAnalysis(ControlFlowGraph cfg)
           
 
Method Summary
 Boolean boundary()
          Initial value for out[enter] or in[exit], depending on direction.
 boolean equals(Boolean t1, Boolean t2)
          Return true if t1 and t2 are equivalent.
 boolean isForward()
          Return true iff the analysis is a forward analysis.
 Boolean meet(Boolean t1, Boolean t2)
          Return the meet of t1 and t2 in the lattice.
 Boolean top()
          Top value in the lattice of T elements.
 Boolean transfer(ic.tac.TInstr instr, Boolean t)
          Return the result of applying the transfer function for instr to t.
 
Methods inherited from class ic.dfa.DataFlowAnalysis
in, out, solve, solveBackward, solveForward, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReachableAnalysis

public ReachableAnalysis(ControlFlowGraph cfg)
Method Detail

boundary

public Boolean boundary()
Description copied from class: DataFlowAnalysis
Initial value for out[enter] or in[exit], depending on direction.

Specified by:
boundary in class DataFlowAnalysis<Boolean>

top

public Boolean top()
Description copied from class: DataFlowAnalysis
Top value in the lattice of T elements.

Specified by:
top in class DataFlowAnalysis<Boolean>

equals

public boolean equals(Boolean t1,
                      Boolean t2)
Description copied from class: DataFlowAnalysis
Return true if t1 and t2 are equivalent.

Specified by:
equals in class DataFlowAnalysis<Boolean>

isForward

public boolean isForward()
Description copied from class: DataFlowAnalysis
Return true iff the analysis is a forward analysis.

Specified by:
isForward in class DataFlowAnalysis<Boolean>

meet

public Boolean meet(Boolean t1,
                    Boolean t2)
Description copied from class: DataFlowAnalysis
Return the meet of t1 and t2 in the lattice.

Specified by:
meet in class DataFlowAnalysis<Boolean>

transfer

public Boolean transfer(ic.tac.TInstr instr,
                        Boolean t)
Description copied from class: DataFlowAnalysis
Return the result of applying the transfer function for instr to t.

Specified by:
transfer in class DataFlowAnalysis<Boolean>