public class Main {
+ /** Main method for the compiler. */
+
public static void main(String args[]) throws Exception {
String ClassLibraryPrefix="./ClassLibrary/";
State state=new State();
state.CONSCHECK=true;
else if (option.equals("-task"))
state.TASK=true;
+ else if (option.equals("-thread"))
+ state.THREAD=true;
+ else if (option.equals("-instructionfailures"))
+ state.INSTRUCTIONFAILURE=true;
else if (option.equals("-help")) {
System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
System.out.println("-dir outputdirectory -- output code in outputdirectory");
System.out.println("-precise -- use precise garbage collection");
System.out.println("-conscheck -- turn on consistency checking");
+ System.out.println("-task -- compiler for tasks");
+ System.out.println("-thread -- threads");
+ System.out.println("-instructionfailures -- insert code for instruction level failures");
System.out.println("-help -- print out help");
System.exit(0);
} else {
readSourceFile(state, ClassLibraryPrefix+"Object.java");
readSourceFile(state, ClassLibraryPrefix+"System.java");
readSourceFile(state, ClassLibraryPrefix+"String.java");
- if (state.TASK)
+ readSourceFile(state, ClassLibraryPrefix+"HashSet.java");
+ readSourceFile(state, ClassLibraryPrefix+"HashMap.java");
+ readSourceFile(state, ClassLibraryPrefix+"HashMapIterator.java");
+ readSourceFile(state, ClassLibraryPrefix+"HashEntry.java");
+ readSourceFile(state, ClassLibraryPrefix+"Integer.java");
+ readSourceFile(state, ClassLibraryPrefix+"StringBuffer.java");
+ readSourceFile(state, ClassLibraryPrefix+"FileInputStream.java");
+ readSourceFile(state, ClassLibraryPrefix+"FileOutputStream.java");
+ readSourceFile(state, ClassLibraryPrefix+"File.java");
+ if (state.TASK) {
readSourceFile(state, ClassLibraryPrefix+"StartupObject.java");
+ readSourceFile(state, ClassLibraryPrefix+"Socket.java");
+ readSourceFile(state, ClassLibraryPrefix+"ServerSocket.java");
+ }
+
+ if (state.THREAD) {
+ readSourceFile(state, ClassLibraryPrefix+"Thread.java");
+ }
BuildIR bir=new BuildIR(state);
bir.buildtree();
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));
ParseNode p=(ParseNode) g./*debug_*/parse().value;
state.addParseNode(p);
if (l.numErrors()!=0) {
- System.out.println("Error parsing Object.java");
+ System.out.println("Error parsing "+sourcefile);
System.exit(l.numErrors());
}
}