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();
public HashSet selfloops;
public HashSet excprefetch;
public Vector classpath;
- public HashSet discclass;
public SymbolTable classes;
public SymbolTable tasks;
public Set parsetrees;
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) {
checkMethod(cd,md);
}
}
- return cd;
}
public void 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);
}
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");
try {
ParseNode pn=Main.readSourceFile(state, f.getCanonicalPath());
bir.buildtree(pn);
- state.discclass.add(cl);
return;
} catch (Exception e) {
throw new Error(e);
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]);
}
}
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");
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) {