Held Wednesday, April 4, 2001
Today we continue our considerations of the steps involved in translating
expressions by visiting the compound data types, arrays and records.
- Are there questions on the type checker?
- I know that Rachel reported that the type checker was the worst part
of their effort; however, they were dealing with a different language.
- In case you haven't figured it out yet, I'm providing project advice
primarily in an "on demand" fashion; I'm unlikely to grade your projects
until the end of the term.
- Having looked at the British system, I feel less bad about these
only end-of-semester evaluations.
- About records and arrays
- Translating record fields
- Translating array references
- Translating other kinds of expressions
- Compound values, like records and arrays are more complicated than
basic values because they occupy more memory and hence cannot fit
in a register.
- There are many ways to handle these bigger things, most of which
involve storing the base address in a temporary.
- It may help to distinguish between values stored on the stack and
values stored in the heap or "static" memory.
- Probably can't be done with the same instruction as integer
or real copies; you need to copy an area of memory, rather than
a single value.
- You may have to implement a
memcopy helper if one
isn't built in to your assembly.
- Example: r.a or r.b
- Generate the code to build the record. You should end up with
a memory reference for the start of the record.
- Add the offset for the field. This gives you the address of the
start of the field.
- Example: A[i] or A[i+3]
- Similar to records, except that the offset is given by a formula
that involves the size of the stored values, the base index, and
the desired index.
- Yes, you'll need to look in the symbol table.
- Yes, here's a case in which you'll probably want to store a reference
to the desired location in a temporary.
- Relational opeartors are
often better handled in the appropriate context (e.g., in translating
- Function calls are complicated enough that we'll return to them
Monday, 22 January 2001
- Created as a blank outline.
Wednesday, 4 April 2001
- Filled in the details, many of which come from the previous outline.