changes
authorbdemsky <bdemsky>
Wed, 18 Jul 2007 22:15:40 +0000 (22:15 +0000)
committerbdemsky <bdemsky>
Wed, 18 Jul 2007 22:15:40 +0000 (22:15 +0000)
Robust/src/Analysis/TaskStateAnalysis/FlagState.java
Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java

index 78233e15b2b3ef714747dba2fb0a96b70edc74a0..c18f9d9079f82000bd0a7db7e66569b4bf7410b5 100644 (file)
@@ -122,20 +122,15 @@ public class FlagState extends GraphNode {
        if (tags.containsKey(tag)){
            //Code could try to remove flag that doesn't exist
            
-           HashSet newset2=(HashSet)flagstate.clone();
-           Hashtable<TagDescriptor,Integer> newtags2=(Hashtable<TagDescriptor,Integer>)tags.clone();
            switch (tags.get(tag).intValue()){
            case ONETAG:
                newtags1.put(tag,new Integer(MULTITAGS));
-               break;
+               return new FlagState[] {this, new FlagState(newset1, cd, newtags1)};
            case MULTITAGS:
-               newtags1.put(tag,new Integer(MULTITAGS));
-               break;
+               return new FlagState[] {this};
            default:
                throw new Error();
            }
-           return new FlagState[] {new FlagState(newset1,cd,newtags1),
-                                   new FlagState(newset2,cd,newtags2)};
        } else {
            newtags1.put(tag,new Integer(ONETAG));
            return new FlagState[] {new FlagState(newset1,cd,newtags1)};
@@ -143,13 +138,12 @@ public class FlagState extends GraphNode {
     }
 
     public int getTagCount(String tagtype){
-               for (Enumeration en=getTags();en.hasMoreElements();){
-                       TagDescriptor td=(TagDescriptor)en.nextElement();
-                       if (tagtype.equals(td.getSymbol()))
-                               return tags.get(td).intValue();   //returns either ONETAG or MULTITAG
-               }
-               return NOTAGS;
-               
+       for (Enumeration en=getTags();en.hasMoreElements();){
+           TagDescriptor td=(TagDescriptor)en.nextElement();
+           if (tagtype.equals(td.getSymbol()))
+               return tags.get(td).intValue();   //returns either ONETAG or MULTITAG
+       }
+       return NOTAGS;
     }
     
     public FlagState[] clearTag(TagDescriptor tag){
@@ -223,7 +217,7 @@ public class FlagState extends GraphNode {
            newset.remove(fd);
        }
        
-       return new FlagState(newset, cd,newtags);
+       return new FlagState(newset, cd, newtags);
     }
     
     /** Tests for equality of two flagstate objects.
index baf38bccf596df6912a47f882f704d4972c3f812..6da94379bc60418b66f4dbb1f5f18611a13fb679 100644 (file)
@@ -47,7 +47,6 @@ public class TaskAnalysis {
        for(Iterator it_classes=state.getClassSymbolTable().getDescriptorsIterator();it_classes.hasNext();) {
                
            ClassDescriptor cd = (ClassDescriptor)it_classes.next();
-           System.out.println(cd.getSymbol());
            Vector vFlags=new Vector();
            FlagDescriptor flag[];
            int ctr=0;
@@ -59,7 +58,6 @@ public class TaskAnalysis {
                
                for(Iterator it_cflags=superdesc.getFlags();it_cflags.hasNext();) {     
                    FlagDescriptor fd = (FlagDescriptor)it_cflags.next();
-                   System.out.println(fd.toString());
                    vFlags.add(fd);
                }
            }
@@ -106,13 +104,6 @@ public class TaskAnalysis {
            ClassDescriptor cd=(ClassDescriptor)it_classes.next();
            externs=((Integer)extern_flags.get(cd)).intValue();
            FlagDescriptor[] fd=(FlagDescriptor[])flags.get(cd);
-
-           //Debug block
-           System.out.println("Inside taskAnalysis;\n Class:"+ cd.getSymbol());
-           System.out.println("No of externs " + externs);
-           System.out.println("No of flags: "+fd.length);
-           //Debug block
-           
            flagstates.put(cd,new Hashtable<FlagState,FlagState>());
            cdtorootnodes.put(cd,new Vector());
        }       
@@ -147,11 +138,7 @@ public class TaskAnalysis {
        Enumeration e=flagstates.keys();
        
        while (e.hasMoreElements()) {
-           System.out.println("creating dot file");
            ClassDescriptor cdtemp=(ClassDescriptor)e.nextElement();
-           System.out.println((cdtemp.getSymbol()));
-           
-
            createDOTfile(cdtemp);
        }
     }
@@ -172,12 +159,6 @@ private void analyseTasks(FlagState fs) {
        TaskDescriptor td = (TaskDescriptor)it_tasks.next();
        String taskname=td.getSymbol();
        
-       //**Debug***/
-       System.out.println();
-       System.out.println(cd.getSymbol()+" : "+fs.getTextLabel());
-       System.out.println("Task: "+taskname);
-       //***********
-       
        /** counter to keep track of the number of parameters (of the task being analyzed) that 
         *  are satisfied by the flagstate.
         */
@@ -206,10 +187,6 @@ private void analyseTasks(FlagState fs) {
            throw new Error("Illegal Operation: A single flagstate cannot satisfy more than one parameter of a task.");
        
        
-       //** debug
-       System.out.println("Task:" + taskname +" is triggered");        
-       
-       
        Set newstates=taganalysis.getFlagStates(td);
        for(Iterator fsit=newstates.iterator();fsit.hasNext();) {
            FlagState fsnew=(FlagState) fsit.next();
@@ -244,22 +221,15 @@ private void analyseTasks(FlagState fs) {
                        throw new Error("PRE FlagActions not supported");
                    
                } else if (ffan.getTaskType() == FlatFlagActionNode.TASKEXIT) {
-                   //***
-                   System.out.println("TASKEXIT");
-                   //***
-                   
                    Vector<FlagState> fsv_taskexit=evalTaskExitNode(ffan,cd,fs,temp);
-                   
                    for(Enumeration en=fsv_taskexit.elements();en.hasMoreElements();){
                        FlagState fs_taskexit=(FlagState)en.nextElement();
                        if (!sourcenodes.containsKey(fs_taskexit)) {
                            toprocess.add(fs_taskexit);
-                           
                        }
                        //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);
                    }
                    continue;
@@ -360,7 +330,7 @@ private boolean isTaskTrigger_tag(TagExpressionList tel, FlagState fs){
                    FlagState fsworking=(FlagState)en.nextElement();
                    if (!ffan.getTagChange(ttp)){
                        processed.addAll(Arrays.asList(fsworking.clearTag(ttp.getTag())));
-                   }
+                   } else processed.add(fsworking);
                }
            }
        }
@@ -376,12 +346,11 @@ private boolean isTaskTrigger_tag(TagExpressionList tel, FlagState fs){
                    FlagState fsworking=(FlagState)en.nextElement();
                    if (ffan.getTagChange(ttp)){
                        processed.addAll(Arrays.asList(fsworking.setTag(ttp.getTag())));
-                   }
+                   } else processed.add(fsworking);
                }
            }
        }
        return processed;
-       
     }          
     
 
@@ -401,10 +370,9 @@ private boolean isTaskTrigger_tag(TagExpressionList tel, FlagState fs){
     */
     
     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);
-               FlagState.DOTVisitor.visit(dotstream,((Hashtable)flagstates.get(cd)).values());
-               
+       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());
     }
 
     /** Returns the flag states for the class descriptor. */