Assignment 4: Static Checking (Part C)
In this assignment, you will implement the static checking of the following requirements of the Joos 1W language:
- All statements must be reachable. (Details of the exact definition of reachability are specified in Section 14.20 of the Java Language Specification. It turns out that it is possible to implement reachability checking using an AST traversal, but it is recommended that you implement it as a dataflow analysis.)
- The last statement on every finite-length execution path through a method whose return
type is not
voidmust be a return statement.
- Every local variable must have an initializer, and the variable must not occur in its own initializer.
You will also implement a dataflow analysis to emit warnings for dead assignments to local variables. Notice that since Joos 1W requires that all local variables be initialized when declared, your compiler need not emit warnings for any local variable declaration even though the initialization may be dead. Any warnings emitted by your compiler should be for assignments to already initialized local variables.
Submit to Marmoset a
report.pdf accompanying your code submissions for
Follow the guidelines in authoring your report.
The report should not exceed eight pages.
Submit to Marmoset a
.zip archive. It should include everything
required to build and run your project. In particular,
.zip file must contain a file called
Makefile. Marmoset will run
make on this
to compile your compiler. The
Makefile must generate an executable
(binary or shell script) called
joosc executable must accept multiple
filenames as arguments. All of the files listed on the
command line, and only those files, are considered part of
the program being compiled.
compiler should not look for classes in
.class files on the
CLASSPATH; it should read only the Joos 1W source files
listed on the command line. This means that all classes, including
classes such as
java.lang.Object, must be available in
source form and must be specified on the
joosc command line.
javac, Joos does not care what directory a source
file is in (i.e. it does not require the directory structure
of the source code to match the package structure).
However, the class declared in a file must still have the same name
as the filename.
For example, Java would require that the class
be declared in the file
Object.java in the directory
java/lang, whereas Joos only requires the file to
Object.java, but otherwise allows it to
be in any directory.
For the purposes of this course, a minimalist version of the
Java standard library is provided. This library can be found
linux.student.cs environment in the directory
/u/cs444/pub/stdlib/4.0. Marmoset will include all
files in this library on the
joosc command line for
every test, in addition to other source file(s) specific to that
test. The following versioning scheme is used to make it possible
to correct errors and/or to extend the library for future assignments
(although we aim to minimize the number of changes that will be required).
The 4 in the directory name refers to Assignment 4, and the 0
is the first version of the library. Any corrections to the Assignment 4
version of the library will appear in the directories
4.2, etc., and the version of the library for Assignment 5
will appear in the directory
Version 4.0 of the standard library is identical to version 3.0.
In this assignment,
joosc should process the Joos 1W files given on the command line,
produce appropriate diagnostic messages on standard error,
and exit with one of the following Unix return codes:
- 0: the input file is valid Joos 1W and does not trigger any warnings
- 42: the input file is not valid Joos 1W
- 43: the input file triggers a warning but is otherwise valid Joos 1W
- any other value: your compiler crashed
The archive should include all your test cases and test code that you used to test your program. Be sure to mention where these files are in your report. Do not include Marmoset public tests.
The archive should include a file named
a4.log showing the commit history
of your Git repository.
The archive should not include any extraneous non-source files. It should not include any files that ought to be automatically generated by building or running your compiler.
Your build process should not transmit data from/to the internet in any way.
We reserve the right to deduct points if your submission does not meet the requirements above.
The Marmoset tests for this assignment take several minutes to run. Do not submit more than one submission at a time to Marmoset. If Marmoset reports that your previous submission has not been tested yet, do not submit another one. Denial-of-service attacks on Marmoset will result in disciplinary action.