harpoon.Analysis
Class ClassHierarchy

java.lang.Object
  extended by harpoon.Analysis.ClassHierarchy
Direct Known Subclasses:
QuadClassHierarchy

public abstract class ClassHierarchy
extends Object

A ClassHierarchy enumerates reachable/usable classes and callable methods. A method is callable if the execution of the compiled application may invoke that method (see callableMethods() for more info); these are the methods that Flex absolutely has to compile. To understand which classes are reachable/usable, please see classes().

Version:
$Id: ClassHierarchy.java,v 1.11 2006/01/07 15:10:27 salcianu Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>

Constructor Summary
ClassHierarchy()
           
 
Method Summary
abstract  Set<HMethod> callableMethods()
          Returns the set of all callable methods.
abstract  Set<HClass> children(HClass c)
          Returns the set of all usable/reachable children of an HClass.
abstract  Set<HClass> classes()
          Returns the set of all reachable/usable classes.
abstract  Set<HClass> instantiatedClasses()
          Returns the set of all instantiated classes.
 Set<HMethod> overrides(HClass hc, HMethod hm, boolean all)
          Returns the set of methods, excluding hm, declared in classes which are instances of hc, which override hm.
 Set<HMethod> overrides(HMethod hm)
          Returns a set of methods in the hierarchy (not necessary reachable methods) which override the given method hm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassHierarchy

public ClassHierarchy()
Method Detail

children

public abstract Set<HClass> children(HClass c)
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.


overrides

public final Set<HMethod> overrides(HMethod hm)
Returns a set of methods in the hierarchy (not necessary reachable methods) which override the given method hm. The set does not include hm and is only one level deep; invoke overrides() again on each member of the returned set to find the rest of the possible overriding methods.

Note however that interface methods may introduce some imprecision: in particular, for some hm2 in overrides(hm1) (where hm1 is an interface method), hm2.getDeclaringClass() may not implement the interface hm1.getDeclaringClass(). For example, ListIterator.next() may be implemented by class A that does not implement the full ListIterator interface; class B (a subclass of A which does not override A.next()) may be the class which implements ListIterator.


overrides

public Set<HMethod> overrides(HClass hc,
                              HMethod hm,
                              boolean all)
Returns the set of methods, excluding hm, declared in classes which are instances of hc, which override hm. If all is true, returns all such methods in the class hierarchy; otherwise returns only the methods which *immediately* override hm.


callableMethods

public abstract Set<HMethod> callableMethods()
Returns the set of all callable methods. A Java method m is callable iff


classes

public abstract Set<HClass> classes()
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).


instantiatedClasses

public abstract Set<HClass> instantiatedClasses()
Returns the set of all instantiated classes. A class is included in this set only if an instance of this class may be created during the execution of the compiled application. This is a subset of the set returned by the classes() method. It includes: