this.m_taskexitnum = 0;
}
- public void buildtree(ParseNode pn) {
- parseFile(pn);
+ public void buildtree(ParseNode pn, Set toanalyze) {
+ parseFile(pn, toanalyze);
}
Vector singleimports;
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();
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());
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) {
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);
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);
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. */