harpoon.Analysis.Quads
Class QuadClassHierarchy

java.lang.Object
  extended by harpoon.Analysis.ClassHierarchy
      extended by harpoon.Analysis.Quads.QuadClassHierarchy
All Implemented Interfaces:
Serializable

public class QuadClassHierarchy
extends ClassHierarchy
implements Serializable

QuadClassHierarchy computes a ClassHierarchy of classes possibly usable starting from some root method using quad form. Native methods are not analyzed.

Version:
$Id: QuadClassHierarchy.java,v 1.14 2007/03/23 17:49:42 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
Serialized Form

Constructor Summary
QuadClassHierarchy(Linker linker, Collection roots, HCodeFactory hcf)
          Creates a ClassHierarchy of all classes reachable/usable from HMethods in the roots Collection.
 
Method Summary
 Set<HMethod> callableMethods()
          Returns set of all callable methods.
 Set<HClass> children(HClass c)
          Returns the set of all usable/reachable children of an HClass.
 Set<HClass> classes()
          Returns the set of all reachable/usable classes.
 Set<HClass> instantiatedClasses()
          Returns the set of all classes instantiated.
 String toString()
          Returns a human-readable representation of the hierarchy.
 
Methods inherited from class harpoon.Analysis.ClassHierarchy
overrides, overrides
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QuadClassHierarchy

public QuadClassHierarchy(Linker linker,
                          Collection roots,
                          HCodeFactory hcf)
Creates a ClassHierarchy of all classes reachable/usable from HMethods in the roots Collection. HClasses included in roots are guaranteed to be included in the classes() set of this class hierarchy, but they may not be included in the instantiatedClasses set (if an instantiation instruction is not found for them). To explicitly include an instantiated class in the hierarchy, add a constructor or non-static method of that class to the roots Collection.

hcf must be a code factory that generates quad form.

Method Detail

callableMethods

public Set<HMethod> callableMethods()
Returns set of all callable methods.

Specified by:
callableMethods in class ClassHierarchy
Returns:
Set of HMethods.

children

public Set<HClass> children(HClass c)
Description copied from class: ClassHierarchy
Returns the set of all usable/reachable children of an HClass. For an interface class c, the children include all reachable classes which implement it as well as any reachable interfaces which extend it. For a non-interface class, children are all reachable subclasses. Note: this method deals with direct children; i.e., it doesn't return transitive (more than one level) subclassing children. The result should be complementary to the result of the c.parents() method: the parents of any class c returned by children(cc) should include cc.

Specified by:
children in class ClassHierarchy

classes

public Set<HClass> classes()
Description copied from class: ClassHierarchy
Returns the set of all reachable/usable classes.

More technically, this method returns the smallest set C that satisfies the following rules:

Intuitively, these are the classes Flex will generate code for. E.g., if a static method is called, the PreciseC backend of Flex will generate a .c file for its declaring class, including the code for that static method (but not including the code for other method that are not invoked by the compiled application).

Specified by:
classes in class ClassHierarchy

instantiatedClasses

public Set<HClass> instantiatedClasses()
Returns the set of all classes instantiated. (Actually only the list of classes for which an explicit NEW is found; should include list of classes that are automatically created by JVM!)

Specified by:
instantiatedClasses in class ClassHierarchy

toString

public String toString()
Returns a human-readable representation of the hierarchy.

Overrides:
toString in class Object