Due: Monday, 1 May 2008.
Complete the compiler, "Chapter 12: Procedure Entry/Exit," page 270 and "Chapter 12: Making It Work," page 272. You may assume fewer temps than registers. Your make file should create a jar file named compile.jar.Submit a file named README that summarizes what you think your compiler is capable of doing correctly. For example,
My compiler successfully compiles all 8 of Appel's mini Java programs.or
The only program of Appel that my compiler succussfully compiles is "Factorial.java".Put your name in the README file.
You may also submit your one best test case (mini Java program) illustrating what your compiler can do.
As usual the compiler takes a file name of a program as the only command line argument. Now the output, the assembly programs, is written to a file. The name of the assembly program is the name of the program without the .java suffix and with an added .s suffix. (It is helpful to put your name in comments in the first line of the .s file.)
The desired effect is that the command
java -jar compiler.jar dir/Test.javacompiles the program Test.java and writes the file dir/Test.s. If there are any errors, the compiler does not have to write a file, but must write the error messages to the standard error stream. As usual, in all cases there must be a single line of output to the standard output stream of the following form:
filename=dir/Test.java, errors=0
#!/bin/csh set dir=`dirname $0` # root dir: location of script set file=`dirname $1`/`basename $1 .java` # remove ext of arg, keep dir gas $dir/macros.s $file.s -o $file.o gld -e start $file.o $dir/runtime.o -lc -o $fileYou may assume that java, gas, gld are in the excute path. You may assume that compile.jar is in the working directory of the script. Obviously, compile.jar must produce a .s file from a .java file. You must insure that any auxiliary files (e.g., macros.s, runtime.o) are created by your makefile in the same directory as compile.jar.
Runtime.getRuntime().exec(new String[]{"/bin/sh", "-c", "compile"});
Runtime.getRuntime().exec(new String[]{"gas", "./macros", dotsfile, "-o", dotofile});
Here is an example makefile. You are free to make any modifications you like to accommodate the actions of your compiler.
# delete the default suffixes for obsolete suffix rules
.SUFFIXES :
# override on the make command line as necessary by
# make "JAVAD=/some/thing/else"
JAVAD := /software/solaris/compilers/java/j2sdk1.4.0/j2se/bin
JAVAC := $(JAVAD)/javac
JAVA := $(JAVAD)/java
# override on the make command line as necessary by
# make "GNUD=/some/thing/else"
GNUD := /software/solaris/compilers/gnu/bin
CC := $(GNUD)/gcc
LD := $(GNUD)/ld
AS := $(GNUD)/as
JAVACC := ../../javacc/javacc-3.2/bin/javacc
runtime.o : runtime.c
$(CC)-c runtime.c
Don't forget to turn in your runtime system (in phase12.jar). Turn in the source; make sure your makefile produces an object file from it.
Don't forget to turn in any file of assembly macros that you require (in phase12.jar).
Your compiler will be built (as usual) by issuing the following command.
make JAVAD=... GNUD=.... JAVACC=... CP=...It should produce a Java jar file called compile.jar.
|
Course=cse4251 Project=asgn8 |