CS322 Prog Lang & Compilers Prog Assignment #2 Assigned Tuesday April 10, 2006. Due Tuesday, April 17, 2006 This assignment is to extend the expr program discussed in class (and available for download) so that it can translate array accesses, where the array is a variable: i.e. x[34+j] fun expr dict (ArrayElm(Var(loc,nm),index,SOME typ)) = . . . Unlike real java you should assume 1 based addressing. The index of an array ranges from 1 to n. You should assume that the array can contain any Basic type (Bool, Int, Real) with the following sizes Bool = 1 byte Int = 4 bytes Real = 8 bytes You will need to add a new instruction to the IR for loading a value from memory. if r1 is an address then load r1 => r2 loads the value storeed at r1 into the register r2. Recall that the the function "base" returns the address of the activation pointer, and that "offset" returns a small integer which is the offset from base for a variable name. To get the starting address of an Array stored in a variable you can add these two together. WHAT TO HAND IN A) Print out the code of S03code.sml. Circle in colored ink the additions you made to the code. B) Run your tests, and print and hand in a transcript of the testing. EXPECTATIONS and EVALUATION A) I expect you to add a new constructor to IR for "load" (10%) B) I expect you to be able to modify "expr" (25%) C) I expect you to get the index arithmetic correct (20%) C) I expect a good set of tests. (25%) D) I expect you to use the compile-manager (5%) E) I expect neat well designed and elegant (10%) code that is well documented. I expect you to document the code I wrote as well as the code you wrote.