remaining hacks
authorbdemsky <bdemsky>
Wed, 18 Feb 2009 09:41:37 +0000 (09:41 +0000)
committerbdemsky <bdemsky>
Wed, 18 Feb 2009 09:41:37 +0000 (09:41 +0000)
Robust/src/IR/Tree/BuildIR.java
Robust/src/IR/Tree/SemanticCheck.java
Robust/src/IR/TypeUtil.java
Robust/src/Main/Main.java

index 2e61224fed4eceeec380cf20a1e8a5bb54e276d1..86a9c1dbdb85fd12aa3c1cdac9026de65cee317c 100644 (file)
@@ -13,8 +13,8 @@ public class BuildIR {
     this.m_taskexitnum = 0;
   }
 
-  public void buildtree(ParseNode pn) {
-      parseFile(pn);
+  public void buildtree(ParseNode pn, Set toanalyze) {
+    parseFile(pn, toanalyze);
   }
 
   Vector singleimports;
@@ -22,7 +22,7 @@ public class BuildIR {
   NameDescriptor packages;
 
   /** Parse the classes in this file */
-  public void parseFile(ParseNode pn) {
+  public void parseFile(ParseNode pn, Set toanalyze) {
     singleimports=new Vector();
     multiimports=new Vector();
 
@@ -51,9 +51,13 @@ public class BuildIR {
          continue;
        if (isNode(type_pn,"class_declaration")) {
          ClassDescriptor cn=parseTypeDecl(type_pn);
+         if (toanalyze!=null)
+           toanalyze.add(cn);
          state.addClass(cn);
        } else if (isNode(type_pn,"task_declaration")) {
          TaskDescriptor td=parseTaskDecl(type_pn);
+         if (toanalyze!=null)
+           toanalyze.add(td);
          state.addTask(td);
        } else {
          throw new Error(type_pn.getLabel());
index d160f65f8e19e10a2fff0aa5d073dfbc19c0c56d..ceef3bce687f092e3db9c5d8a6157869f77518bf 100644 (file)
@@ -57,25 +57,23 @@ public class SemanticCheck {
   public void semanticCheck() {
     SymbolTable classtable=state.getClassSymbolTable();
     toanalyze.addAll(classtable.getValueSet());
+    toanalyze.addAll(state.getTaskSymbolTable().getValueSet());
 
-    //Start with any tasks
-    for(Iterator task_it=state.getTaskSymbolTable().getDescriptorsIterator(); task_it.hasNext();) {
-      TaskDescriptor td=(TaskDescriptor)task_it.next();
-      checkTask(td);
-
-    }
-    
     // Do methods next
     while(!toanalyze.isEmpty()) {
-      ClassDescriptor cd=(ClassDescriptor)toanalyze.iterator().next();
-      toanalyze.remove(cd);
-      checkClass(cd);
-      for(Iterator method_it=cd.getMethods(); method_it.hasNext();) {
-       MethodDescriptor md=(MethodDescriptor)method_it.next();
-       checkMethodBody(cd,md);
+      Object obj=toanalyze.iterator().next();
+      if (obj instanceof TaskDescriptor) {
+       checkTask((TaskDescriptor)obj);
+      } else {
+       ClassDescriptor cd=(ClassDescriptor)obj;
+       toanalyze.remove(cd);
+       checkClass(cd);
+       for(Iterator method_it=cd.getMethods(); method_it.hasNext();) {
+         MethodDescriptor md=(MethodDescriptor)method_it.next();
+         checkMethodBody(cd,md);
+       }
       }
     }
-
   }
 
   public void checkTypeDescriptor(TypeDescriptor td) {
index 5b65deb1dd2b908beacd1d10d28a2243f89bad19..019e3130257c7fe32d29b971d75c95ecd7e2a6aa 100644 (file)
@@ -21,14 +21,14 @@ public class TypeUtil {
     createTables();
   }
 
-  public void addNewClass(String cl) {
+  public void addNewClass(String cl, Set todo) {
     for(int i=0;i<state.classpath.size();i++) {
       String path=(String)state.classpath.get(i);
       File f=new File(path, cl+".java");
       if (f.exists()) {
        try {
          ParseNode pn=Main.readSourceFile(state, f.getCanonicalPath());
-         bir.buildtree(pn);
+         bir.buildtree(pn, todo);
          return;
        } catch (Exception e) {
          throw new Error(e);
@@ -49,7 +49,7 @@ public class TypeUtil {
     ClassDescriptor cd=(ClassDescriptor)state.getClassSymbolTable().get(classname);
     if (cd==null) {
       //have to find class
-      addNewClass(classname);
+      addNewClass(classname, todo);
       cd=(ClassDescriptor)state.getClassSymbolTable().get(classname);
       System.out.println("Build class:"+cd);
       todo.add(cd);
index 6ea3f63c1e0921986555d6170272a7f0caa0a346..cc7d396f5bcf270b50593257dc4f1e3410dc1651 100644 (file)
@@ -336,7 +336,7 @@ public class Main {
 
   public static void loadClass(State state, BuildIR bir, String sourcefile) {
     ParseNode pn=readSourceFile(state, sourcefile);
-    bir.buildtree(pn);
+    bir.buildtree(pn, null);
   }
 
   /** Reads in a source file and adds the parse tree to the state object. */