CS 3304: Comparative Languages
Implementing Subprograms
[
Course Documents
] : [
Implementing Subprograms
]
Previous
Contents
Next
Keyword Index
Mechanics of Display References
Use the display_offset to get the pointer into the display to the ARI with the variable
Use the local_offset to get to the variable within the ARI
Display maintenance (assuming no parameters that are subprograms and no pass-by-name parameters):
Display_offset depends only on the static_depth of the procedure whose ARI is being built: It is exactly the static_depth of the procedure
There are k+1 entries in the display, where k is the static depth of the currently executing unit (k=0 is for the main program)
For a call to procedure P with a static_depth of k:
Save a copy of the display pointer at position k in new ARI
Put the link to the new ARI for P at position k in the display
On return, move the saved display pointer from the ARI back into the display at position k