Here is the specification for translating designators:
282 'action' Designator(Desig: DESIG -> Type: TYPE) 283 'rule' Designator(id(Ident, Pos) -> T) : 284 Apply(Ident, Pos -> Obj) 285 Access(Obj, Pos -> T) 286 'rule' Designator(subscr(Array, Index, Pos) -> T) : 287 Designator(Array -> TArray) 288 Expression(Index -> TIndex) 289 CheckArrayType(TArray, Pos -> Lwb, Upb, T) 290 TypeSize(T -> Size) 291 CheckInt(TIndex, Pos) 292 CHK(Lwb, Upb) 293 LDC(1, Lwb) 294 SUB 295 IXA(Size) 296 'action' Access(Obj: OBJ, Pos: POS -> Type: TYPE) 297 'rule' Access(object(varobj(Offset, Type), Level, Hidden), Pos 298 -> Type) : 299 GetCurrentNesting(-> CurLev) 300 LDA(CurLev-Level, Offset) 301 'rule' Access(object(varparamobj(Offset,Type), Level, Hidden), 302 Pos -> Type) : 303 GetCurrentNesting(-> CurLev) 304 LDA(CurLev-Level, Offset) 305 LDI 306 'rule' Access(object(valueparamobj(Offset,Type),Level,Hidden), 307 Pos -> Type) : 308 GetCurrentNesting(-> CurLev) 309 LDA(CurLev-Level, Offset) 310 'rule' Access(object(procobj(_,_),_,_), Pos -> none) : 311 Error("procedure not allowed here", Pos) |
|
Designator
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
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.