return virtReadSet;
}
- // who are the parent and siblings?
+ // who can be the alternate sources? Your siblings. Your parent.
+ // your parent's siblings. Your parent's parent and its siblings, etc.
+ // So find your ancestors and grab siblings along the way.
Set<FlatSESEEnterNode> alternateSESEs = new HashSet<FlatSESEEnterNode>();
- Iterator<FlatSESEEnterNode> childItr;
- FlatSESEEnterNode parent = exiter.getLocalParent();
-
- if( parent == null ) {
- // when some caller task is the exiter's parent, the siblings
- // of the exiter are other local root tasks
- parent = rblockRel.getCallerProxySESE();
- childItr = rblockRel.getLocalRootSESEs( exiter.getfmEnclosing() ).iterator();
-
- } else {
- // otherwise, the siblings are locally-defined
- childItr = parent.getLocalChildren().iterator();
- }
-
- alternateSESEs.add( parent );
- while( childItr.hasNext() ) {
- FlatSESEEnterNode sibling = childItr.next();
- if( !sibling.equals( exiter ) ) {
+ FlatSESEEnterNode ancestor = exiter;
+ boolean findMore = true;
+
+ while( findMore ) {
+ // first move up to the next ancestor
+ ancestor = ancestor.getLocalParent();
+ Iterator<FlatSESEEnterNode> childItr;
+
+ if( ancestor == null ) {
+ // when some caller task is the next parent, the siblings
+ // of the current task are other local root tasks
+ ancestor = rblockRel.getCallerProxySESE();
+ childItr = rblockRel.getLocalRootSESEs( exiter.getfmEnclosing() ).iterator();
+ findMore = false;
+ } else {
+ // otherwise, the siblings are locally-defined
+ childItr = ancestor.getLocalChildren().iterator();
+
+ // and there is no further ancestry beyond the main task
+ if( ancestor.equals( rblockRel.getMainSESE() ) ) {
+ findMore = false;
+ }
+ }
+
+ // this ancestor and its children are valid alternate sources
+ alternateSESEs.add( ancestor );
+ while( childItr.hasNext() ) {
+ FlatSESEEnterNode sibling = childItr.next();
alternateSESEs.add( sibling );
}
}
+
// VSTs to remove if they are alternate sources for exiter VSTs
// whose variables will become virtual reads
while( vstItr.hasNext() ) {
VariableSourceToken vstExiterSrc = vstItr.next();
- // only interested in tokens that come from our current instance
+ // only interested in sources from our current instance
if( vstExiterSrc.getAge() != 0 ) {
continue;
}
forRemoval.add( vstPossibleOtherSrc );
} else if( alternateSESEs.contains( vstPossibleOtherSrc.getSESE() ) ) {
- // this is an alternate source from parent or sibling
+ // this is an alternate source from ancestor or ancestor's sibling
virtReadSet.add( refVar );
forRemoval.add( vstPossibleOtherSrc );