--- /dev/null
+package Analysis.TaskStateAnalysis;
+import IR.*;
+import Analysis.TaskStateAnalysis.*;
+import IR.Tree.*;
+import IR.Flat.*;
+import java.util.*;
+import Util.Edge;
+
+
+public class TEdge extends Edge{
+
+ private String target;
+
+ public TEdge(TaskNode target){
+ super(target);
+ }
+
+
+
+ public int hashCode(){
+ return target.hashCode()^target.toString().hashCode();
+ }
+
+
+ public boolean equals(Object o) {
+ if (o instanceof TEdge) {
+ TEdge e=(TEdge)o;
+ return e.target.equals(target);
+ }
+ return false;
+ }
+
+
+}
Hashtable flags;
Hashtable extern_flags;
Queue<FlagState> toprocess;
+
TypeUtil typeutil;
/**
//seen this node already
fs_taskexit=canonicalizeFlagState(sourcenodes,fs_taskexit);
FEdge newedge=new FEdge(fs_taskexit,taskname);
+ //FEdge newedge=new FEdge(fs_taskexit,td);
fs.addEdge(newedge);
}
}
*/
public void createDOTfile(ClassDescriptor cd) throws java.io.IOException {
- File dotfile= new File("graph"+cd.getSymbol()+".dot");
- FileOutputStream dotstream=new FileOutputStream(dotfile,true);
+ File dotfile_flagstates= new File("graph"+cd.getSymbol()+".dot");
+ FileOutputStream dotstream=new FileOutputStream(dotfile_flagstates,true);
FlagState.DOTVisitor.visit(dotstream,((Hashtable)flagstates.get(cd)).values());
+
+ File dotfile_tasknodes=new File("graph"+cd.getSymbol()+"_task.dot");
+ dotstream=new FileOutputStream(dotfile_tasknodes,true);
+ TaskNode.DOTVisitor.visit(dotstream,(produceTaskNodes((Hashtable)flagstates.get(cd))).values());
}
fs.addEdge(new FEdge(fstemp,"Runtime"));
}
}
+
+ private TaskNode canonicalizeTaskNode(Hashtable nodes, TaskNode node){
+ if (nodes.containsKey(node))
+ return (TaskNode)nodes.get(node);
+ else{
+ nodes.put(node,node);
+ return (TaskNode)node;
+ }
+ }
+
+ public Hashtable produceTaskNodes(Hashtable<FlagState,FlagState> fsnodes){
+
+ Hashtable<TaskNode,TaskNode> tasknodes=new Hashtable<TaskNode,TaskNode>();
+ for(Enumeration en=fsnodes.keys();en.hasMoreElements();){
+ FlagState fs=(FlagState)en.nextElement();
+
+ Iterator it_inedges=fs.inedges();
+ TaskNode tn;
+ do{
+ if (!fs.inedges().hasNext()){
+ tn=new TaskNode("Start Node");
+ }else{
+ FEdge inedge=(FEdge)it_inedges.next();
+ tn=new TaskNode(inedge.getLabel());
+ }
+ if(fs.edges().hasNext()){
+ tn=(TaskNode)canonicalizeTaskNode(tasknodes, tn);
+ for (Iterator it_edges=fs.edges();it_edges.hasNext();){
+ TaskNode target=new TaskNode(((FEdge)it_edges.next()).getLabel());
+ target=(TaskNode)canonicalizeTaskNode(tasknodes,target);
+ tn.addEdge(new TEdge(target));
+ }
+ }
+ }while(it_inedges.hasNext());
+ }
+ return tasknodes;
+ }
+
}
--- /dev/null
+package Analysis.TaskStateAnalysis;
+import Analysis.TaskStateAnalysis.*;
+import IR.*;
+import IR.Tree.*;
+import IR.Flat.*;
+import java.util.*;
+import java.io.*;
+import Util.GraphNode;
+
+public class TaskNode extends GraphNode {
+
+ private final String name;
+ private int uid;
+ private static int nodeid=0;
+
+ public void setOption(String option) {
+ this.nodeoption=","+option;
+ }
+
+ /**Class Constructor
+ * Creates a new TaskNode using the TaskDescriptor.
+ * @param tasknode TaskDescriptor
+ */
+ public TaskNode(String name){
+ this.name=name;
+ this.uid=TaskNode.nodeid++;
+ }
+
+ /**Returns the string representation of the node
+ * @return string representation of the tasknode (e.g "Task foo")
+ */
+ public String getTextLabel() {
+ return "Task "+name;
+ }
+
+ public String getLabel() {
+ return "N"+uid;
+ }
+
+
+ /**toString method.
+ * @return string representation of the tasknode (e.g "Task foo")
+ */
+ public String toString(){
+ return getTextLabel();
+ }
+
+ public int hashCode(){
+ return name.hashCode();
+
+ }
+
+ public boolean equals(Object o) {
+ if (o instanceof TaskNode) {
+ TaskNode tn=(TaskNode)o;
+ return (tn.name.equals(name));
+ }
+ return false;
+ }
+}
+
+
+