Bug fixes
authorbdemsky <bdemsky>
Tue, 1 Aug 2006 22:56:17 +0000 (22:56 +0000)
committerbdemsky <bdemsky>
Tue, 1 Aug 2006 22:56:17 +0000 (22:56 +0000)
Robust/src/IR/Flat/BuildFlat.java
Robust/src/IR/State.java
Robust/src/IR/Tree/BuildIR.java
Robust/src/IR/Tree/SemanticCheck.java
Robust/src/IR/TypeDescriptor.java
Robust/src/Main/Main.java
Robust/src/Tests/TaskExample.java

index f47fdeeb09deb11983d7a2589391d39817ffa334..a0fcb722459f336e72df484443efd88278d908ca 100644 (file)
@@ -51,6 +51,9 @@ public class BuildFlat {
 
     /* This method transforms a vector of FlagEffects into the FlatFlagActionNode */
     private void updateFlagActionNode(FlatFlagActionNode ffan, Vector flags) {
+       if (flags==null) // Do nothing if the flag effects vector is empty
+           return;
+
        for(int i=0;i<flags.size();i++) {
            FlagEffects fes=(FlagEffects)flags.get(i);
            TempDescriptor flagtemp=getTempforVar(fes.getVar());
index c893c20ee70e0ceb9c1579297fe01a869074a4f0..ac160634bdd26bdc163e8e0062b5f0f09e0f8c66 100644 (file)
@@ -21,6 +21,10 @@ public class State {
        parsetrees.add(parsetree);
     }
 
+    /** Boolean flag which indicates whether compiler is compiling a task-based
+     * program. */
+    public boolean TASK;
+
     public SymbolTable classes;
     public SymbolTable tasks;
     public Set parsetrees;
index 9bebc91da9136033102385ae68d55a9458c6353f..96cbf846e273189d54ec1f9a3670b2fe6f6fc022 100644 (file)
@@ -170,6 +170,7 @@ public class BuildIR {
        ParseNode flagnode=pn.getChild("flag");
        if (flagnode!=null) {
            parseFlagDecl(cn, flagnode.getChild("flag_declaration"));
+           return;
        }
        throw new Error();
     }
@@ -416,14 +417,12 @@ public class BuildIR {
        ParseNode bodyn0=pn.getChild("body");
        ParseNode bodyn=bodyn0.getChild("constructor_body");
        cn.addMethod(md);
-       if (bodyn!=null) {
-           BlockNode bn=parseBlock(bodyn);
-           state.addTreeCode(md,bn);
-       }
+       BlockNode bn=parseBlock(bodyn);
+       state.addTreeCode(md,bn);
     }
 
     public BlockNode parseBlock(ParseNode pn) {
-       if (isEmpty(pn.getTerminal()))
+       if (pn==null||isEmpty(pn.getTerminal()))
            return new BlockNode();
        ParseNode bsn=pn.getChild("block_statement_list");
        return parseBlockHelper(bsn);
index 9be66a385426113bd4ea2b8e500e9c3540d75bf5..5892bb6e9b04c384adabeba7afaf95ce351844db 100644 (file)
@@ -79,6 +79,8 @@ public class SemanticCheck {
     }
 
     public void checkFlagEffects(TaskDescriptor td, Vector vfe) {
+       if (vfe==null)
+           return; /* No flag effects to check */
        for(int i=0;i<vfe.size();i++) {
            FlagEffects fe=(FlagEffects) vfe.get(i);
            String varname=fe.getName();
index 78270a0b2af4be737a1b405f6495a3ae2e80c33e..9f564211f9908ba57fd9e1bf26e8e23372fee4b8 100644 (file)
@@ -41,7 +41,7 @@ public class TypeDescriptor extends Descriptor {
     public int hashCode() {
        int hashcode=type^arraycount;
        if (type==CLASS)
-           hashcode^=class_desc.hashCode();
+           hashcode^=getSymbol().hashCode();
        return hashcode;
     }
 
index da4c77bdb1b0f5406b8752410383a747bcc97870..cf2f054f4a0fe1590d6b4ca3c5f2e0116c6dea83 100644 (file)
@@ -12,6 +12,7 @@ import IR.State;
 import IR.TypeUtil;
 
 public class Main {
+
   public static void main(String args[]) throws Exception {
       String ClassLibraryPrefix="./ClassLibrary/";
       State state=new State();
@@ -26,6 +27,8 @@ public class Main {
              ClassLibraryPrefix=args[++i]+"/";
          else if (option.equals("-mainclass"))
              state.main=args[++i];
+         else if (option.equals("-task"))
+             state.TASK=true;
          else if (option.equals("-help")) {
              System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
              System.out.println("-dir outputdirectory -- output code in outputdirectory");
@@ -42,6 +45,8 @@ public class Main {
       readSourceFile(state, ClassLibraryPrefix+"Object.java");
       readSourceFile(state, ClassLibraryPrefix+"System.java");
       readSourceFile(state, ClassLibraryPrefix+"String.java");
+      if (state.TASK)      
+         readSourceFile(state, ClassLibraryPrefix+"StartupObject.java");
 
       BuildIR bir=new BuildIR(state);
       bir.buildtree();
index dcaf95060e9a9b0e471b804b300679014477cde8..94a6c4c16e67baf8868b130b82718e586d917db6 100644 (file)
@@ -1,7 +1,9 @@
 class Example {
     flag needoperation;
     flag needprinting;
-    
+    public Example() {}
+
+   
     int operation;
     int x;
     int y;
@@ -41,5 +43,5 @@ task DoOperation(Example e{needoperation}) {
 
 task DoPrint(Example e{needprinting}) {
     System.printInt(e.z);
-    taskexit(e {!needprinting};
+    taskexit(e {!needprinting});
 }