You will need to do type checking for method calls, variable declarations, and ...
java -jar MJPA6_groupname.jar InputFile.java
The input files can be any PA6 MeggyJava program. The PA6Cylon.java example you wrote for PA2 and PA6PaddleBall.java are possible test cases for MJPA6_groupname.jar. The output file named InputFile.java.s should be an AVR assembly program that using the provided build process will run on the MeggyJr device. Additionally, the InputFile.java.s file must be such that we can run it through the AVR simulator MJSIM.jar (NOTE: this is a new version of MJSIM.jar updated for PA5).
This assignment requires the following implementation strategies be used:
For each method, you will need to store signature information. A method's signature includes information about the types of each of its parameters and its return value. Method and Class STEs should also contain a scope that can then contain local variables or member variables and methods respectively. When a symbol is inserted into the symbol table, it should be inserted into the most current scope (i.e. the method being visited).
Class STEs should also contain a scope that can then contain member variables and methods. Each class also has its own namespace, and therefore different classes can have the same method name in them. This means that the method name will need to be mangled, both when the label is printed and for any calls to that method. We recommend that you extend the method STEs to keep track of a mangled name for the method. The mangled name can be some concatenation of the class name and the method name.
The symbol table data structure should be able to insert and lookup the symbol table entries for symbols and print itself to a dot file. Here is a possible interface:
STE lookup(String)
void insert(STE)
void pushScope(String)
void insertAndPushScope(NamedScopeSTE)
void popScope()
void outputDot(...)
See the notes from March 31st for some more ideas about how to design the symbol table.
[LINENUM,POSNUM] Redeclared symbol SYMNAMEwhere LINENUM is the line number for the symbol, POSNUM is the position number for the symbol, and SYMNAME is the symbol name. ALL such errors should be printed to standard error, and at the end of symbol table construction if any such errors are printed then the following error should be printed to standard error and your compiler should exit:
Errors found while building symbol tableAs an example, here is the output for PA6dupnameserror.java:
[23,16] Redefined symbol A [27,17] Redefined symbol run [40,16] Redefined symbol B [45,17] Redefined symbol foo [51,21] Redefined symbol run [57,7] Redefined symbol A Errors found while building symbol tableNote that since the reference compiler is provided in jar form, you can compare your output with the output from the reference MJ_PA6.jar. Also note that id tokens (i.e., the Token class) already has line and position information.
[LINENUM,POSNUM] Class CLASSNAME does not exist
// anywhere an id token should be a class name
[LINENUM,POSNUM] Receiver of method call must be a class type
[LINENUM,POSNUM] Method METHODNAME does not exist in class type CLASSNAME
[LINENUM,POSNUM] Invalid type returned from method METHODNAME
// any method declaration
[LINENUM,POSNUM] Method METHODNAME does not exist
[LINENUM,POSNUM] Method METHODNAME requires exactly NUM arguments
[LINENUM,POSNUM] Invalid argument type for method METHODNAME
[LINENUM,POSNUM] Undeclared variable VARNAME
// anywhere an id token could be a variable name
[LINENUM,POSNUM] Invalid expression type assigned to variable VARNAME
// assignment statements
where LINENUM is the line number for the symbol, POSNUM is the position number for the symbol, CLASSNAME is a specific class name,
METHODNAME is a specific method name, and VARNAME is a specific variable name.
To enable easier testing and grading do not change the phrasing of the error messages. Test against the reference type checkers in ~cs453/public/.
See the Meggy Sim instructions for usage notes. The set of instructions you will need include a file declaration at the top of the assembly file (.file "main.java"), instructions in the previously provided avrH.rtl.s and avrF.rtl.s files and the following:
# Examples of each statement type are provided.
# Register numbers, constant values, and labels can change.
ldi r24,lo8(1)
ldi r25,hi8(0)
ldi r24,73
lds r24, Button_A
push r24
pop r24
call functionName
tst r24
cp r24, r25
breq MJ_L6
brne MJ_L7
jmp MJ_L6
LabelWithAnyName:
# top of a function declaration
.text
.global Cloudrain
.type Cloudrain, @function
Cloudrain:
# indirect stores and loads
std Y+1, r24
ldd r24, Y + 3
call malloc
For more details about the instructions see the 08-MeggyJrSimple-n-AVR.txt notes.
Notice that avrF.rtl.s already has an infinite loop at the end of main so that the program will always remain running on the Meggy Jr device even if there is no while loop in the MeggyJava program.
svn log
svn info
svnlook tree REPOSITORY_PATH
Note that svnlook must be issued on the machine where the repository resides.
~cs453/bin/checkin PA6 MJPA6_groupname.jar
// We will also run the test cases with different arg_opts files.
java -jar MJPA6_groupname.jar TestCase.java
java -jar MJSIM.jar -b -f TestCase.java.s > t1
javac TestCase.java
java TestCase > t2
diff t1 t2
// to get the README, subversion.txt, look at source files,
// and view any other required files
jar xf MJPA6_groupname.jar