harpoon.Analysis
Class Context<E>
java.lang.Object
harpoon.Analysis.Context<E>
public abstract class Context<E>
- extends Object
A Context object is an opaque representation of a
method's calling context, intended to make it easier to
generalize across context-sensitive and context-insensitive
analyses. The Context consists of the last n
"objects" (call-sites or methods). Only two operations are
defined: we can make a new (empty) context (with a factory; see for
example the GenericContextFactory class), and we can
create a new context by adding another element on to the end of an
existing context. Context-insensitive analyses have a singleton
Context object, which is returned unchanged by the
addElement() call. Usually a n-level context
will be created, where Contexts are represented by an
n-tuple holding the last n items given to
addElement() (last n method calls, call-sites,
etc). Behind the scenes, it will often be desirable to keep a
context cache to avoid creating more than one live object
representing a given context.
Note that, for context-sensitive analyses, there remain two main
flavors of contexts: caller-based, and
call-site-based. A caller-based Context will
pass an HMethod to addElement(), and will
group together all call-sites in this method which share the same
destination. A call-site based Context will pass a
Quads.CALL (or similar IR object) to
addElement(), to distinguish different call-sites
leaving to the same destination method.
- Version:
- $Id: Context.java,v 1.2 2003/06/17 16:44:56 cananian Exp $
- Author:
- C. Scott Ananian <cananian@alumni.princeton.edu>
- See Also:
GenericContextFactory
|
Constructor Summary |
protected |
Context()
|
CONTEXT_INSENSITIVE
public static final Context CONTEXT_INSENSITIVE
CONTEXT_SENSITIVE_1
public static final Context CONTEXT_SENSITIVE_1
CONTEXT_SENSITIVE_2
public static final Context CONTEXT_SENSITIVE_2
Context
protected Context()
addElement
public abstract Context<E> addElement(E o)
- Add a new element to the end of this
Context,
'forgetting' about elements at the start of the Context
if necessary. For context-insensitivity, this method should
return this unmodified. Context-sensitive
analyses may wish to implement a context cache. Or not.
Depends on how long you're planning on keeping those
Context objects around, don't it.
asList
public abstract List<E> asList()
- Return the elements of this
Context as a tuple,
as represented by an unmodifiable List.
This is to support interoperability between different
Context implementations. The object passed to
the allElement() call which created this
Context will be the last element of the
returned List.
The length of this List will usually be bounded by
a small constant.
hashCode
public int hashCode()
- Overrides:
hashCode in class Object
- Returns:
asList().hashCode()
equals
public boolean equals(Object o)
- Overrides:
equals in class Object
- Returns:
true iff the asList()
representations of the two Contexts are
equal.
toString
public String toString()
- Overrides:
toString in class Object
- Returns:
asList().toString()