few more changes
authorbdemsky <bdemsky>
Wed, 18 Feb 2009 09:26:19 +0000 (09:26 +0000)
committerbdemsky <bdemsky>
Wed, 18 Feb 2009 09:26:19 +0000 (09:26 +0000)
Robust/src/IR/State.java
Robust/src/IR/Tree/SemanticCheck.java
Robust/src/IR/TypeUtil.java
Robust/src/Main/Main.java

index ef5aa45d59ac13b2b17ca51e42da47f2c3bee446..dcf54b21ef76d37fac87382d1f7b9cb2c4e58a00 100644 (file)
@@ -8,7 +8,6 @@ import Analysis.TaskStateAnalysis.*;
 public class State {
   public State() {
     this.classes=new SymbolTable();
-    this.discclass=new HashSet();
     this.tasks=new SymbolTable();
     this.treemethodmap=new Hashtable();
     this.flatmethodmap=new Hashtable();
@@ -82,7 +81,6 @@ public class State {
   public HashSet selfloops;
   public HashSet excprefetch;
   public Vector classpath;
-  public HashSet discclass;
   public SymbolTable classes;
   public SymbolTable tasks;
   public Set parsetrees;
index 59bc63aca9a4adff07c780584fb3e26964b7513b..d160f65f8e19e10a2fff0aa5d073dfbc19c0c56d 100644 (file)
@@ -21,8 +21,14 @@ public class SemanticCheck {
 
   public ClassDescriptor getClass(String classname) {
     ClassDescriptor cd=typeutil.getClass(classname, toanalyze);
+    checkClass(cd);
+    return cd;
+  }
+
+  private void checkClass(ClassDescriptor cd) {
     if (!completed.contains(cd)) {
       completed.add(cd);
+      
       //System.out.println("Checking class: "+cd);
       //Set superclass link up
       if (cd.getSuper()!=null) {
@@ -46,7 +52,6 @@ public class SemanticCheck {
        checkMethod(cd,md);
       }
     }
-    return cd;
   }
 
   public void semanticCheck() {
@@ -64,6 +69,7 @@ public class SemanticCheck {
     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);
index 0bda49cb92c4b68b92d1bcce2f7ff914fb30bb55..5b65deb1dd2b908beacd1d10d28a2243f89bad19 100644 (file)
@@ -22,8 +22,6 @@ public class TypeUtil {
   }
 
   public void addNewClass(String cl) {
-    if (state.discclass.contains(cl))
-      return;
     for(int i=0;i<state.classpath.size();i++) {
       String path=(String)state.classpath.get(i);
       File f=new File(path, cl+".java");
@@ -31,7 +29,6 @@ public class TypeUtil {
        try {
          ParseNode pn=Main.readSourceFile(state, f.getCanonicalPath());
          bir.buildtree(pn);
-         state.discclass.add(cl);
          return;
        } catch (Exception e) {
          throw new Error(e);
index 82c56168ed1a843664660c0064fb34ab7058f28a..6ea3f63c1e0921986555d6170272a7f0caa0a346 100644 (file)
@@ -178,10 +178,7 @@ public class Main {
        System.out.println("-help -- print out help");
        System.exit(0);
       } else {
-       if (args[i].indexOf(".java")!=-1)
-         sourcefiles.add(args[i].substring(0,args[i].indexOf(".java")));
-       else
-         sourcefiles.add(args[i]);
+       sourcefiles.add(args[i]);
       }
     }
 
@@ -196,7 +193,7 @@ public class Main {
     SemanticCheck sc=new SemanticCheck(state,tu);
 
     for(int i=0;i<sourcefiles.size();i++)
-      sc.getClass((String)sourcefiles.get(i));
+      loadClass(state, bir,(String)sourcefiles.get(i));
 
     //Stuff the runtime wants to see
     sc.getClass("String");
@@ -337,6 +334,11 @@ public class Main {
     System.exit(0);
   }
 
+  public static void loadClass(State state, BuildIR bir, String sourcefile) {
+    ParseNode pn=readSourceFile(state, sourcefile);
+    bir.buildtree(pn);
+  }
+
   /** Reads in a source file and adds the parse tree to the state object. */
 
   public static ParseNode readSourceFile(State state, String sourcefile) {