CS 3304: Comparative Languages
Implementing Subprograms
[
Course Documents
] : [
Implementing Subprograms
]
Previous
Contents
Next
Keyword Index
Technique 1: Static Chains
A
static chain
is a chain of
static links
that connects certain ARIs
The static link in an ARI for subprogram A points to one of the ARIs of A's
static parent
The static chain from an ARI connects it to all of its static ancestors
To find the declaration for a reference to a nonlocal variable:
The compiler can easily determine how many levels of scope separate the current subprogram from the definition
Just walk the static chain the correct number of steps
Static_depth
is an integer associated with a static scope whose value is the depth of nesting of that scope