check in changes
authorbdemsky <bdemsky>
Tue, 15 Aug 2006 21:11:59 +0000 (21:11 +0000)
committerbdemsky <bdemsky>
Tue, 15 Aug 2006 21:11:59 +0000 (21:11 +0000)
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/Flat/TempFlagPair.java
Robust/src/Runtime/runtime.c
Robust/src/Runtime/runtime.h
Robust/src/buildscripttask [new file with mode: 0755]

index 380b2a812dd91c6894f20de28e7ef8e321390419..09679d14b25c23cde5ab8de724fe6dd9a2327840 100644 (file)
@@ -237,12 +237,12 @@ public class BuildCode {
                    DNFFlagAtom dfa=(DNFFlagAtom)term.get(k);
                    FlagDescriptor fd=dfa.getFlag();
                    boolean negated=dfa.getNegated();
-                   int flagid=((Integer)flags.get(fd)).intValue();
+                   int flagid=1<<((Integer)flags.get(fd)).intValue();
                    andmask|=flagid;
                    if (!negated)
                        checkmask|=flagid;
                }
-               output.print(andmask+", "+checkmask);
+               output.print("0x"+Integer.toHexString(andmask)+", 0x"+Integer.toHexString(checkmask));
            }
            output.println("};");
 
@@ -464,8 +464,8 @@ public class BuildCode {
                    FlagDescriptor fd=(FlagDescriptor)superflagit.next();
                    Integer number=(Integer)superflags.get(fd);
                    flags.put(fd, number);
-                   if (number.intValue()>max)
-                       max=number.intValue();
+                   if ((number.intValue()+1)>max)
+                       max=number.intValue()+1;
                }
            }
            
@@ -473,7 +473,7 @@ public class BuildCode {
            while(flagit.hasNext()) {
                FlagDescriptor fd=(FlagDescriptor)flagit.next();
                if (sp==null||!sp.getFlagTable().contains(fd.getSymbol()))
-                   flags.put(fd, new Integer(++max));
+                   flags.put(fd, new Integer(max++));
            }
        }
     }
