Bug fixed in BuildCode.
authorwmontaz <wmontaz>
Wed, 15 Aug 2007 00:34:39 +0000 (00:34 +0000)
committerwmontaz <wmontaz>
Wed, 15 Aug 2007 00:34:39 +0000 (00:34 +0000)
First implementation of the optional args in runtime (still buggy).
Test cases added. use the dot files to see to what task structure the test cases correspond to.
TestRuntime contains the test designed for the runtime.
TestStaticAnalysis contains the ones designed for the static Analysis. They don't generate a good c code.

43 files changed:
Robust/src/Analysis/TaskStateAnalysis/OptionalTaskDescriptor.java
Robust/src/Analysis/TaskStateAnalysis/SafetyAnalysis.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/GenericHashtable.c
Robust/src/Runtime/runtime.h
Robust/src/Runtime/task.c
Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime1/Object.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime1/Willy.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime2/Important [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime2/Object.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime2/Willy.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime3/Object.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime3/Willy.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test1/Object.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test1/Willy.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test10/Object.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test10/Willy.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test11/Object.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test11/Willy.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test12/Object.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test12/Willy.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test2/Object.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test2/Willy.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test3/Object.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test3/Willy.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test4/Object.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test4/Willy.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test5/Object.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test5/Willy.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test6/Object.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test6/Willy.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test7/Object.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test7/Willy.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test8/Object.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test8/Willy.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test9/Object.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test9/Willy.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/TestMultiple/Object.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/TestMultiple/Object2.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/TestMultiple/Willy.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/TestTag/Object.java [new file with mode: 0644]
Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/TestTag/Willy.java [new file with mode: 0644]
Robust/src/buildscript

index b4f398127d1b7cec1e6fb39777817efaed195c65..380112ed40f2185196fba0edda76f67b45f8e533 100644 (file)
@@ -28,10 +28,13 @@ public class  OptionalTaskDescriptor{
     public boolean equals(Object o){
        if (o instanceof OptionalTaskDescriptor) {
            OptionalTaskDescriptor otd = (OptionalTaskDescriptor) o;
-           if (this.td.getSymbol().compareTo(otd.td.getSymbol())==0)
+           /*if (this.td.getSymbol().compareTo(otd.td.getSymbol())==0)
                if(this.flagstates.equals(otd.flagstates))
                    if(this.predicate.equals(otd.predicate))
                        return true;
+                       return false;*/
+           if(this.hashCode()==otd.hashCode())
+               return true;
            return false;
        }
        else return false;
index 8ecab55facce414550c4a4b272082568d91cc984..1db990f18e2963136dddb43e7f5882efab9ca763 100644 (file)
@@ -161,12 +161,30 @@ public class SafetyAnalysis {
            safeexecution.put(processedclass, cdhashtable);
                               
        }
-       cleanPredicates();
+       putinoptionaltaskdescriptors();
        printTEST();
 
        
     }
 
+    private void putinoptionaltaskdescriptors(){
+       Enumeration e = safeexecution.keys();
+       while (e.hasMoreElements()) {
+           ClassDescriptor cdtemp=(ClassDescriptor)e.nextElement();
+           optionaltaskdescriptors.get(cdtemp).clear();
+           Hashtable hashtbtemp = safeexecution.get(cdtemp);
+           Enumeration fses = hashtbtemp.keys();
+           while(fses.hasMoreElements()){
+               FlagState fs = (FlagState)fses.nextElement();
+               HashSet availabletasks = (HashSet)hashtbtemp.get(fs);
+               for(Iterator otd_it = availabletasks.iterator(); otd_it.hasNext();){
+                   OptionalTaskDescriptor otd = (OptionalTaskDescriptor)otd_it.next();
+                   optionaltaskdescriptors.get(cdtemp).put(otd, otd);
+               }
+           }
+       }
+    }
+
     private void printTEST(){
        
        Enumeration e = safeexecution.keys();
@@ -370,7 +388,6 @@ public class SafetyAnalysis {
                    HashSet fstemp = new HashSet();
                    fstemp.add(tn.getFS());
                    OptionalTaskDescriptor otd = new OptionalTaskDescriptor(tn.getTD(), fstemp, depth, temppredicate);
-                   //System.out.println("Create Optionaltaskdescriptor number "+otd.getuid()+" hascode "+otd.hashCode());
                    if(optionaltaskdescriptors.get(processedclass).get(otd)!=null){
                        otd = (OptionalTaskDescriptor)((Hashtable)optionaltaskdescriptors.get(processedclass)).get(otd);
                    }
@@ -389,7 +406,6 @@ public class SafetyAnalysis {
                    HashSet fstemp = new HashSet();
                    fstemp.add(tn.getFS());
                    OptionalTaskDescriptor otd = new OptionalTaskDescriptor(tn.getTD(), fstemp, depth, temppredicate);
-                   //System.out.println("Create Optionaltaskdescriptor number "+otd.getuid()+" hascode "+otd.hashCode());
                    if(optionaltaskdescriptors.get(processedclass).get(otd)!=null){
                        otd = (OptionalTaskDescriptor)((Hashtable)optionaltaskdescriptors.get(processedclass)).get(otd);
                    }
@@ -690,14 +706,14 @@ public class SafetyAnalysis {
     
     private HashSet createIntersection( HashSet A, HashSet B){
        HashSet result = new HashSet();
-       HashSet processed = new HashSet();
+       //HashSet processed = new HashSet();
        for(Iterator b_it = B.iterator(); b_it.hasNext();){
            OptionalTaskDescriptor otd_b = (OptionalTaskDescriptor)b_it.next();
            for(Iterator a_it = A.iterator(); a_it.hasNext();){
                OptionalTaskDescriptor otd_a = (OptionalTaskDescriptor)a_it.next();
                if(((String)otd_a.td.getSymbol()).compareTo((String)otd_b.td.getSymbol())==0){
-                   processed.add(otd_a);
-                   processed.add(otd_b);
+                   //processed.add(otd_a);
+                   //processed.add(otd_b);
                    
                    HashSet newfs = new HashSet();
                    newfs.addAll(otd_a.flagstates);
@@ -706,9 +722,9 @@ public class SafetyAnalysis {
                    OptionalTaskDescriptor newotd = new OptionalTaskDescriptor(otd_b.td, newfs, newdepth, combinePredicates(otd_a.predicate, otd_b.predicate));
                    if(optionaltaskdescriptors.get(processedclass).get(newotd)!=null){
                        //System.out.println("OTD found");
-                       //System.out.println("before "+newotd.getuid());
+                       System.out.println("before "+newotd.getuid());
                        newotd = (OptionalTaskDescriptor)((Hashtable)optionaltaskdescriptors.get(processedclass)).get(newotd);
-                       //System.out.println("after "+newotd.getuid());
+                       System.out.println("after "+newotd.getuid());
                    }
                    else optionaltaskdescriptors.get(processedclass).put(newotd, newotd);
                    result.add(newotd);
@@ -716,7 +732,7 @@ public class SafetyAnalysis {
            }
        }
        
-       for(Iterator a_it = A.iterator(); a_it.hasNext();){
+       /*      for(Iterator a_it = A.iterator(); a_it.hasNext();){
            OptionalTaskDescriptor otd = (OptionalTaskDescriptor)a_it.next();
            if(!processed.contains(otd))
                optionaltaskdescriptors.get(processedclass).remove(otd);
@@ -725,7 +741,7 @@ public class SafetyAnalysis {
            OptionalTaskDescriptor otd = (OptionalTaskDescriptor)b_it.next();
            if(!processed.contains(otd))
                optionaltaskdescriptors.get(processedclass).remove(otd);
-       }    
+               }    */
        return result;
     }
 
@@ -862,11 +878,7 @@ public class SafetyAnalysis {
        otd.exitfses=result;
     }
 
-    private void cleanPredicates(){
-       
-    }
-       
-        
+            
 }
 
 
index 647778490febf8441d9f5c3c8f5c6db40fa7dbeb..be5f1ca4679d1153caba54158ebfaeab38812b9c 100644 (file)
@@ -337,6 +337,8 @@ public class BuildCode {
     private void outputClassDeclarations(PrintWriter outclassdefs) {
        if (state.THREAD)
            outclassdefs.println("#include <pthread.h>");
+       if(state.OPTIONAL)
+           outclassdefs.println("#include \"optionalstruct.h\"");
        outclassdefs.println("struct "+arraytype+";");
        /* Start by declaring all structs */
        Iterator it=state.getClassSymbolTable().getDescriptorsIterator();
@@ -356,8 +358,14 @@ public class BuildCode {
        if (state.TASK) {
            outclassdefs.println("  int flag;");
            outclassdefs.println("  void * flagptr;");
-           if(state.OPTIONAL) 
+           if(state.OPTIONAL){
                outclassdefs.println("  int failedstatus;");
+               outclassdefs.println("  int hashcode;");
+               outclassdefs.println("  int numexitfses;");
+               outclassdefs.println("  int * exitfses;");
+               outclassdefs.println("  int numotds;");
+               outclassdefs.println("  struct optionaltaskdescriptor ** otds;");
+           }
        }
        printClassStruct(typeutil.getClass(TypeUtil.ObjectClass), outclassdefs);
        
@@ -801,6 +809,7 @@ public class BuildCode {
     /** Force consistent field ordering between inherited classes. */
 
     private void printClassStruct(ClassDescriptor cn, PrintWriter classdefout) {
+       
        ClassDescriptor sp=cn.getSuperDesc();
        if (sp!=null)
            printClassStruct(sp, classdefout);
@@ -877,7 +886,14 @@ public class BuildCode {
        if (state.TASK) {
            classdefout.println("  int flag;");
            classdefout.println("  void * flagptr;");
-           if (state.OPTIONAL) classdefout.println("  int failedstatus;");
+           if (state.OPTIONAL){
+               classdefout.println("  int failedstatus;");
+               classdefout.println("  int hashcode;");
+               classdefout.println("  int numexitfses;");
+               classdefout.println("  int * exitfses;");
+               classdefout.println("  int numotds;");
+               classdefout.println("  struct optionaltaskdescriptor ** otds;");
+           }
        }
        printClassStruct(cn, classdefout);
        classdefout.println("};\n");
@@ -1850,6 +1866,10 @@ public class BuildCode {
         
         //GENERATE HEADERS
         headers.println("#include \"task.h\"\n\n");
+        headers.println("#ifndef _OPTIONAL_STRUCT_");
+        headers.println("#define _OPTIONAL_STRUCT_");
+        
+        
         
         
         //STRUCT PREDICATEMEMBER
@@ -1860,43 +1880,42 @@ public class BuildCode {
         headers.println("int numtags;");
         headers.println("int * tags;\n};\n\n");
 
-        //STRUCT EXITFLAGSTATE
-        headers.println("struct exitflagstate{");
-        headers.println("int numflags;");
-        headers.println("int * flags;");
-        /*
-          headers.println("int numtags;");
-          headers.println("int * tags;");
-        */
-        headers.println("\n};\n\n");
-        
-        //STRUCT EXITSTATES
+        /*//STRUCT EXITSTATES
         headers.println("struct exitstates{");
-        headers.println("int numexitflagstates;");
-        headers.println("struct exitflagstate * exitflagstatearray;\n};\n\n");
+        headers.println("int numflagstates;");
+        headers.println("int * flagstatearray;\n};\n\n");*///appeared to be useless
 
         //STRUCT OPTIONALTASKDESCRIPTOR
         headers.println("struct optionaltaskdescriptor{");
         headers.println("struct taskdescriptor * task;");
+        headers.println("int numenterflags;");
+        headers.println("int * enterflags;");
         headers.println("int numpredicatemembers;");
-        headers.println("struct predicatemember * predicatememberarray;");
-        headers.println("int numexitstates;");
-        headers.println("struct existates * exitstatesarray;\n};\n\n");
+        headers.println("struct predicatemember ** predicatememberarray;");
+        //headers.println("int numexitstates;");
+        //headers.println("int numTotal;");
+        //headers.println("struct exitstates ** exitstatesarray;\n};\n\n");
+        headers.println("\n};\n\n");
                 
         //STRUCT FSANALYSISWRAPPER
         headers.println("struct fsanalysiswrapper{");
-        headers.println("int numflags;");
-        headers.println("int * flags;");
+        headers.println("int  flags;");
         headers.println("int numtags;");
         headers.println("int * tags;");
         headers.println("int numoptionaltaskdescriptors;");
-        headers.println("struct optionaltaskdescriptor * optionaltaskdescriptorarray;\n};\n\n");
+        headers.println("struct optionaltaskdescriptor ** optionaltaskdescriptorarray;\n};\n\n");
 
         //STRUCT CLASSANALYSISWRAPPER
-        headers.println("struct classanalyiswrapper{");
+        headers.println("struct classanalysiswrapper{");
         headers.println("int type;");
+        headers.println("int numotd;");
+        headers.println("struct optionaltaskdescriptor ** otdarray;");
         headers.println("int numfsanalysiswrappers;");
-        headers.println("struct fsanalysiswrapper * fsanalysiswrapperarray;\n};\n\n");
+        headers.println("struct fsanalysiswrapper ** fsanalysiswrapperarray;\n};\n\n");
+        
+        headers.println("struct classanalysiswrapper * classanalysiswrapperarray[];\n");
+
+       
 
         Iterator taskit=state.getTaskSymbolTable().getDescriptorsIterator();
         while(taskit.hasNext()) {
@@ -1904,23 +1923,34 @@ public class BuildCode {
             headers.println("extern struct taskdescriptor task_"+td.getSafeSymbol()+";");
         }
         
-                                                  
+        
         
         //GENERATE STRUCTS
         output.println("#include \"optionalstruct.h\"\n\n");    
         HashSet processedcd = new HashSet();
        
-
+        int maxotd=0;
         Enumeration e = safeexecution.keys();
         while (e.hasMoreElements()) {
-            
+            int numotd=0;
             //get the class
             ClassDescriptor cdtemp=(ClassDescriptor)e.nextElement();
             Hashtable flaginfo=(Hashtable)flagorder.get(cdtemp);//will be used several times
             
+            //////////////////////////DEBUG
+            System.out.println(cdtemp.getSymbol()+" "+cdtemp.getId());
+            for(Iterator flags = cdtemp.getFlags(); flags.hasNext();){
+                FlagDescriptor flagd = (FlagDescriptor)flags.next();
+                int flagid=1<<((Integer)flaginfo.get(flagd)).intValue();
+                System.out.println(" Flag "+flagd.getSymbol()+" 0x"+Integer.toHexString(flagid)+" int "+flagid);
+            }
+            ///////////////////////////
+            
             //Generate the struct of optionals
             if((Hashtable)optionaltaskdescriptors.get(cdtemp)==null) System.out.println("Was in cd :"+cdtemp.getSymbol());
             Collection c_otd = ((Hashtable)optionaltaskdescriptors.get(cdtemp)).values();
+            numotd = c_otd.size();
+            if(maxotd<numotd) maxotd = numotd; 
             if( !c_otd.isEmpty() ){
                 for(Iterator otd_it = c_otd.iterator(); otd_it.hasNext();){
                     OptionalTaskDescriptor otd = (OptionalTaskDescriptor)otd_it.next();
@@ -1942,9 +1972,7 @@ public class BuildCode {
                             for (Iterator fen_it = fen_hashset.iterator(); fen_it.hasNext();){
                                 FlagExpressionNode fen = (FlagExpressionNode)fen_it.next();
                                 if (fen==null) {
-                                    //output.println("0x0, 0x0 };");
-                                    //numberterms+=1;
-                                }
+                                }    
                                 else {
                                     
                                     DNFFlag dflag=fen.getDNF();
@@ -1983,12 +2011,8 @@ public class BuildCode {
                             for(int j=0;j<tagel.numTags();j++) {
                                 if (j!=0)
                                     output.println(",");
-                                /* for each tag we need */
-                                /* which slot it is */
-                                /* what type it is */
-                                //TagVarDescriptor tvd=(TagVarDescriptor)task.getParameterTable().get(tagel.getName(j));
                                 TempDescriptor tmp=tagel.getTemp(j);
-                                //got rid of slot
+                                //got rid of slot, maybe some improvments to do ???
                                 output.println("/*tagid*/"+state.getTagId(tmp.getTag()));
                             }
                             numtags = tagel.numTags();
@@ -2011,55 +2035,45 @@ public class BuildCode {
                     output.println("struct predicatemember * predicatememberarray_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"[]={");
                     for( int j = 0; j<predicateindex; j++){
                         if( j != predicateindex-1)output.println("&predicatemember_"+j+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+",");
-                        else output.println("&predicatemember_"+j+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"};\n");
+                        else output.println("&predicatemember_"+j+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol());
                     }
+                    output.println("};\n");
 
-                    //generate the struct for possible exitfses
-                    HashSet<HashSet> exitfses = otd.exitfses;
+                    //generate the struct for possible exitfses, appeared to be useless
+                    /*HashSet<HashSet> exitfses = otd.exitfses;
                     int exitindex = 0;
                     int nbexit = exitfses.size();
                     int fsnumber;
                     
                     //iterate through possible exits
+                    int nbtotal=0;
                     for(Iterator exitfseshash = exitfses.iterator(); exitfseshash.hasNext();){
                         HashSet temp_hashset = (HashSet)exitfseshash.next();
                         fsnumber = 0 ;
-                        
+                        output.println("int flag_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"[]={");
                         //iterate through possible FSes corresponding to the exit
                         for(Iterator exfses = temp_hashset.iterator(); exfses.hasNext();){
-                           FlagState fs = (FlagState)exfses.next();
-                           fsnumber++;
-                           output.println("int flags"+fsnumber+"_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"[]={");
-                           int counterflag = 0;
-                           for(Iterator flags = fs.getFlags(); flags.hasNext();){
-                               FlagDescriptor flagd = (FlagDescriptor)flags.next();
-                               int flagid=1<<((Integer)flaginfo.get(flagd)).intValue();
-                               if( flags.hasNext() ) output.print("0x"+Integer.toHexString(flagid)+" /*"+Integer.toBinaryString(flagid)+"*/,");
-                               else  output.print("0x"+Integer.toHexString(flagid)+" /*"+Integer.toBinaryString(flagid)+"*/");
-                               counterflag++;
-                           } 
-                           output.println("};\n");
-                           //do the same for tags;
-                           //maybe not needed because no tag changes tolerated.
-
-                           //store the information into a struct
-                           output.println("struct exitflagstate exitflagstate"+fsnumber+"_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"={");
-                           output.println("/*number of flags*/"+counterflag+",");
-                           output.println("flags"+fsnumber+"_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol());
-                           output.println("};\n");
+                            FlagState fs = (FlagState)exfses.next();
+                            fsnumber++;
+                            nbtotal++;
+                            int flagid=0;
+                            for(Iterator flags = fs.getFlags(); flags.hasNext();){
+                                FlagDescriptor flagd = (FlagDescriptor)flags.next();
+                                int id=1<<((Integer)flaginfo.get(flagd)).intValue();
+                                flagid+=id;
+                            }
+                            if(fsnumber!=1) output.print(",");
+                            output.print(flagid);
+                            //do the same for tags.
+                            //maybe not needed because no tag changes tolerated.
                         }
+                        output.println("};\n");
                         
-                        //store fses corresponding to this exit into an array
-                        output.println("struct exitflagstate * exitflagstatearray"+"_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+" [] = {");
-                        for( int j = 0; j<fsnumber; j++){
-                            if( j != fsnumber-1)output.println("&exitflagstate"+(j+1)+"_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"'");
-                            else output.println("&exitflagstate"+(j+1)+"_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"};\n");
-                        }
                         
                         //store that information in a struct
                         output.println("struct exitstates exitstates"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"={");
-                        output.println("/*number of exitflagstate*/"+fsnumber+",");
-                        output.println("exitflagstatearray"+"_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol());
+                        output.println(fsnumber+",");
+                        output.println("flag_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol());
                         output.println("};\n");
 
                         exitindex++;
@@ -2070,21 +2084,55 @@ public class BuildCode {
                     for( int j = 0; j<nbexit; j++){
                         if( j != nbexit-1)output.println("&exitstates"+j+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+",");
                         else output.println("&exitstates"+j+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"};\n");
+                    }*/
+
+                    int fsnumber = 0 ;
+                    output.println("int enterflag_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"[]={");
+                        //iterate through possible FSes corresponding to the state when entering
+                    for(Iterator fses = otd.flagstates.iterator(); fses.hasNext();){
+                        FlagState fs = (FlagState)fses.next();
+                        fsnumber++;
+                        int flagid=0;
+                        for(Iterator flags = fs.getFlags(); flags.hasNext();){
+                            FlagDescriptor flagd = (FlagDescriptor)flags.next();
+                            int id=1<<((Integer)flaginfo.get(flagd)).intValue();
+                            flagid+=id;
+                        }
+                        if(fsnumber!=1) output.print(",");
+                        output.print(flagid);
+                        //tag information not needed because tag changes are not tolerated.
                     }
-                                    
-                                    
+                    output.println("};\n");
+                    
+                    
                     //generate optionaltaskdescriptor that actually includes exit fses, predicate and the task concerned
                     output.println("struct optionaltaskdescriptor optionaltaskdescriptor_"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"={");
-                    output.println("task_"+otd.td.getSafeSymbol()+",");
+                    output.println("&task_"+otd.td.getSafeSymbol()+",");
+                    output.println("/*number of enter flags*/"+fsnumber+",");
+                    output.println("enterflag_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+",");
                     output.println("/*number of members */"+predicateindex+",");
                     output.println("predicatememberarray_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+",");
-                    output.println("/*number of exit fses */"+nbexit+",");
-                    output.println("exitstatearray_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol());
+                    //output.println("/*number of exitstates */"+nbexit+",");
+                    //output.println("/*total number of fses*/"+nbtotal+",");
+                    //output.println("exitstatesarray_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol());
                     output.println("};\n");
                 }      
             }
             else continue; // if there is no optionals, there is no need to build the rest of the struct 
             
+            output.println("struct optionaltaskdescriptor * otdarray"+cdtemp.getSafeSymbol()+"[]={");
+            c_otd = ((Hashtable)optionaltaskdescriptors.get(cdtemp)).values();
+            int x=0;
+            if( !c_otd.isEmpty() ){
+                for(Iterator otd_it = c_otd.iterator(); otd_it.hasNext();){
+                    OptionalTaskDescriptor otd = (OptionalTaskDescriptor)otd_it.next();
+                    if(x!=0) output.println(",");
+                    x++;
+                    output.println("&optionaltaskdescriptor_"+otd.getuid()+"_"+cdtemp.getSafeSymbol());
+                }
+            }
+            output.println("};\n");
+            
             //get all the possible falgstates reachable by an object
             Hashtable hashtbtemp = safeexecution.get(cdtemp);
             Enumeration fses = hashtbtemp.keys();
@@ -2100,45 +2148,45 @@ public class BuildCode {
                 output.println("struct optionaltaskdescriptor * optionaltaskdescriptorarray_FS"+fscounter+"_"+cdtemp.getSafeSymbol()+"[] = {");
                 for(Iterator mos = availabletasks.iterator(); mos.hasNext();){
                     OptionalTaskDescriptor mm = (OptionalTaskDescriptor)mos.next();
-                    if(!mos.hasNext()) output.println("&optionaltaskdescriptor_"+mm.getuid()+"_"+cdtemp.getSafeSymbol()+"};\n");
+                    if(!mos.hasNext()) output.println("&optionaltaskdescriptor_"+mm.getuid()+"_"+cdtemp.getSafeSymbol());
                     
                     else output.println("&optionaltaskdescriptor_"+mm.getuid()+"_"+cdtemp.getSafeSymbol()+",");
                 }
 
+                output.println("};\n");
+                
                 //process flag information (what the flag after failure is) so we know what optionaltaskdescriptors to choose.
                 
-                output.println("int flags_FS"+fscounter+"_"+cdtemp.getSafeSymbol()+"[]={");
+                int flagid=0;
                 for(Iterator flags = fs.getFlags(); flags.hasNext();){
                     FlagDescriptor flagd = (FlagDescriptor)flags.next();
-                    int flagid=1<<((Integer)flaginfo.get(flagd)).intValue();
-                    if( flags.hasNext() ) output.print("0x"+Integer.toHexString(flagid)+" /*"+Integer.toBinaryString(flagid)+"*/,");
-                    else  output.print("0x"+Integer.toHexString(flagid)+" /*"+Integer.toBinaryString(flagid)+"*/");
-                    
+                    int id=1<<((Integer)flaginfo.get(flagd)).intValue();
+                    flagid+=id;
                 }
+                
+                
                 //process tag information
                 
                 int tagcounter = 0;
-                //TagExpressionList tagel = fs.getTags(); 
-                //output.println("int predicatetags_"+predicateindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"[]={");
-                //BUG...added next line to fix, test with any task program
-                
-                //if (tagel!=null){
-                //    for(int j=0;j<tagel.numTags();j++) {
-                //      if (j!=0)
-                //          output.println(",");
-                //      TempDescriptor tmp=tagel.getTemp(j);
-                //      output.println("/*tagid*/"+state.getTagId(tmp.getTag()));
-                //   }
-                //  numtags = tagel.numTags();
-                //}
-                //output.println("};");
+                boolean first = true;
+                Enumeration tag_enum = fs.getTags(); 
+                output.println("int tags_FS"+fscounter+"_"+cdtemp.getSafeSymbol()+"[]={");
+                while(tag_enum.hasMoreElements()){
+                    tagcounter++;
+                    TagDescriptor tagd = (TagDescriptor)tag_enum.nextElement(); 
+                    if(first==true)
+                        first = false;
+                    else
+                        output.println(", ");
+                    output.println("/*tagid*/"+state.getTagId(tagd));
+                }
+                output.println("};");
                 
                 
                 //Store the result in fsanalysiswrapper
-                output.println("};\n");
+                
                 output.println("struct fsanalysiswrapper fsanalysiswrapper_FS"+fscounter+"_"+cdtemp.getSafeSymbol()+"={");
-                output.println("/* number of flags*/"+fs.numFlags()+",");
-                output.println("flags_FS"+fscounter+"_"+cdtemp.getSafeSymbol()+",");
+                output.println("/*flag*/"+flagid+",");
                 output.println("/* number of tags*/"+tagcounter+",");
                 output.println("tags_FS"+fscounter+"_"+cdtemp.getSafeSymbol()+",");
                 output.println("/* number of optionaltaskdescriptors */"+availabletasks.size()+",");
@@ -2158,12 +2206,14 @@ public class BuildCode {
             //Build the classanalysiswrapper referring to the previous array
             output.println("struct classanalysiswrapper classanalysiswrapper_"+cdtemp.getSafeSymbol()+"={");
             output.println("/*type*/"+cdtemp.getId()+",");
+            output.println("/*numotd*/"+numotd+",");
+            output.println("otdarray"+cdtemp.getSafeSymbol()+",");
             output.println("/* number of fsanalysiswrappers */"+fscounter+",");
             output.println("fsanalysiswrapperarray_"+cdtemp.getSafeSymbol()+"};\n");
             fscounter = 0;
             processedcd.add(cdtemp);
         }
-
+        
         //build an array containing every classes for which code has been build
         output.println("struct classanalysiswrapper * classanalysiswrapperarray[]={");
         for(Iterator classit = processedcd.iterator(); classit.hasNext();){
@@ -2171,7 +2221,13 @@ public class BuildCode {
             if(!classit.hasNext()) output.println("&classanalysiswrapper_"+cdtemp.getSafeSymbol()+"};\n");
             else output.println("&classanalysiswrapper_"+cdtemp.getSafeSymbol()+",");
         }
-        output.println("int numclasses = "+processedcd.size()+";");
+        
+        output.println("int numclasses="+processedcd.size()+";");
+        headers.println("extern numclasses;");
+        output.println("int maxotd="+maxotd+";");
+        headers.println("extern maxotd;");
+        headers.println("#endif");
+       
         
      }
     
index ac50f964979dce195e97ae9e3152170f67d8e539..422d03c5c5e8be33ac0b2759d8e0488bba8c80b7 100755 (executable)
@@ -121,7 +121,7 @@ int gencontains(struct genhashtable *ht, void * key) {
 
 void genfreekey(struct genhashtable *ht, void * key) {
   struct genpointerlist * ptr=ht->bins[genhashfunction(ht,key)];
-
+  if(ptr==NULL) printf("otr is null\n");
   if (((ht->comp_function==NULL)&&(ptr->src==key))||((ht->comp_function!=NULL)&&(*ht->comp_function)(ptr->src,key))) {
     ht->bins[genhashfunction(ht,key)]=ptr->next;
 
index b0500def20c4700d8c549ee537ce099a10bbc02c..c3405ec4a8b2da624fe2c9f92663efa8d9c5d483 100644 (file)
@@ -60,6 +60,7 @@ void createstartupobject();
 #include "SimpleHash.h"
 #include "task.h"
 #include "structdefs.h"
+#include "optionalstruct.h"
 
 void flagorand(void * ptr, int ormask, int andmask);
 void flagorandinit(void * ptr, int ormask, int andmask);
@@ -96,6 +97,7 @@ struct taskparamdescriptor {
   struct taskdescriptor * task;
   int numParameters;
   void ** parameterArray;
+  int containsoptional;
 };
 
 int hashCodetpd(struct taskparamdescriptor *);
index 5e7848c83c61cc379475f20fa93d8f9058ea7f7f..5b811b2693d3d32954a3392b66cd8597c29b0e3e 100644 (file)
@@ -6,7 +6,6 @@
 #include "Queue.h"
 #include "SimpleHash.h"
 #include "GenericHashtable.h"
-#include "optionalstruct.h"
 #include <sys/select.h>
 #include <sys/types.h>
 #include <sys/mman.h>
@@ -28,7 +27,7 @@ struct genhashtable * failedtasks;
 struct taskparamdescriptor * currtpd;
 struct RuntimeHash * forward;
 struct RuntimeHash * reverse;
-
+struct RuntimeHash * exitfsesdata;
 
 int main(int argc, char **argv) {
 #ifdef BOEHM_GC
@@ -45,8 +44,8 @@ int main(int argc, char **argv) {
   /* Create queue of active tasks */
   activetasks=genallocatehashtable((unsigned int (*)(void *)) &hashCodetpd, 
                                   (int (*)(void *,void *)) &comparetpd);
-
-
+  
+  exitfsesdata=allocateRuntimeHash(10);
   /* Process task information */
   processtasks();
 
@@ -86,8 +85,8 @@ void createstartupobject(int argc, char ** argv) {
 
 int hashCodetpd(struct taskparamdescriptor *ftd) {
   int hash=(int)ftd->task;
-  int i;
-  for(i=0;i<ftd->numParameters;i++) {
+  int i;                                               
+  for(i=0;i<ftd->numParameters;i++)
     hash^=(int)ftd->parameterArray[i];
   }
   return hash;
@@ -98,12 +97,11 @@ int comparetpd(struct taskparamdescriptor *ftd1, struct taskparamdescriptor *ftd
   if (ftd1->task!=ftd2->task)
     return 0;
   for(i=0;i<ftd1->numParameters;i++)
-    if (ftd1->parameterArray[i]!=ftd2->parameterArray[i])
+    if(ftd1->parameterArray[i]!=ftd2->parameterArray[i])
       return 0;
   return 1;
 }
 
-
 /* This function sets a tag. */
 #ifdef PRECISE_GC
 void tagset(void *ptr, struct ___Object___ * obj, struct ___TagDescriptor___ * tagd) {
@@ -289,105 +287,511 @@ struct ___TagDescriptor___ * allocate_tag(int index) {
    with the or mask and and's it with the andmask. */
 
 void flagbody(struct ___Object___ *ptr, int flag);
+#ifdef OPTIONAL
+void enqueueoptional(struct ___Object___ * currobj);
+
+struct optionaltaskdescriptor *** makeintersectionotd(int num, struct fsanalysiswrapper ** wrapperarray, int *result){
+  int i,j,k;
+  (*result)=0;
+  struct optionaltaskdescriptor *** bigtmparray = RUNMALLOC(sizeof(struct optionaltaskdescriptor **)*maxotd);
+  struct fsanalysiswrapper * tmpwrapper;
+  struct fsanalysiswrapper * firstwrapper = wrapperarray[0];/*we are sure that num>0*/
+  /*we check if the otd of the first wrapper is contained in all others*/
+  for(i=0; i<firstwrapper->numoptionaltaskdescriptors; i++){
+    struct optionaltaskdescriptor ** tmparray = RUNMALLOC(sizeof(struct optionaltaskdescriptor *) * num);
+    struct optionaltaskdescriptor * otd = firstwrapper->optionaltaskdescriptorarray[i];
+    tmparray[0]=otd;
+    for(j=1; j<num; j++){
+      tmpwrapper = wrapperarray[j];
+      for(k=0; k<tmpwrapper->numoptionaltaskdescriptors; k++){
+       struct optionaltaskdescriptor * tmpotd=tmpwrapper->optionaltaskdescriptorarray[k];
+       if(otd->task->name == tmpotd->task->name){
+         tmparray[j]=tmpotd;
+         goto nextwrapper;
+       }
+       RUNFREE(tmparray);
+       goto nextotd;
+      }
+    nextwrapper:
+      ;
+    }
+    bigtmparray[(*result)]=tmparray;
+    (*result)++;          
+  nextotd:
+    ;
+  }
+  
+  {/*now allocate the good size for otdarray and put the otds*/
+    struct optionaltaskdescriptor *** otdarray = RUNMALLOC(sizeof(struct optionaltaskdescriptor *) * (*result));
+    for(i=0; i<(*result); i++)     
+      otdarray[i]=bigtmparray[i];
+    
+    RUNFREE(bigtmparray);
+    return otdarray;
+  }
+}
+#endif
 
 void flagorand(void * ptr, int ormask, int andmask) {
   int oldflag=((int *)ptr)[1];
   int flag=ormask|oldflag;
-  flag&=andmask;
-  // Not sure why this was necessary
-  //  if (flag==oldflag) /* Don't do anything */
-  //  return;
-  //else 
-  flagbody(ptr, flag);
+#ifdef OPTIONAL
+  struct ___Object___ * obj = (struct ___Object___ *)ptr;
+  if(obj->failedstatus==1){/*store the information about exitfses*/
+    int i,j,counter=0, offset=0;
+    for(i=0; i<obj->numotds; i++){
+      counter+=obj->otds[i]->numenterflags;
+    }
+    obj->numexitfses=counter;
+    if(obj->exitfses!=NULL) RUNFREE(obj->exitfses);
+    obj->exitfses= RUNMALLOC(sizeof(int) * counter);
+    for(i=0; i<obj->numotds; i++){
+      for(j=0; j<obj->otds[i]->numenterflags; j++){
+       oldflag=obj->otds[i]->enterflags[j];
+       flag=ormask|oldflag;
+       flag&=andmask;
+       obj->exitfses[j+offset]=flag;
+      }
+      offset+=obj->otds[i]->numenterflags;
+    }
+    enqueueoptional(ptr);
+  }
+  else
+#endif
+    {
+    flag&=andmask;
+    // Not sure why this was necessary
+    //  if (flag==oldflag) /* Don't do anything */
+    //  return;
+    //else 
+    flagbody(ptr, flag);
+    }
 }
-
 void intflagorand(void * ptr, int ormask, int andmask) {
   int oldflag=((int *)ptr)[1];
   int flag=ormask|oldflag;
-  flag&=andmask;
-  if (flag==oldflag) /* Don't do anything */
-    return;
-  else flagbody(ptr, flag);
+#ifdef OPTIONAL
+  struct ___Object___ * obj = (struct ___Object___ *)ptr;
+  if(obj->failedstatus==1){/*store the information about exitfses*/
+    int i,j,counter=0, offset=0;
+    for(i=0; i<obj->numotds; i++){
+      counter+=obj->otds[i]->numenterflags;
+    }
+    obj->numexitfses=counter;
+    if(obj->exitfses!=NULL) RUNFREE(obj->exitfses);
+    obj->exitfses= RUNMALLOC(sizeof(int) * counter);
+    for(i=0; i<obj->numotds; i++){
+      for(j=0; j<obj->otds[i]->numenterflags; j++){
+       oldflag=obj->otds[i]->enterflags[j];
+       flag=ormask|oldflag;
+       flag&=andmask;
+       obj->exitfses[j+offset]=flag;
+      }
+      offset+=obj->otds[i]->numenterflags;
+    }
+    enqueueoptional(ptr);
+  }
+  else
+#endif
+    {
+    flag&=andmask;
+    if (flag==oldflag) /* Don't do anything */
+      return;
+    else flagbody(ptr, flag);
+    }
 }
 
 void flagorandinit(void * ptr, int ormask, int andmask) {
   int oldflag=((int *)ptr)[1];
   int flag=ormask|oldflag;
-  flag&=andmask;
-  flagbody(ptr,flag);
-}
-
-void flagbody(struct ___Object___ *ptr, int flag) {
-  struct parameterwrapper *flagptr=(struct parameterwrapper *)ptr->flagptr;
-  ptr->flag=flag;
-  
-  /*Remove object from all queues */
-  while(flagptr!=NULL) {
-    struct parameterwrapper *next;
-    struct ___Object___ * tag=ptr->___tags___;
-    RuntimeHashget(flagptr->objectset, (int) ptr, (int *) &next);
-    RuntimeHashremove(flagptr->objectset, (int)ptr, (int) next);
-    flagptr=next;
-  }
-  
-  {
-    struct QueueItem *tmpptr;
-    struct parameterwrapper * parameter=objectqueues[ptr->type];
-    int i;
-    struct parameterwrapper * prevptr=NULL;
-    struct ___Object___ *tagptr=ptr->___tags___;
-      
-    /* Outer loop iterates through all parameter queues an object of
-       this type could be in.  */
-
-    while(parameter!=NULL) {
-      /* Check tags */
-      if (parameter->numbertags>0) {
-       if (tagptr==NULL)
-         goto nextloop;//that means the object has no tag but that param needs tag
-       else if(tagptr->type==TAGTYPE) {//one tag
-         struct ___TagDescriptor___ * tag=(struct ___TagDescriptor___*) tagptr;
-         for(i=0;i<parameter->numbertags;i++) {
-           //slotid is parameter->tagarray[2*i];
-           int tagid=parameter->tagarray[2*i+1];
-           if (tagid!=tagptr->flag)
-             goto nextloop; /*We don't have this tag */          
-         }
-       } else {//multiple tags
-         struct ArrayObject * ao=(struct ArrayObject *) tagptr;
-         for(i=0;i<parameter->numbertags;i++) {
-           //slotid is parameter->tagarray[2*i];
-           int tagid=parameter->tagarray[2*i+1];
-           int j;
-           for(j=0;j<ao->___cachedCode___;j++) {
-             if (tagid==ARRAYGET(ao, struct ___TagDescriptor___*, i)->flag)
-               goto foundtag;
-           }
-           goto nextloop;
-         foundtag:
-           ;
-         }
-       }
-      }
-
-      /* Check flags */
-      for(i=0;i<parameter->numberofterms;i++) {
-       int andmask=parameter->intarray[i*2];
-       int checkmask=parameter->intarray[i*2+1];
-       if ((flag&andmask)==checkmask) {
-         enqueuetasks(parameter, prevptr, ptr);
-         prevptr=parameter;
-         break;
-       }
+#ifdef OPTIONAL
+  struct ___Object___ * obj = (struct ___Object___ *)ptr;
+  if(obj->failedstatus==1){/*store the information about exitfses*/
+    int i,j,counter=0, offset=0;
+    for(i=0; i<obj->numotds; i++){
+      counter+=obj->otds[i]->numenterflags;
+    }
+    obj->numexitfses=counter;
+    if(obj->exitfses!=NULL) RUNFREE(obj->exitfses);
+    obj->exitfses= RUNMALLOC(sizeof(int) * counter);
+    for(i=0; i<obj->numotds; i++){
+      for(j=0; j<obj->otds[i]->numenterflags; j++){
+       oldflag=obj->otds[i]->enterflags[j];
+       flag=ormask|oldflag;
+       flag&=andmask;
+       obj->exitfses[j+offset]=flag;
       }
-    nextloop:
-      parameter=parameter->next;
+      offset+=obj->otds[i]->numenterflags;
     }
-    ptr->flagptr=prevptr;
+    enqueueoptional(ptr);
   }
+  else
+#endif
+    {
+    flag&=andmask;
+    flagbody(ptr,flag);
+    }
 }
-  
-void enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr) {
+
+#ifdef OPTIONAL
+ removeoptionalfromqueues(int hashcode, struct ___Object___ * currobj, struct parameterwrapper * flagptr){/*find a better way to free the useless instances of the object*/
+   while(flagptr!=NULL) {
+     struct ___Object___ *temp=NULL;
+     struct parameterwrapper *ptr;
+     struct RuntimeNode * node = flagptr->objectset->listhead;
+     while(node!=NULL){
+       temp=(struct ___Object___ *)node->key;
+       if(temp->failedstatus==1 && temp->hashcode==currobj->hashcode){
+        if(temp!=currobj){
+          RuntimeHashget(flagptr->objectset, (int)temp, (int *) &ptr);
+          RuntimeHashremove(flagptr->objectset, (int)temp, (int) ptr);//remove from wrapper
+          //delete the fields that wont be removed by the GC.
+          if(temp->exitfses!=NULL) RUNFREE(temp->exitfses);
+          if(temp->otds!=NULL) RUNFREE(temp->otds);
+          goto nextwrapper;
+        }
+        else{
+          //remove from wrapper
+          RuntimeHashget(flagptr->objectset, (int)temp, (int *) &ptr);
+          RuntimeHashremove(flagptr->objectset, (int)temp, (int) ptr);
+          goto nextwrapper;
+        }
+       }
+       node=node->next;
+     }
+   nextwrapper:
+     ;
+     flagptr=flagptr->next;
+   }
+ } 
+#endif
+ void flagbody(struct ___Object___ *ptr, int flag) {
+   struct parameterwrapper *flagptr=(struct parameterwrapper *)ptr->flagptr;
+   ptr->flag=flag;
+   
+   /*Remove object from all queues */
+   while(flagptr!=NULL) {
+     struct parameterwrapper *next;
+     struct ___Object___ * tag=ptr->___tags___;
+     RuntimeHashget(flagptr->objectset, (int) ptr, (int *) &next);
+     RuntimeHashremove(flagptr->objectset, (int)ptr, (int) next);
+     flagptr=next;
+   }
+   
+   {
+     struct QueueItem *tmpptr;
+     struct parameterwrapper * parameter=objectqueues[ptr->type];
+     int i;
+     struct parameterwrapper * prevptr=NULL;
+     struct ___Object___ *tagptr=ptr->___tags___;
+     
+     /* Outer loop iterates through all parameter queues an object of
+       this type could be in.  */
+     
+     while(parameter!=NULL) {
+       /* Check tags */
+       if (parameter->numbertags>0) {
+        if (tagptr==NULL)
+          goto nextloop;//that means the object has no tag but that param needs tag
+        else if(tagptr->type==TAGTYPE) {//one tag
+          struct ___TagDescriptor___ * tag=(struct ___TagDescriptor___*) tagptr;
+          for(i=0;i<parameter->numbertags;i++) {
+            //slotid is parameter->tagarray[2*i];
+            int tagid=parameter->tagarray[2*i+1];
+            if (tagid!=tagptr->flag)
+              goto nextloop; /*We don't have this tag */         
+          }
+        } else {//multiple tags
+          struct ArrayObject * ao=(struct ArrayObject *) tagptr;
+          for(i=0;i<parameter->numbertags;i++) {
+            //slotid is parameter->tagarray[2*i];
+            int tagid=parameter->tagarray[2*i+1];
+            int j;
+            for(j=0;j<ao->___cachedCode___;j++) {
+              if (tagid==ARRAYGET(ao, struct ___TagDescriptor___*, i)->flag)
+                goto foundtag;
+            }
+            goto nextloop;
+          foundtag:
+            ;
+          }
+        }
+       }
+       
+       /* Check flags */
+       for(i=0;i<parameter->numberofterms;i++) {
+        int andmask=parameter->intarray[i*2];
+        int checkmask=parameter->intarray[i*2+1];
+        if ((flag&andmask)==checkmask) {
+          enqueuetasks(parameter, prevptr, ptr);
+          prevptr=parameter;
+          break;
+        }
+       }
+     nextloop:
+       parameter=parameter->next;
+     }
+     ptr->flagptr=prevptr;
+   }
+ }
+#ifdef OPTIONAL
+ void enqueueoptional(struct ___Object___ * currobj){
+   
+   struct classanalysiswrapper * classwrapper=NULL; 
+   struct fsanalysiswrapper * fswrapper=NULL;
+   int counter=0;
+   int numoptionaltaskdescriptors=0;
+   struct optionaltaskdescriptor *** optionaltaskdescriptorarray=NULL;
+   struct fsanalysiswrapper ** goodfswrappersarray=NULL;
+   int numgoodfswrappers=0;
+#ifdef DEBUG
+   if(currobj->numexitfses==0)
+     printf("Handling failed object\nType : %i\nFlag : 0x%x\n", currobj->type, currobj->flag);
+   else{
+     printf("Handling failed object\nType : %i\n", currobj->type);
+     int fscount=0;
+     for(fscount=0; fscount<currobj->numexitfses; fscount++)
+       printf("Flag : 0x%x\n", currobj->exitfses[fscount]);
+   }
+   struct ___Object___ * tagptr = currobj->___tags___;
+   if(tagptr!=NULL){
+     if(tagptr->type==TAGTYPE) {
+       printf("Tag : %i\n", tagptr->flag);}
+     else {
+       struct ArrayObject * ao=(struct ArrayObject *) tagptr;
+       int numbertags = ao->___length___;
+       for(counter=0; counter<numbertags; counter++){
+        printf("Tag : %i\n", ao[counter].flag);
+       } 
+     }
+   }
+#endif   
+   /*set the object as failed*/
+   currobj->failedstatus = 1;
+   
+   /*test what optionaltaskdescriptors are available,
+     find the class corresponding*/
+   
+   for(counter = 0; counter<numclasses; counter++){
+     classwrapper = classanalysiswrapperarray[counter];
+     if(classwrapper == NULL){
+       fprintf(stderr, "ERROR : \"struct classanalysiswrapper * classwraper\" is a NULL pointer\n, Analysis has been skipped, check Runtime/task.c, function enqueueoptional\n");
+       goto nothingtodo;
+     }
+     /*check object type*/
+     if( currobj->type == classwrapper->type)
+       goto classchecked;
+   }
+#ifdef DEBUG
+   printf("No task will use this parameter as optional\n");
+#endif
+   removeoptionalfromqueues(currobj->hashcode,currobj, objectqueues[currobj->type]);
+   goto nothingtodo;
+ classchecked:
+   ;
+#ifdef DEBUG
+   printf("Found the class, search through fses\n");
+#endif       
+   /*search through fses*/
+   goodfswrappersarray = RUNMALLOC(sizeof(struct fsanalysiswrapper *) * classwrapper->numfsanalysiswrappers); /*max number of good fswrappers*/
+   if(goodfswrappersarray == NULL){
+     fprintf(stderr, "ERROR : \"struct fsanalysiswrapper ** goodfswrappersarray\" is a NULL pointer\n, Analysis has been skipped, check Runtime/task.c, function enqueueoptional\n");
+     removeoptionalfromqueues(currobj->hashcode,currobj, objectqueues[currobj->type]);
+     goto nothingtodo;
+   }
+   for(counter = 0; counter<classwrapper->numfsanalysiswrappers; counter++){
+     /*test the FS of the object (include flags and tags)*/
+     fswrapper = classwrapper->fsanalysiswrapperarray[counter];
+     if(fswrapper == NULL){
+       fprintf(stderr, "ERROR : struct fsanalysiswrapper * is a NULL pointer\n, Analysis has been skipped, check Runtime/task.c, function enqueueoptional\n");
+       removeoptionalfromqueues(currobj->hashcode,currobj, objectqueues[currobj->type]);
+       goto nothingtodo;
+     }
+     /*check tags*/
+     struct ___Object___ * tagptr = currobj->___tags___;
+     if(fswrapper->numtags>0){
+       if (tagptr==NULL)
+        goto nextloop;//that means the object has no tag but that param needs tag
+       else if(tagptr->type==TAGTYPE) {//one tag
+        if(fswrapper->numtags!=1) goto nextloop;//we don't have the right number of tags
+        struct ___TagDescriptor___ * tag=(struct ___TagDescriptor___*) tagptr;
+        if (fswrapper->tags[0]!=tagptr->flag)
+          goto nextloop; 
+       }         
+       else {//multiple tags
+        struct ArrayObject * ao=(struct ArrayObject *) tagptr;
+        int tag_counter=0;
+        if(ao->___length___!=fswrapper->numtags) goto nextloop;//we don't have the right number of tags
+        for(tag_counter=0;tag_counter<fswrapper->numtags;tag_counter++) {
+          int tagid=fswrapper->tags[tag_counter];
+          int j;
+          for(j=0;j<ao->___cachedCode___;j++) {
+            if (tagid==ARRAYGET(ao, struct ___TagDescriptor___*, tag_counter)->flag)
+              goto foundtag;
+          }
+          goto nextloop;
+        foundtag:
+          ;                  ;
+        }
+       }
+     }
+     
+     //check flags
+     if(currobj->numexitfses==0){/*first time the method is invoqued*/
+       if( currobj->flag == fswrapper->flags){
+        int otdc;
+        optionaltaskdescriptorarray = RUNMALLOC(sizeof(struct optionaltaskdescriptor **) * fswrapper->numoptionaltaskdescriptors);
+        numoptionaltaskdescriptors = fswrapper->numoptionaltaskdescriptors;
+        for(otdc = 0; otdc<fswrapper->numoptionaltaskdescriptors; otdc++){
+          struct optionaltaskdescriptor ** tmpptr = RUNMALLOC(sizeof(struct optionaltaskdescriptor *));
+          tmpptr[0] = fswrapper->optionaltaskdescriptorarray[otdc];
+          optionaltaskdescriptorarray[otdc] = tmpptr;
+        }
+        numgoodfswrappers=1;
+        goto fschecked;
+       }
+     }
+     else if(currobj->numexitfses==1){/*one fs exit*/
+       if(currobj->exitfses[0] == fswrapper->flags){
+        int otdc;
+        optionaltaskdescriptorarray = RUNMALLOC(sizeof(struct optionaltaskdescriptor **) * fswrapper->numoptionaltaskdescriptors);
+        numoptionaltaskdescriptors = fswrapper->numoptionaltaskdescriptors;
+        for(otdc = 0; otdc<fswrapper->numoptionaltaskdescriptors; otdc++){
+          struct optionaltaskdescriptor ** tmpptr = RUNMALLOC(sizeof(struct optionaltaskdescriptor *));
+          tmpptr[0] = fswrapper->optionaltaskdescriptorarray[otdc];
+          optionaltaskdescriptorarray[otdc] = tmpptr;
+        }
+        numgoodfswrappers=1;
+        goto fschecked;
+       }
+     }
+     else{
+       int fscount=0;
+       for(fscount=0; fscount<currobj->numexitfses; fscount++){
+        
+        if( currobj->exitfses[fscount] == fswrapper->flags ){/*see if the fswraper correspond to one of the fses*/
+          goodfswrappersarray[numgoodfswrappers]=fswrapper;
+          numgoodfswrappers++;
+        }
+       }
+       if(counter==classwrapper->numfsanalysiswrappers-1) goto makeintersection; /*last fswrapper*/
+     }
+   nextloop:
+     ;
+   }
+ nofs:
+   ;
+#ifdef DEBUG
+   printf("FS not found, Nothing more to do\n");
+#endif
+   removeoptionalfromqueues(currobj->hashcode,currobj, objectqueues[currobj->type]);
+   goto nothingtodo;
+ makeintersection:
+   ;
+   if(numgoodfswrappers==0 || numgoodfswrappers==1) goto nofs; /*nothing has been found, we expect more than one wrapper for multiple flags*/
+   optionaltaskdescriptorarray = makeintersectionotd(numgoodfswrappers, goodfswrappersarray, &numoptionaltaskdescriptors);
+   if(optionaltaskdescriptorarray==NULL){
+     fprintf(stderr, "ERROR : struct optionaltaskdescriptor ** is a NULL pointer\n, Analysis has been skipped, check Runtime/task.c, function enqueueoptional\n");
+     goto nothingtodo;
+   }
+   
+  fschecked:
+   ;
+#ifdef DEBUG
+   printf("FS(es) found, intersection created, %i potential tasks :\n", numoptionaltaskdescriptors);
+   
+   
+   /*find the parameterwrapper corresponding to the potential task*/
+   for(counter = 0; counter<numoptionaltaskdescriptors; counter++){
+     struct optionaltaskdescriptor ** tmpptr = optionaltaskdescriptorarray[counter];
+     printf("Task %s\n", tmpptr[0]->task->name);
+   }
+   
+#endif
+   {           
+     struct parameterwrapper * prevptr = NULL;
+     struct parameterwrapper * flagptr = objectqueues[currobj->type];
+     removeoptionalfromqueues(currobj->hashcode,currobj, flagptr);
+     /*process for each otd*/
+     for(counter = 0; counter<numoptionaltaskdescriptors; counter++){
+       struct parameterwrapper * parameter = objectqueues[currobj->type];
+       struct optionaltaskdescriptor ** tmpptr = optionaltaskdescriptorarray[counter];
+       struct optionaltaskdescriptor * currotd = tmpptr[0];
+       int otd_counter=0;
+       while(parameter->task != currotd->task)
+        parameter=parameter->next;
+#ifdef DEBUG
+       printf("found parameterwrapper for task : %s\n", parameter->task->name);
+#endif
+       
+       struct ___Object___ * newobj = RUNMALLOC(sizeof(struct ___Object___));
+       (*newobj)=(*currobj);
+       newobj->numotds=numgoodfswrappers;
+       newobj->otds=RUNMALLOC(sizeof(struct optionaltaskdescriptor *) * numgoodfswrappers);
+       for(otd_counter=0; otd_counter<numgoodfswrappers; otd_counter++){
+        newobj->otds[otd_counter]=tmpptr[otd_counter];
+       }
+       enqueuetasks(parameter, prevptr, newobj);
+       prevptr = parameter;
+       
+     nextotd:
+       ;
+     }
+     
+   }
+ nothingtodo:
+   
+   /*if(currobj->exitfses!=NULL) RUNFREE(currobj->exitfses);
+     if(currobj->otds!=NULL) RUNFREE(currobj->otds);*///there has been a problem just before the program exit, maybe due to the GC ?
+   RUNFREE(optionaltaskdescriptorarray);
+   ;
+ }
+
+ /*we need to check if the object is optional, in this case, test the predicate*/
+ /*here is the code for predicate checking*/
+ /*The code has not been tested. I don't even know if it is working or efficient but it is a lead...
+   if(currotd->numpredicatemembers == 0){
+   printf("this task can be fired\n");
+   goto enqueuetask;
+   }
+   else{
+   int pred_counter;
+   int predicatetrue = 0;
+   for(pred_counter = 0; pred_counter<currotd->numpredicatemembers; pred_counter++){
+   struct predicatemember * currpred = currotd->predicatememberarray[pred_counter];
+   printf("predicate type : %i\n", currpred->type);
+   
+   //test if the predicate member is true
+   struct parameterwrapper * paramwrapper = objectqueues[currpred->type];
+   while(paramwrapper!=NULL){
+   struct RuntimeIterator * it = allocateRuntimeIterator(paramwrapper->objectset->listhead);
+   do{
+   struct ___Object___ * obj = (struct ___Object___ *)Runkey(it);
+   printf("obj type : %i\n", obj->type);
+   if(obj->type == currpred->type){
+   //test the predicate
+   printf("predicate to test\n");
+   //only if good
+   goto enqueuetask;
+   }
+   Runnext(it);
+   }while(RunhasNext(it));
+   paramwrapper=paramwrapper->next;
+   }
+   printf("not the good predicate");
+   //goto endanalysis
+   }
+   //the predicate members have to be all true
+   }*/
+#endif
+ void enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr) {
   void * taskpointerarray[MAXTASKPARAMS];
   int j;
   int numparams=parameter->task->numParameters;
@@ -424,15 +828,23 @@ void enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *p
   
   while(1) {
     /* Enqueue current state */
+    int launch = 0;
     struct taskparamdescriptor *tpd=RUNMALLOC(sizeof(struct taskparamdescriptor));
     tpd->task=task;
     tpd->numParameters=numiterators+1;
     tpd->parameterArray=RUNMALLOC(sizeof(void *)*(numiterators+1));
-    for(j=0;j<=numiterators;j++)
+    for(j=0;j<=numiterators;j++){
+#ifdef OPTIONAL
+#ifdef DEBUG
+      struct ___Object___ * obj = (struct ___Object___ *)taskpointerarray[j];
+      if(obj->failedstatus==1)
+       printf("parameter %i used as optional for task %s\n", obj->type, task->name);
+#endif
+#endif
       tpd->parameterArray[j]=taskpointerarray[j];//store the actual parameters
-    
+    }
     /* Enqueue task */
-    if (!gencontains(failedtasks, tpd)&&!gencontains(activetasks,tpd)) {
+    if ((!gencontains(failedtasks, tpd)&&!gencontains(activetasks,tpd))) {
       genputtable(activetasks, tpd, tpd);
     } else {
       RUNFREE(tpd->parameterArray);
@@ -464,10 +876,14 @@ void enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *p
    arithmatic errors. */
 
 void myhandler(int sig, siginfo_t *info, void *uap) {
+  sigset_t toclear;
 #ifdef DEBUG
   printf("sig=%d\n",sig);
   printf("signal\n");
 #endif
+  sigemptyset(&toclear);
+  sigaddset(&toclear, sig);
+  sigprocmask(SIG_UNBLOCK, &toclear,NULL); 
   longjmp(error_handler,1);
 }
 
@@ -551,8 +967,8 @@ void executetasks() {
       int i;
       currtpd=(struct taskparamdescriptor *) getfirstkey(activetasks);
       genfreekey(activetasks, currtpd);
-
-      /* Check if this task has failed */
+      
+      /* Check if this task has failed, allow a task that contains optional objects to fire */
       if (gencontains(failedtasks, currtpd)) {
        // Free up task parameter descriptor
        RUNFREE(currtpd->parameterArray);
@@ -561,7 +977,7 @@ void executetasks() {
       }
       int numparams=currtpd->task->numParameters;
       int numtotal=currtpd->task->numTotal;
-
+      
       /* Make sure that the parameters are still in the queues */
       for(i=0;i<numparams;i++) {
        void * parameter=currtpd->parameterArray[i];
@@ -569,11 +985,35 @@ void executetasks() {
        struct parameterwrapper *pw=(struct parameterwrapper *) pd->queue;
        int j;
        /* Check that object is still in queue */
-       if (!RuntimeHashcontainskey(pw->objectset, (int) parameter)) {
+#ifdef OPTIONAL
+       struct ___Object___ * obj = (struct ___Object___ *)parameter;
+       if(obj->failedstatus==1){
+         struct ___Object___ *temp=NULL;
+         struct parameterwrapper * ptr;
+         struct RuntimeNode * node = pw->objectset->listhead;
+         while(node!=NULL){
+           temp=(struct ___Object___ *)node->key;
+           if(temp->failedstatus==1 && temp->hashcode==obj->hashcode){
+             if(temp==obj)
+               goto parameterpresent;
+           }
+           node=node->next;
+         }
          RUNFREE(currtpd->parameterArray);
          RUNFREE(currtpd);
          goto newtask;
        }
+       else
+#endif
+       {
+         if (!RuntimeHashcontainskey(pw->objectset, (int) parameter)) {
+           RUNFREE(currtpd->parameterArray);
+           RUNFREE(currtpd);
+           goto newtask;
+         }
+       }
+      parameterpresent:
+       ;
        /* Check that object still has necessary tags */
        for(j=0;j<pd->numbertags;j++) {
          int slotid=pd->tagarray[2*j]+numparams;
@@ -599,15 +1039,31 @@ void executetasks() {
        void ** checkpoint=makecheckpoint(currtpd->task->numParameters, currtpd->parameterArray, forward, reverse);
        int x;
        if (x=setjmp(error_handler)) {
+         int counter;
          /* Recover */
-         int h;
 #ifdef DEBUG
          printf("Fatal Error=%d, Recovering!\n",x);
 #endif
          genputtable(failedtasks,currtpd,currtpd);
          restorecheckpoint(currtpd->task->numParameters, currtpd->parameterArray, checkpoint, forward, reverse);
-         /*where we have to insert the code for optional tasks
-           all the pointers I need are in currtpd->parameterArray */
+
+#ifdef OPTIONAL
+#ifdef DEBUG     
+         printf("%i object(s) restored\n", currtpd->task->numParameters);
+#endif 
+         
+         for(counter=0; counter<currtpd->task->numParameters; counter++){
+           //remove the object from the previous parameterwrapper (maybe not necessary)
+           //do a new instance of the object. It allows the restored object to be used by other tasks as a non optional arg.
+           struct ___Object___ * currobj = RUNMALLOC(sizeof(struct ___Object___));
+           (*currobj)=(*(struct ___Object___ *)currtpd->parameterArray[counter]);
+           currobj->numexitfses = 0;
+           currobj->exitfses = NULL;
+           currobj->otds=NULL;
+           currobj->hashcode=(int)currobj;
+           enqueueoptional( currobj );
+         }
+#endif
          freeRuntimeHash(forward);
          freeRuntimeHash(reverse);
          freemalloc();
@@ -625,13 +1081,13 @@ void executetasks() {
          ((int *)taskpointerarray)[0]=currtpd->task->numParameters;
          taskpointerarray[1]=NULL;
 #endif
-
-         if (debugtask) {
+         if(debugtask){
            printf("ENTER %s count=%d\n",currtpd->task->name, (instaccum-instructioncount));
            ((void (*) (void **)) currtpd->task->taskptr)(taskpointerarray);
            printf("EXIT %s count=%d\n",currtpd->task->name, (instaccum-instructioncount));
          } else
            ((void (*) (void **)) currtpd->task->taskptr)(taskpointerarray);
+           
          freeRuntimeHash(forward);
          freeRuntimeHash(reverse);
          freemalloc();
@@ -645,11 +1101,11 @@ void executetasks() {
     }
   }
 }
-
 /* This function processes an objects tags */
 void processtags(struct parameterdescriptor *pd, int index, struct parameterwrapper *parameter, int * iteratorcount, int *statusarray, int numparams) {
   int i;
-
+  
   for(i=0;i<pd->numbertags;i++) {
     int slotid=pd->tagarray[2*i];
     int tagid=pd->tagarray[2*i+1];
diff --git a/Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime1/Object.java b/Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime1/Object.java
new file mode 100644 (file)
index 0000000..db414d5
--- /dev/null
@@ -0,0 +1,37 @@
+public class Test {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+    private int number;
+
+    public void Test(){
+       number=1;
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+    public void decrease(){
+       number--;
+    }
+
+    public int getNumber(){
+       return number;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime1/Willy.java b/Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime1/Willy.java
new file mode 100644 (file)
index 0000000..12e67f2
--- /dev/null
@@ -0,0 +1,59 @@
+
+
+task Startup(StartupObject s {initialstate}){
+    
+    Test o = new Test() {A};
+    
+    taskexit(s {!initialstate});
+    
+}
+
+task ONE(Test o{A}){
+    o.decrease();
+    System.printString("Inside ONE\n");
+    int i = 100/o.getNumber();
+    taskexit(o {!A, B});
+}
+
+task TWO(Test o{B}){
+    System.printString("Inside TWO\n");
+  taskexit(o {!B, C});
+  
+}
+
+task THREE(optional Test o{B}){
+System.printString("Inside THREE\n");
+    taskexit(o {!B, D});
+}
+
+task FOUR(Test o{C}){
+System.printString("Inside FOUR\n");
+    taskexit(o {!C, E});
+    
+    
+}
+
+task FIVE(Test o{D}){
+  System.printString("Inside FIVE\n");
+    taskexit(o {!D, F});
+
+}
+
+task SIX(optional Test o{E}){
+  System.printString("Inside SIX\n");
+    taskexit(o {!E, G});
+
+}
+
+task SEVEN(Test o{F}){
+  System.printString("Inside SEVEN\n");
+    taskexit(o {!F, G});
+
+}
+
+task EIGHT(optional Test o{G}){
+  System.printString("Inside EIGHT\n");
+    taskexit(o {!G, H});
+
+}
+
diff --git a/Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime2/Important b/Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime2/Important
new file mode 100644 (file)
index 0000000..1f80736
--- /dev/null
@@ -0,0 +1 @@
+There is an error probably due to a leak of memory.
diff --git a/Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime2/Object.java b/Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime2/Object.java
new file mode 100644 (file)
index 0000000..db414d5
--- /dev/null
@@ -0,0 +1,37 @@
+public class Test {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+    private int number;
+
+    public void Test(){
+       number=1;
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+    public void decrease(){
+       number--;
+    }
+
+    public int getNumber(){
+       return number;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime2/Willy.java b/Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime2/Willy.java
new file mode 100644 (file)
index 0000000..2b328d1
--- /dev/null
@@ -0,0 +1,72 @@
+
+
+task Startup(StartupObject s {initialstate}){
+    
+    Test o = new Test() {A};
+    
+    taskexit(s {!initialstate});
+    
+}
+
+task ONE(Test o{A}){
+    o.decrease();
+    System.printString("Inside ONE\n");
+    int i = 100/o.getNumber();
+    taskexit(o {!A, B});
+    taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+ System.printString("Inside TWO\n");   
+ if(false) taskexit(o {!B, C});
+ else taskexit(o {!B, D});
+  
+}
+
+/*task THREE(Test o{B}){
+
+    taskexit(o {!B, D});
+    }*/
+
+task FOUR(Test o{C}){
+System.printString("Inside FOUR\n");
+    taskexit(o {!C, E});
+    
+    
+}
+
+task FIVE(optional Test o{D}){
+  System.printString("Inside FIVE\n");
+    taskexit(o {!D, F});
+
+}
+
+task SIX(Test o{E}){
+  System.printString("Inside SIX\n");
+    taskexit(o {!E, G, J});
+
+}
+
+task SEVEN(optional Test o{F}){
+  System.printString("Inside SEVEN\n");
+    taskexit(o {!F, G, K});
+
+}
+
+task EIGHT(optional Test o{G}){
+  System.printString("Inside EIGHT\n");
+    
+    if(false) taskexit(o {!G, H}); 
+    else taskexit(o {!G, I});
+
+}
+
+task NINE(optional Test o{H}){
+System.printString("Inside NINE\n");
+taskexit(o {!H}); 
+}
+task TEN(optional Test o{I}){
+System.printString("Inside TEN\n");
+ if(true) taskexit(o {!I,L }); 
+ else taskexit(o {!I,M });
+}
diff --git a/Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime3/Object.java b/Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime3/Object.java
new file mode 100644 (file)
index 0000000..db414d5
--- /dev/null
@@ -0,0 +1,37 @@
+public class Test {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+    private int number;
+
+    public void Test(){
+       number=1;
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+    public void decrease(){
+       number--;
+    }
+
+    public int getNumber(){
+       return number;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime3/Willy.java b/Robust/src/Tests/OptionalArgsTest/TestRuntime/TestRuntime3/Willy.java
new file mode 100644 (file)
index 0000000..c2db749
--- /dev/null
@@ -0,0 +1,74 @@
+//Same as the previous test but object is not optional
+//for task two. Implies multiple entering flags
+// (tricky part we spoke about, Brian and William)
+
+task Startup(StartupObject s {initialstate}){
+    
+    Test o = new Test() {A};
+    
+    taskexit(s {!initialstate});
+    
+}
+
+task ONE(Test o{A}){
+    o.decrease();
+    System.printString("Inside ONE\n");
+    int i = 100/o.getNumber();
+    taskexit(o {!A, B});
+    taskexit(o {!A, B});
+}
+
+task TWO(Test o{B}){
+ System.printString("Inside TWO\n");   
+ if(false) taskexit(o {!B, C});
+ else taskexit(o {!B, D});
+  
+}
+
+/*task THREE(Test o{B}){
+
+    taskexit(o {!B, D});
+    }*/
+
+task FOUR(Test o{C}){
+System.printString("Inside FOUR\n");
+    taskexit(o {!C, E});
+    
+    
+}
+
+task FIVE(optional Test o{D}){
+  System.printString("Inside FIVE\n");
+    taskexit(o {!D, F});
+
+}
+
+task SIX(Test o{E}){
+  System.printString("Inside SIX\n");
+    taskexit(o {!E, G, J});
+
+}
+
+task SEVEN(optional Test o{F}){
+  System.printString("Inside SEVEN\n");
+    taskexit(o {!F, G, K});
+
+}
+
+task EIGHT(optional Test o{G}){
+  System.printString("Inside EIGHT\n");
+    
+    if(false) taskexit(o {!G, H}); 
+    else taskexit(o {!G, I});
+
+}
+
+task NINE(optional Test o{H}){
+System.printString("Inside NINE\n");
+taskexit(o {!H}); 
+}
+task TEN(optional Test o{I}){
+System.printString("Inside TEN\n");
+ if(true) taskexit(o {!I,L }); 
+ else taskexit(o {!I,M });
+}
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test1/Object.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test1/Object.java
new file mode 100644 (file)
index 0000000..f968cf4
--- /dev/null
@@ -0,0 +1,26 @@
+public class Test {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+
+    public void Test(){
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test1/Willy.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test1/Willy.java
new file mode 100644 (file)
index 0000000..b0f669a
--- /dev/null
@@ -0,0 +1,54 @@
+
+
+task Startup(StartupObject s {initialstate}){
+    
+    Test o = new Test() {A};
+    
+    taskexit(s {!initialstate});
+    
+}
+
+task ONE(optional Test o{A}){
+
+    taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+    
+    taskexit(o {!B, C});
+}
+
+task THREE(optional Test o{C}){
+
+    taskexit(o {!C, D});
+}
+
+task FOUR(optional Test o{D}){
+    
+   taskexit(o {!D, E});
+}
+/*
+task FIVE(optional Test o{D}){
+  
+    taskexit(o {!D, F});
+
+}
+
+task SIX(Test o{E}){
+  
+    taskexit(o {!E, F});
+
+}
+
+task SEVEN(Test o{F}){
+  
+    taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+  
+    taskexit(o {!G, H});
+
+}
+*/
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test10/Object.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test10/Object.java
new file mode 100644 (file)
index 0000000..f968cf4
--- /dev/null
@@ -0,0 +1,26 @@
+public class Test {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+
+    public void Test(){
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test10/Willy.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test10/Willy.java
new file mode 100644 (file)
index 0000000..2e541f6
--- /dev/null
@@ -0,0 +1,58 @@
+
+
+task Startup(StartupObject s {initialstate}){
+    
+    Test o = new Test() {A};
+    
+    taskexit(s {!initialstate});
+    
+}
+
+task ONE(optional Test o{A}){
+
+    taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+    
+  taskexit(o {!B, C});
+  
+}
+
+task THREE(optional Test o{C}){
+
+   taskexit(o {!C, D});
+  
+}
+
+task FOUR(optional Test o{D}){
+
+  taskexit(o {!D, B});
+  
+    
+}
+
+task FIVE(optional Test o{D}){
+  
+    taskexit(o {!D, E});
+
+}
+
+task SIX(optional Test o{E}){
+  
+   if (true) taskexit(o {!E, F});
+
+}
+/*
+task SEVEN(Test o{F}){
+  
+    taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+  
+    taskexit(o {!G, H});
+
+}
+*/
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test11/Object.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test11/Object.java
new file mode 100644 (file)
index 0000000..f968cf4
--- /dev/null
@@ -0,0 +1,26 @@
+public class Test {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+
+    public void Test(){
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test11/Willy.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test11/Willy.java
new file mode 100644 (file)
index 0000000..d797ad8
--- /dev/null
@@ -0,0 +1,60 @@
+
+
+task Startup(StartupObject s {initialstate}){
+    
+    Test o = new Test() {A};
+    
+    taskexit(s {!initialstate});
+    
+}
+
+task ONE(optional Test o{A}){
+
+    taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+    
+ if(o.is()) taskexit(o {!B, C});
+ else taskexit(o {!B, D});
+  
+}
+
+/*task THREE(Test o{B}){
+
+    taskexit(o {!B, D});
+    }*/
+
+task FOUR(optional Test o{C}){
+
+    taskexit(o {!C, E});
+    
+    
+}
+
+task FIVE(optional Test o{D}){
+  
+    taskexit(o {!D, F});
+
+}
+
+task SIX(optional Test o{E}){
+  
+    taskexit(o {!E, G, J});
+
+}
+
+task SEVEN(optional Test o{F}){
+  
+    taskexit(o {!F, G, K});
+
+}
+
+task EIGHT(optional Test o{G}){
+  
+    
+    if(true) taskexit(o {!G, H}); 
+    else taskexit(o {!G, I});
+
+}
+
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test12/Object.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test12/Object.java
new file mode 100644 (file)
index 0000000..f968cf4
--- /dev/null
@@ -0,0 +1,26 @@
+public class Test {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+
+    public void Test(){
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test12/Willy.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test12/Willy.java
new file mode 100644 (file)
index 0000000..df6b90f
--- /dev/null
@@ -0,0 +1,57 @@
+
+
+task Startup(StartupObject s {initialstate}){
+    
+    Test o = new Test() {A};
+    
+    taskexit(s {!initialstate});
+    
+}
+
+task ONE(optional Test o{A}){
+
+    taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+    
+  if(o.is())  taskexit(o {!B, C});
+  else taskexit(o {!B, D});
+}
+
+task THREE(optional Test o{C||D}){
+
+    taskexit(o {!C, !D, E});
+}
+
+task FOUR(optional Test o{C||D}){
+
+    taskexit(o {!C, !D, F});
+    
+    
+}
+/*
+task FIVE(Test o{D}){
+  
+    taskexit(o {!D, F});
+
+}
+
+task SIX(Test o{E}){
+  
+    taskexit(o {!E, F});
+
+}
+
+task SEVEN(Test o{F}){
+  
+    taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+  
+    taskexit(o {!G, H});
+
+}
+*/
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test2/Object.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test2/Object.java
new file mode 100644 (file)
index 0000000..f968cf4
--- /dev/null
@@ -0,0 +1,26 @@
+public class Test {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+
+    public void Test(){
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test2/Willy.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test2/Willy.java
new file mode 100644 (file)
index 0000000..0102d18
--- /dev/null
@@ -0,0 +1,54 @@
+
+
+task Startup(StartupObject s {initialstate}){
+    
+    Test o = new Test() {A};
+    
+    taskexit(s {!initialstate});
+    
+}
+
+task ONE(optional Test o{A}){
+
+    taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+    
+    taskexit(o {!B, C});
+}
+
+task THREE(optional Test o{B}){
+
+    taskexit(o {!B, D});
+}
+
+task FOUR(optional Test o{C}){
+    
+   taskexit(o {!C, E});
+}
+
+task FIVE(optional Test o{D}){
+  
+    taskexit(o {!D, F});
+
+}
+/*
+task SIX(Test o{E}){
+  
+    taskexit(o {!E, F});
+
+}
+
+task SEVEN(Test o{F}){
+  
+    taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+  
+    taskexit(o {!G, H});
+
+}
+*/
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test3/Object.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test3/Object.java
new file mode 100644 (file)
index 0000000..f968cf4
--- /dev/null
@@ -0,0 +1,26 @@
+public class Test {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+
+    public void Test(){
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test3/Willy.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test3/Willy.java
new file mode 100644 (file)
index 0000000..7dc10fe
--- /dev/null
@@ -0,0 +1,56 @@
+
+
+task Startup(StartupObject s {initialstate}){
+    
+    Test o = new Test() {A};
+    
+    taskexit(s {!initialstate});
+    
+}
+
+task ONE(optional Test o{A}){
+
+    taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+    
+    taskexit(o {!B, C});
+}
+
+task THREE(optional Test o{B}){
+
+    taskexit(o {!B, D});
+}
+
+task FOUR(optional Test o{D||C}){
+
+    taskexit(o {!D,!C, F});
+    
+    
+}
+/*
+task FIVE(Test o{D}){
+  
+    taskexit(o {!D, F});
+
+}
+
+task SIX(Test o{E}){
+  
+    taskexit(o {!E, F});
+
+}
+
+task SEVEN(Test o{F}){
+  
+    taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+  
+    taskexit(o {!G, H});
+
+}
+*/
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test4/Object.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test4/Object.java
new file mode 100644 (file)
index 0000000..f968cf4
--- /dev/null
@@ -0,0 +1,26 @@
+public class Test {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+
+    public void Test(){
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test4/Willy.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test4/Willy.java
new file mode 100644 (file)
index 0000000..9d6e8e3
--- /dev/null
@@ -0,0 +1,57 @@
+
+
+task Startup(StartupObject s {initialstate}){
+    
+    Test o = new Test() {A};
+    
+    taskexit(s {!initialstate});
+    
+}
+
+task ONE(optional Test o{A}){
+
+    taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+    
+  if(o.is())  taskexit(o {!B, C});
+  else taskexit(o {!B, D});
+}
+
+task THREE(optional Test o{C}){
+
+    taskexit(o {!C, E});
+}
+
+task FOUR(optional Test o{D}){
+
+    taskexit(o {!D, F});
+    
+    
+}
+/*
+task FIVE(Test o{D}){
+  
+    taskexit(o {!D, F});
+
+}
+
+task SIX(Test o{E}){
+  
+    taskexit(o {!E, F});
+
+}
+
+task SEVEN(Test o{F}){
+  
+    taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+  
+    taskexit(o {!G, H});
+
+}
+*/
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test5/Object.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test5/Object.java
new file mode 100644 (file)
index 0000000..f968cf4
--- /dev/null
@@ -0,0 +1,26 @@
+public class Test {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+
+    public void Test(){
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test5/Willy.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test5/Willy.java
new file mode 100644 (file)
index 0000000..a5c48cb
--- /dev/null
@@ -0,0 +1,57 @@
+
+
+task Startup(StartupObject s {initialstate}){
+    
+    Test o = new Test() {A};
+    
+    taskexit(s {!initialstate});
+    
+}
+
+task ONE(optional Test o{A}){
+
+    taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+    
+  if(o.is())  taskexit(o {!B, C});
+  else taskexit(o {!B, D});
+}
+
+task THREE(optional Test o{C||D}){
+
+    taskexit(o {!C,!D, E});
+}
+/*
+task FOUR(Test o{D}){
+
+    taskexit(o {!D, F});
+    
+    
+}
+
+task FIVE(Test o{D}){
+  
+    taskexit(o {!D, F});
+
+}
+
+task SIX(Test o{E}){
+  
+    taskexit(o {!E, F});
+
+}
+
+task SEVEN(Test o{F}){
+  
+    taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+  
+    taskexit(o {!G, H});
+
+}
+*/
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test6/Object.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test6/Object.java
new file mode 100644 (file)
index 0000000..f968cf4
--- /dev/null
@@ -0,0 +1,26 @@
+public class Test {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+
+    public void Test(){
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test6/Willy.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test6/Willy.java
new file mode 100644 (file)
index 0000000..def1fdc
--- /dev/null
@@ -0,0 +1,57 @@
+
+
+task Startup(StartupObject s {initialstate}){
+    
+    Test o = new Test() {A};
+    
+    taskexit(s {!initialstate});
+    
+}
+
+task ONE(Test o{A}){
+
+    taskexit(o {!A, B});
+}
+
+task TWO(Test o{B}){
+    
+  taskexit(o {!B, C});
+  
+}
+
+task THREE(Test o{B}){
+
+    taskexit(o {!B, D});
+}
+
+task FOUR(Test o{C}){
+
+    taskexit(o {!C, E});
+    
+    
+}
+
+task FIVE(Test o{D}){
+  
+    taskexit(o {!D, F});
+
+}
+
+task SIX(optional Test o{E}){
+  
+    taskexit(o {!E, G});
+
+}
+
+task SEVEN(Test o{F}){
+  
+    taskexit(o {!F, G});
+
+}
+
+task EIGHT(optional Test o{G}){
+  
+    taskexit(o {!G, H});
+
+}
+
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test7/Object.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test7/Object.java
new file mode 100644 (file)
index 0000000..f968cf4
--- /dev/null
@@ -0,0 +1,26 @@
+public class Test {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+
+    public void Test(){
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test7/Willy.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test7/Willy.java
new file mode 100644 (file)
index 0000000..a11c006
--- /dev/null
@@ -0,0 +1,57 @@
+
+
+task Startup(StartupObject s {initialstate}){
+    
+    Test o = new Test() {A};
+    
+    taskexit(s {!initialstate});
+    
+}
+
+task ONE(optional Test o{A}){
+
+    taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+    
+  taskexit(o {!B, C});
+  
+}
+
+task THREE(optional Test o{C}){
+
+    taskexit(o {!C, D});
+}
+
+task FOUR(optional Test o{D}){
+
+    taskexit(o {!D, E});
+    
+    
+}
+
+task FIVE(optional Test o{C}){
+  
+    taskexit(o {C});
+
+}
+/*
+task SIX(Test o{E}){
+  
+    taskexit(o {!E, G});
+
+}
+
+task SEVEN(Test o{F}){
+  
+    taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+  
+    taskexit(o {!G, H});
+
+}
+*/
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test8/Object.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test8/Object.java
new file mode 100644 (file)
index 0000000..f968cf4
--- /dev/null
@@ -0,0 +1,26 @@
+public class Test {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+
+    public void Test(){
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test8/Willy.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test8/Willy.java
new file mode 100644 (file)
index 0000000..afee2b8
--- /dev/null
@@ -0,0 +1,58 @@
+
+
+task Startup(StartupObject s {initialstate}){
+    
+    Test o = new Test() {A};
+    
+    taskexit(s {!initialstate});
+    
+}
+
+task ONE(optional Test o{A}){
+
+    taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+    
+  taskexit(o {!B, C});
+  
+}
+
+task THREE(optional Test o{C}){
+
+   if (true)  taskexit(o {!C, D});
+   else taskexit(o {C});
+}
+
+task FOUR(optional Test o{D}){
+
+    taskexit(o {!D, E});
+    
+    
+}
+/*
+task FIVE(Test o{C}){
+  
+    taskexit(o {C});
+
+}
+
+task SIX(Test o{E}){
+  
+    taskexit(o {!E, G});
+
+}
+
+task SEVEN(Test o{F}){
+  
+    taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+  
+    taskexit(o {!G, H});
+
+}
+*/
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test9/Object.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test9/Object.java
new file mode 100644 (file)
index 0000000..f968cf4
--- /dev/null
@@ -0,0 +1,26 @@
+public class Test {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+
+    public void Test(){
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test9/Willy.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/Test9/Willy.java
new file mode 100644 (file)
index 0000000..3eef20e
--- /dev/null
@@ -0,0 +1,58 @@
+
+
+task Startup(StartupObject s {initialstate}){
+    
+    Test o = new Test() {A};
+    
+    taskexit(s {!initialstate});
+    
+}
+
+task ONE(optional Test o{A}){
+
+    taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+    
+  taskexit(o {!B, C});
+  
+}
+
+task THREE(optional Test o{C}){
+
+   taskexit(o {!C, D});
+  
+}
+
+task FOUR(optional Test o{D}){
+
+  if(true)  taskexit(o {!D, E});
+  else taskexit(o {!D, B});
+    
+}
+
+task FIVE(optional Test o{E}){
+  
+    taskexit(o {!E, F});
+
+}
+/*
+task SIX(Test o{E}){
+  
+    taskexit(o {!E, G});
+
+}
+
+task SEVEN(Test o{F}){
+  
+    taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+  
+    taskexit(o {!G, H});
+
+}
+*/
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/TestMultiple/Object.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/TestMultiple/Object.java
new file mode 100644 (file)
index 0000000..f968cf4
--- /dev/null
@@ -0,0 +1,26 @@
+public class Test {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+
+    public void Test(){
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/TestMultiple/Object2.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/TestMultiple/Object2.java
new file mode 100644 (file)
index 0000000..5374580
--- /dev/null
@@ -0,0 +1,26 @@
+public class Test2 {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+
+    public void Test2(){
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/TestMultiple/Willy.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/TestMultiple/Willy.java
new file mode 100644 (file)
index 0000000..9930da5
--- /dev/null
@@ -0,0 +1,29 @@
+
+
+task Startup(StartupObject s {initialstate}){
+    
+    Test o = new Test() {A};
+    Test2 o2 = new Test2() {G};
+    taskexit(s {!initialstate});
+    
+}
+
+task ONE(Test o{A}){
+
+    taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+    
+    taskexit(o {!B, C});
+}
+
+task THREE(optional Test o{C}, Test2 o2{G}){
+
+    taskexit(o {!C, D});
+}
+
+task FOUR(optional Test o{D}, Test2 o2{G}){
+    
+   taskexit(o {!D, E});
+}
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/TestTag/Object.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/TestTag/Object.java
new file mode 100644 (file)
index 0000000..f968cf4
--- /dev/null
@@ -0,0 +1,26 @@
+public class Test {
+    
+    
+    flag A;
+    flag B;
+    flag C;
+    flag D;
+    flag E;
+    flag F;
+    flag G;
+    flag H;
+    flag I;
+    flag J;
+    flag K;
+    flag L;
+    flag M;
+
+    public void Test(){
+    }
+
+    public boolean is(){
+       return true;
+    }
+
+}
+    
diff --git a/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/TestTag/Willy.java b/Robust/src/Tests/OptionalArgsTest/TestStaticAnalysis/TestTag/Willy.java
new file mode 100644 (file)
index 0000000..e375601
--- /dev/null
@@ -0,0 +1,56 @@
+
+
+task Startup(StartupObject s {initialstate}){
+    tag t =new tag(link);
+    Test o = new Test() {A}{t};
+    taskexit(s {!initialstate});
+    
+}
+
+task ONE(Test o{A}{link l}){
+
+    taskexit(o {!A, B});
+}
+
+task TWO(Test o{B}{link l}){
+    
+  taskexit(o {!B, C});
+  
+}
+
+task THREE(Test o{B}{link l}){
+
+    taskexit(o {!B, D});
+}
+
+task FOUR(Test o{C}{link l}){
+    tag f =new tag(link);
+    taskexit(o {!C, E}{!l, f});
+    
+    
+}
+
+task FIVE(Test o{D}{link l}){
+    tag h =new tag(link);
+    taskexit(o {!D, F}{!l, h});
+
+}
+
+task SIX(optional Test o{E}{link l}){
+  
+    taskexit(o {!E, G});
+
+}
+
+task SEVEN(Test o{F}{link l}){
+  
+    taskexit(o {!F, G});
+
+}
+
+task EIGHT(optional Test o{G}{link l}){
+  
+    taskexit(o {!G, H});
+
+}
+
index 3f4523d01cb846201600995cdc6b247736566c66..1c73bf726b4b30bd08df3a1123ae3bfd015b1ccc 100755 (executable)
@@ -33,6 +33,7 @@ SRCFILES=''
 EXTRAOPTIONS=''
 MAINFILE='a'
 JAVAOPTS=''
+OPTIONALFLAG=false
 
 if [[ -z $1 ]]
 then
@@ -63,6 +64,7 @@ JAVAOPTS="$JAVAOPTS -taskstate"
 elif [[ $1 = '-optional' ]]
 then
 JAVAOPTS="$JAVAOPTS -optional"
+OPTIONALFLAG=true
 elif [[ $1 = '-dmalloc' ]]
 then
 USEDMALLOC=true
@@ -187,6 +189,12 @@ EXTRAOPTIONS="$EXTRAOPTIONS -DTASK"
 FILES="$FILES tmpbuilddirectory/taskdefs.c $ROBUSTROOT/Runtime/checkpoint.c"
 fi
 
+if $OPTIONALFLAG
+then
+EXTRAOPTIONS="$EXTRAOPTIONS -DOPTIONAL"
+FILES="$FILES tmpbuilddirectory/optionalarrays.c"
+fi
+
 if $THREADFLAG
 then
 FILES="$FILES $ROBUSTROOT/Runtime/thread.c"