Queue<FlagState> toprocess;
TagAnalysis taganalysis;
Hashtable cdtorootnodes;
+ Hashtable tdToFEdges;
TypeUtil typeutil;
/* Adding the flags of the super class */
- if (cd.getSuper()!=null) {
- ClassDescriptor superdesc=cd.getSuperDesc();
-
- for(Iterator it_cflags=superdesc.getFlags();it_cflags.hasNext();) {
+ ClassDescriptor tmp=cd;
+ while(tmp!=null) {
+ for(Iterator it_cflags=tmp.getFlags();it_cflags.hasNext();) {
FlagDescriptor fd = (FlagDescriptor)it_cflags.next();
vFlags.add(fd);
}
+ tmp=tmp.getSuperDesc();
}
- for(Iterator it_cflags=cd.getFlags();it_cflags.hasNext();) {
- FlagDescriptor fd = (FlagDescriptor)it_cflags.next();
- vFlags.add(fd);
- }
if (vFlags.size()!=0) {
flag=new FlagDescriptor[vFlags.size()];
flagstates=new Hashtable();
Hashtable<FlagState,FlagState> sourcenodes;
cdtorootnodes=new Hashtable();
+ tdToFEdges=new Hashtable();
getFlagsfromClasses();
TaskDescriptor td = (TaskDescriptor)it_tasks.next();
String taskname=td.getSymbol();
+ if(!tdToFEdges.containsKey(td)) {
+ tdToFEdges.put(td, new Vector<FEdge>());
+ }
+
/** counter to keep track of the number of parameters (of the
* task being analyzed) that are satisfied by the flagstate.
*/
Set newstates=taganalysis.getFlagStates(td);
for(Iterator fsit=newstates.iterator();fsit.hasNext();) {
FlagState fsnew=(FlagState) fsit.next();
- fsnew.setAsSourceNode();
- fsnew.addAllocatingTask(td);
- ((Vector)cdtorootnodes.get(fsnew.getClassDescriptor())).add(fsnew);
+ System.out.println("SOURCE:"+fsnew);
if (! ((Hashtable<FlagState,FlagState>)flagstates.get(fsnew.getClassDescriptor())).containsKey(fsnew)) {
((Hashtable<FlagState,FlagState>)flagstates.get(fsnew.getClassDescriptor())).put(fsnew, fsnew);
toprocess.add(fsnew);
+ } else {
+ fsnew=((Hashtable<FlagState, FlagState>)flagstates.get(fsnew.getClassDescriptor())).get(fsnew);
+ }
+ fsnew.setAsSourceNode();
+ fsnew.addAllocatingTask(td);
+
+ if(!((Vector)cdtorootnodes.get(fsnew.getClassDescriptor())).contains(fsnew)) {
+ ((Vector)cdtorootnodes.get(fsnew.getClassDescriptor())).add(fsnew);
}
}
if (fn1.kind()==FKind.FlatReturnNode) {
/* Self edge */
FEdge newedge=new FEdge(fs, taskname, td, parameterindex);
+ ((Vector<FEdge>)tdToFEdges.get(td)).add(newedge);
fs.addEdge(newedge);
continue;
} else if (fn1.kind()==FKind.FlatFlagActionNode) {
} else if (ffan.getTaskType() == FlatFlagActionNode.TASKEXIT) {
Vector<FlagState> fsv_taskexit=evalTaskExitNode(ffan,cd,fs,temp);
+ Vector<FlagState> initFStates = ffan.getInitFStates(temp.getType().getClassDesc());
+ if(!initFStates.contains(fs)) {
+ initFStates.addElement(fs);
+ }
+ Vector<FlagState> targetFStates = ffan.getTargetFStates(fs);
for(Enumeration en=fsv_taskexit.elements();en.hasMoreElements();){
FlagState fs_taskexit=(FlagState)en.nextElement();
if (!sourcenodes.containsKey(fs_taskexit)) {
//seen this node already
fs_taskexit=canonicalizeFlagState(sourcenodes,fs_taskexit);
FEdge newedge=new FEdge(fs_taskexit,taskname, td, parameterindex);
+ ((Vector<FEdge>)tdToFEdges.get(td)).add(newedge);
fs.addEdge(newedge);
+
+ if(!targetFStates.contains(fs_taskexit)) {
+ targetFStates.addElement(fs_taskexit);
+ }
}
continue;
}
*/
-private boolean isTaskTrigger_flag(FlagExpressionNode fen,FlagState fs) {
+public static boolean isTaskTrigger_flag(FlagExpressionNode fen,FlagState fs) {
if (fen==null)
return true;
else if (fen instanceof FlagNode)
public void createDOTfile(ClassDescriptor cd) throws java.io.IOException {
File dotfile_flagstates= new File("graph"+cd.getSymbol()+".dot");
- FileOutputStream dotstream=new FileOutputStream(dotfile_flagstates,true);
+ FileOutputStream dotstream=new FileOutputStream(dotfile_flagstates,false);
FlagState.DOTVisitor.visit(dotstream,((Hashtable)flagstates.get(cd)).values());
}
public Vector getRootNodes(ClassDescriptor cd){
return (Vector)cdtorootnodes.get(cd);
}
+
+ public Vector getFEdgesFromTD(TaskDescriptor td) {
+ return (Vector)tdToFEdges.get(td);
+ }
}