@@ -486,6 +486,8 @@ public class BuildCode {
        /* Output class structure */
        classdefout.println("struct "+cn.getSafeSymbol()+" {");
        classdefout.println("  int type;");
+       if (cn.hasFlags())
+           classdefout.println("  int flag;");
        printClassStruct(cn, classdefout);
        classdefout.println("};\n");
 
@@ -1051,8 +1053,47 @@ public class BuildCode {
        output.print(")");
     }
 
-    public void generateFlatFlagActionNode(FlatMethod fm, FlatFlagActionNode ffann, PrintWriter output) {
-       output.print("/* FlatFlagActionNode will go here */");
-       
+    public void generateFlatFlagActionNode(FlatMethod fm, FlatFlagActionNode ffan, PrintWriter output) {
+       output.println("/* FlatFlagActionNode */");
+       Hashtable flagandtable=new Hashtable();
+       Hashtable flagortable=new Hashtable();
+
+
+       Iterator flagsit=ffan.getTempFlagPairs();
+       while(flagsit.hasNext()) {
+           TempFlagPair tfp=(TempFlagPair)flagsit.next();
+           TempDescriptor temp=tfp.getTemp();
+           Hashtable flagtable=(Hashtable)flagorder.get(temp.getType().getClassDesc());
+           FlagDescriptor flag=tfp.getFlag();
+           int flagid=1<<((Integer)flagtable.get(flag)).intValue();
+           boolean flagstatus=ffan.getFlagChange(tfp);
+           if (flagstatus) {
+               int mask=0;
+               if (flagortable.containsKey(temp)) {
+                   mask=((Integer)flagortable.get(temp)).intValue();
+               }
+               mask|=flagid;
+               flagortable.put(temp,new Integer(mask));
+           } else {
+               int mask=0xFFFFFFFF;
+               if (flagandtable.containsKey(temp)) {
+                   mask=((Integer)flagandtable.get(temp)).intValue();
+               }
+               mask&=(0xFFFFFFFF^flagid);
+               flagandtable.put(temp,new Integer(mask));
+           }
+       }
+       Iterator orit=flagortable.keySet().iterator();
+       while(orit.hasNext()) {
+           TempDescriptor temp=(TempDescriptor)orit.next();
+           int ormask=((Integer)flagortable.get(temp)).intValue();
+           output.println("flagor("+generateTemp(fm, temp)+", 0x"+Integer.toHexString(ormask)+");");
+       }
+       Iterator andit=flagandtable.keySet().iterator();
+       while(andit.hasNext()) {
+           TempDescriptor temp=(TempDescriptor)andit.next();
+           int andmask=((Integer)flagandtable.get(temp)).intValue();
+           output.println("flagand("+generateTemp(fm, temp)+", 0x"+Integer.toHexString(andmask)+");");
+       }
     }
 }
index c7f4e68ea74b852d3835b91a2b6a3308d6b91829..81edcefc76162a1497564165ff2944fc22c2a436 100644 (file)
@@ -17,6 +17,10 @@ public class TempFlagPair {
        return td;
     }
 
+    public FlagDescriptor getFlag() {
+       return fd;
+    }
+
     public boolean equals(Object o) {
        if (!(o instanceof TempFlagPair))
            return false;
index c91890a9222ab160cd95a20ad04b53aa46dd6c5d..a6e2f6a94b6282b74056b374be9f1ea24007f73d 100644 (file)
@@ -15,6 +15,8 @@ int main(int argc, char **argv) {
   int i;
   /* Allocate startup object */
   struct ___StartupObject___ *startupobject=(struct ___StartupObject___*) allocate_new(STARTUPTYPE);
+  /* Set flag */
+  flagor(startupobject,1);
 
   /* Build array of strings */
   struct ArrayObject * stringarray=allocate_newarray(STRINGARRAYTYPE, argc); 
@@ -23,11 +25,20 @@ int main(int argc, char **argv) {
   for(i=0;i<argc;i++) {
     int length=strlen(argv[i]);
     struct ___String___ *newstring=NewString(argv[i],length);
-    ((void **)(((char *)& stringarray->___length___)+sizeof(int)))[i]=newstring;  
+    ((void **)(((char *)& stringarray->___length___)+sizeof(int)))[i]=newstring;
   }
+  processtasks();
+}
 
+void flagor(void * ptr, int ormask) {
+  ((int *)ptr)[1]|=ormask;
+}
 
+void flagand(void * ptr, int andmask) {
+  ((int *)ptr)[1]&=andmask;
 }
+
+void processtasks();
 #endif
 
 int ___Object______hashcode____(struct ___Object___ * ___this___) {
index eb020ef26b90de9f9e0c567881d96de47e65768b..f9031810488241b5d74a1b28a96b3b8ff4a0c08b 100644 (file)
@@ -10,4 +10,7 @@ struct ___String___ * NewString(char *str,int length);
 
 void failedboundschk();
 void failednullptr();
+void flagor(void * ptr, int ormask);
+void flagand(void * ptr, int andmask);
+
 #endif
diff --git a/Robust/src/buildscripttask b/Robust/src/buildscripttask
new file mode 100755 (executable)
index 0000000..fc37f88
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+ROBUSTROOT=~/research/Robust/src
+MAINFILE=$1
+shift
+mkdir tmpbuilddirectory
+java -cp $ROBUSTROOT/../cup/:$ROBUSTROOT Main.Main -classlibrary $ROBUSTROOT/ClassLibrary/ -dir tmpbuilddirectory -task $@
+gcc -I$ROBUSTROOT/Runtime -Itmpbuilddirectory -O0 -DTASK -g tmpbuilddirectory/methods.c $ROBUSTROOT/Runtime/runtime.c -o $MAINFILE.bin
\ No newline at end of file