/ CASE STUDY
/ The Compiler
Here is the specification for translating designators:
Designator(Desig -> Type) generates code for the designator Desig (a construct yielding an address) and computes its type Type.
If the designator is a simple identifier, we look up its definition and use Access to determine the code and type.
Access(Obj, Pos -> Type) generates the code to access the object Obj and return its type. By way of an example, consider the rule that handles variables:
'rule' Access(object(varobj(Offset, Type), Level, Hidden), Pos -> Type) : GetCurrentNesting(-> CurLev) LDA(CurLev-Level, Offset)The object has the offset Offset and the type Type ; it was declared on nesting level Level. This results in an instruction
LDA CurLev-Level, Offsetwhere CurLevel is the nesting level of the location where the object is used.
The representation of objects is discussed next.