CS 3304: Comparative Languages
Implementing Subprograms
[
Course Documents
] : [
Implementing Subprograms
]
Previous
Contents
Next
Keyword Index
Static Chain Maintenance
At the call (assume there are no parameters that are subprograms and no pass-by-name parameters):
The activation record instance must be built
The dynamic link is just the old frame pointer
The static link must point to the most recent ARI of the static parent (in most situations)
Best method:
If A calls B, then B's static link should be set to the ARI that is (static_depth(A) – static_depth(B) + 1) links along the static chain starting at A
Amounts to treating subprogram calls and definitions like variable references and definitions, and then using the chain_offset
This info can be computed statically by the compiler