|
ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectescjava.backpred.FindContributors
This class is responsible for determining the contributors to a given TypeSig or RoutineDecl.
The contributors are divided into a set of TypeSigs, a set of Invariants, and a set of Fields.
Field Summary | |
private Set |
contributorFields
The set of fields (elementType FieldDecl) we've determined to be contributors so far. |
private Set |
contributorInvariants
The set of invariants (elementType ExprDeclPragmas) we've determined to be contributors so far. |
private Set |
contributorTypes
The set of TypeSigs we've determined to be contributors so far. |
(package private) java.util.Hashtable |
fieldToPossible
A mapping from fields (FieldDecls) to possible invariant contributors (ExprDeclPragmaVec). |
TypeSig |
originType
Our origin type; used to determine visibility and accessibility when needed. |
int |
preFieldMode
|
Set |
preFields
|
private Set |
visitedRoutines
The set of routines visited so far. |
Constructor Summary | |
FindContributors(RoutineDecl rd)
Generate the contributors for a given RoutineDecl. |
|
FindContributors(TypeSig T)
Generate the contributors for a given TypeSig. |
Method Summary | |
private void |
addField(FieldDecl fd)
Add a given field to contributorFields, maintaining all the closure properties. |
private void |
addImplicitConstructorRefs(ConstructorDecl cd,
FieldDeclVec fields,
boolean addTypes,
java.util.LinkedList visited)
Add implicit references from a ConstructorDecl that do not appear in Java code or via backedges as per walk(,,). |
private void |
addInvariant(ExprDeclPragma J)
Add a given invariant to contributorInvarints, maintaining all closure properties. |
private void |
addPossibleInvariant(ExprDeclPragma J)
Add a possible invariant contributor to either fieldToPossible or contributorInvariants as approperiate, maintaining all closure properties. |
private void |
addPossibleMentions(FieldDecl fd,
ExprDeclPragma J)
Add the mapping (fd, J) to fieldToPossible. |
private void |
addType(Type T)
Add the TypeSigs mentioned explicitly in a given Type to contributorTypes, maintaining all the closure properties. |
private void |
backedgeToGenericVarDecl(GenericVarDecl decl,
FieldDeclVec fields,
boolean addTypes,
java.util.LinkedList visited)
Calculate the fields and types "mentioned" by a backedge to a GenericVarDecl and then add them as per walk(,,). |
private void |
backedgeToRoutineDecl(RoutineDecl rd,
FieldDeclVec fields,
boolean addTypes,
int inlined,
java.util.LinkedList visited)
Calculate the fields and types "mentioned" by a backedge to a RoutineDecl and then add them as per walk(,,). |
java.util.Enumeration |
fields()
Enumerate the field contributors |
private FieldDeclVec |
fieldsInvariantMentions(ExprDeclPragma J)
Returns the set of fields that a given invariant mentions. |
java.util.Enumeration |
invariants()
Enumerate the invariant contributors |
private boolean |
isNonRecursiveHelperInvocation(RoutineDecl r)
Returns true if and only if r is a helper
routine that has not been visited by this FindContributor
object. |
(package private) void |
typecheck(TypeSig sig)
Make sure a given TypeSig has been type checked, type checking it if necessary. |
java.util.Enumeration |
typeSigs()
Enumerate the TypeSig contributors |
private void |
walk(ASTNode N)
Walks a given ASTNode, adding all the types it "mentions" via addType and adding all the fields it "mentions" via addField. |
private void |
walk(ASTNode N,
FieldDeclVec fields,
boolean addTypes,
java.util.LinkedList visited)
Walks a given ASTNode, finding all the types it "mentions" and all the fields it "mentions". |
private void |
walkInstanceInitialier(TypeDecl td,
FieldDeclVec fields,
boolean addTypes,
java.util.LinkedList visited)
Walk the implicit instance initializer code for a given TypeDecl, excluding any field initializations of superinterface fields. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public TypeSig originType
private Set visitedRoutines
private Set contributorTypes
Invariant: This set is closed under taking supertypes
private Set contributorInvariants
Closure Property: walk(-) has been called on each of these invariants.
private Set contributorFields
Closure Property: all invariants J that are declared in types in contributorTypes and "mention the field" f for f a field in contributorFields are members of contributorInvariants
public int preFieldMode
public Set preFields
java.util.Hashtable fieldToPossible
(An invariant is a possible contributor if it is declared in a type of contributorTypes.) Invariant: if (f,J) in fieldToPossible then the invariant J "mentions the field" f and J is a possible invariant contributor Closure property: if J is possible invariant contributor, J not in contributorInvariants, and J "mentions the field" f, then (f,J) is in fieldToPossible.
Constructor Detail |
public FindContributors(TypeSig T)
The originType is taken to be that Typesig.
Precondition: T must have been typechecked.
Note: in the process of locating contributors, FindContributors may type check additional types leading possibly to type errors. If such error(s) occur, a fatal error is reproted.
public FindContributors(RoutineDecl rd)
The originType is taken to be the type declaring that RoutineDecl.
Precondition: the type declaring rd must have been typechecked.
Note: in the process of locating contributors, FindContributors may type check additional types leading possibly to type errors. If such error(s) occur, a fatal error is reproted.
Method Detail |
public java.util.Enumeration typeSigs()
public java.util.Enumeration invariants()
public java.util.Enumeration fields()
private void addType(Type T)
Precondition: T has been resolved.
private void addField(FieldDecl fd)
private void addPossibleMentions(FieldDecl fd, ExprDeclPragma J)
private void addPossibleInvariant(ExprDeclPragma J)
Precondition: J has been type checked.
private void addInvariant(ExprDeclPragma J)
Precondition: J has been type checked.
private void walk(ASTNode N)
Precondition: N has been typechecked. WARNING: N is assumed to have no free local or parameter varables.
private FieldDeclVec fieldsInvariantMentions(ExprDeclPragma J)
Precondition: J must be an invariant, J must be typechecked.
private void walk(ASTNode N, FieldDeclVec fields, boolean addTypes, java.util.LinkedList visited)
If fields is null, the fields mentioned are added via addField; otherwise, they are added to fields directly.
If addTypes is true, the types mentioned are added via addType.
Precondition: N has been typechecked.
private boolean isNonRecursiveHelperInvocation(RoutineDecl r)
true
if and only if r
is a helper
routine that has not been visited by this FindContributor
object.
private void addImplicitConstructorRefs(ConstructorDecl cd, FieldDeclVec fields, boolean addTypes, java.util.LinkedList visited)
private void walkInstanceInitialier(TypeDecl td, FieldDeclVec fields, boolean addTypes, java.util.LinkedList visited)
E.g., f_1 = 0; ...; f_3 =
private void backedgeToGenericVarDecl(GenericVarDecl decl, FieldDeclVec fields, boolean addTypes, java.util.LinkedList visited)
private void backedgeToRoutineDecl(RoutineDecl rd, FieldDeclVec fields, boolean addTypes, int inlined, java.util.LinkedList visited)
inlined
is one of: 0 (not an inlined routine),
1 (an inlined helper routine), or 2 (a routine inlined for
a reason other than being a helper). (Why this complication,
why not just use a boolean field "inlined"? By distinguishing
cases 1 and 2, one can write a nice run-time assert inside the
implementation of this method.)
void typecheck(TypeSig sig)
Throws a fatal error if a type error occurs while checking sig.
|
ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |