Question
This is your third and final assignment for this course that accounts for 60% of your total marks for the course. You should implement the
This is your third and final assignment for this course that accounts for 60% of your total marks for the course.
You should implement the lower operations for all the new language constructs and features in the extended MiniJava language. This includes inserting coercions from integers to doubles wherever necessary, and for generating tests for null array references and out-of-bounds array references and negative-sized array creations. To support System.out.println on doubles, a new runtime function should be added to the Target/Runtime/runtime.c file. The lower operations should use the IL classes defined in the IL subdirectory, but you should not make any changes to these IL classes.
After lowering, your lowered IL program should be able to be translated into x86 target code, which then compiles, links, and runs correctly. (The x86 code generator is already fully implemented; you should not make any changes to it.)
In all cases, as long as the MiniJava language restrictions are satisfied, a MiniJava program should compile into an executable program that then runs the same as the equivalent Java program.
Do the following:
1. Add and/or modify classes in the AST and/or SymbolTable subdirectories to perform lowering, and modify the Target/Runtime/runtime.c file to include any new runtime functions you need. (You should not modify any files in the IL or Target subdirectories, other than the runtime.c file.)
2. Develop test cases that demonstrate that your extended compiler works properly, both in cases that should now compile and run successfully and in cases that should now compile successfully but throw exceptions when run. (Since execution ends with the first exception, you'll likely need several excepting test case files to test the different excepting cases.) You may assume that your test cases pass all lexical, syntactic, and semantic checks, and you may assume that all MiniJava constructs from the initial language (before your extensions) are compiled and executed correctly; you only need to test compilation and execution of the new language features. The Sample Programs directory contains some files that should compile and execute successfully after you make your changes; some of the files should compile and execute successfully with the initial version of the MiniJava compiler.
You can use the -lower -printIL options to the MiniJava compiler to just run the lowering phase and print out the IL program that it produces. See the test_lowering
target in the Makefile for an example. You can use the -printCode option (the -codegen option is the default) to the MiniJava compiler to run the full compiler and print out the assembly code that it produces. See the test_codegen target in the Makefile for an example, which also compiles the runtime.c file, runs the assembler on the generated assembly file, links it with the compiled runtime.c file, and finally runs the linked executable program. (This target should be run only on an x86 machine, so that the generated x86 assembly code can be compiled and run successfully.) Feel free to make your own target(s) to make running the tests you like easier and more mechanical.
Submit to VLE the following:
1. Your new and/or modified AST/*.java, SymbolTable/*.java, and/or Target/Runtime/runtime.c files. Clearly identify any modifications to existing files using comments.
2. Your test cases, with names of the form name.legal.java for test cases that should compile and run successfully and name.illegal.java for test cases that should compile successfully but throw exceptions when run.
3. A transcript of running your intermediate code generator and printing out the resulting IL program (not the final assembly code) on each of your test cases.
4. A transcript of running the compiled code for each of your test cases.
You can put them in a zip file or in folder, choose the more convenient for you. You need to include also your test programs.
Your work needs to be well written and have quality information. Your work must be clear and has to be able to educate someone with no prior knowledge in Compiler design.
Assignment Evaluation Rules:
Overall presentation 10%
Coding Structure 10%
Comments 10%
Code correctness 50%
Recommendations 10%
Conclusion - What you have learned 10%
Notes:
Please read and apply the rules for referencing.
The assignment is your own individual work. I expect all sent assignments to be very different from one another even if they are based on the same topic.
The deadline is the end of week 4. Late assignments will NOT be accepted unless for exceptional reasons.
This is worth 60% of your mark
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started