outclassdefs.println("extern int classsize[];");
outclassdefs.println("extern int hasflags[];");
outclassdefs.println("extern int * pointerarray[];");
+ outclassdefs.println("extern int supertypes[];");
//Store the sizes of classes & array elements
generateSizeArray(outmethod);
+ //Store table of supertypes
+ generateSuperTypeTable(outmethod);
+
//Store the layout of classes
generateLayoutStructs(outmethod);
output.println("};");
}
- /* Force consistent field ordering between inherited classes. */
+ /** Print out table to give us supertypes */
+ private void generateSuperTypeTable(PrintWriter output) {
+ output.println("int supertypes[]={");
+ boolean needcomma=false;
+ for(int i=0;i<state.numClasses();i++) {
+ ClassDescriptor cn=cdarray[i];
+ if (needcomma)
+ output.println(",");
+ needcomma=true;
+ if (cn.getSuperDesc()!=null) {
+ ClassDescriptor cdsuper=cn.getSuperDesc();
+ output.print(cdsuper.getId());
+ } else
+ output.print("-1");
+ }
+ output.println("};");
+ }
+
+ /** Force consistent field ordering between inherited classes. */
private void printClassStruct(ClassDescriptor cn, PrintWriter classdefout) {
ClassDescriptor sp=cn.getSuperDesc();
private void generateFlatCastNode(FlatMethod fm, FlatCastNode fcn, PrintWriter output) {
/* TODO: Do type check here */
if (fcn.getType().isArray()) {
- ;
+ throw new Error();
} else if (fcn.getType().isClass())
output.println(generateTemp(fm,fcn.getDst())+"=(struct "+fcn.getType().getSafeSymbol()+" *)"+generateTemp(fm,fcn.getSrc())+";");
else
public class Main {
+ /** Main method for the compiler. */
+
public static void main(String args[]) throws Exception {
String ClassLibraryPrefix="./ClassLibrary/";
State state=new State();
bc.buildCode();
System.exit(0);
}
+
+ /** Reads in a source file and adds the parse tree to the state object. */
private static void readSourceFile(State state, String sourcefile) throws Exception {
Reader fr = new BufferedReader(new FileReader(sourcefile));
javadoc:
mkdir javadoc
- javadoc -classpath ../cup:.:$(CLASSPATH) -sourcepath .:./ClassLibrary -private -d javadoc Lex Util ClassLibrary IR IR.Tree IR.Flat Analysis Analysis.CallGraph Analysis.Flag Main ClassLibrary/*.java
+ javadoc -classpath ../cup:.:$(CLASSPATH) -sourcepath . -private -d javadoc Lex Util IR IR.Tree IR.Flat Analysis Analysis.CallGraph Analysis.Flag Analysis.TaskStateAnalysis Main
clean:
- rm IR/*.class IR/Tree/*.class Main/*.class Lex/*.class Parse/*.class Parse/Sym.java Parse/Parser.java IR/Flat/*.class classdefs.h methodheaders.h methods.c structdefs.h virtualtable.h task.h taskdefs.c taskdefs.h Analysis/*.class Analysis/Flag/*.class Analysis/CallGraph/*.class -r javadoc
+ rm -r javadoc
+ rm IR/*.class IR/Tree/*.class Main/*.class Lex/*.class Parse/*.class Parse/Sym.java Parse/Parser.java IR/Flat/*.class classdefs.h methodheaders.h methods.c structdefs.h virtualtable.h task.h taskdefs.c taskdefs.h Analysis/*.class Analysis/Flag/*.class Analysis/CallGraph/*.class
+
collect(stackptr);
/* Update stat on previous gc size */
- lastgcsize=to_heapptr-to_heapbase;
+ lastgcsize=(to_heapptr-to_heapbase)+size;
/* Flip to/curr heaps */
{
curr_heapgcpoint=((char *) curr_heapbase)+GCPOINT(curr_heaptop-curr_heapbase);
to_heapptr=to_heapbase;
- //XXXXX Need check here in case we allocate a really big object
+ /* Not enough room :(, redo gc */
+ if (curr_heapptr>curr_heapgcpoint)
+ return mygcmalloc(stackptr, size);
+
bzero(tmp, curr_heaptop-tmp);
return tmp;
}