Chapter 6: Runtime System

Nesting Depth

. Main procedure is at depth 1

. Add 1 to depth as we go from enclosing to enclosed procedure

Access to non-local names

. Include a field 'access link' in the activation record

. If p is nested in q then access link of p points to the access link in most recent activation of q

Nesting Depth : The notion of nesting depth is used to implement lexical scope. The main program is assumed to be at nesting depth 1 and we add 1 to the nesting depth as we go from an enclosing to an enclosed procedure.

Access Links : To implement the lexical scope for nested procedures we add a pointer called an access link to each activation record. If a procedure p is nested immediately within q in the source text, then the access link in an activation record for p points to the access link in the record for most recent activation of q .

The access links for finding storage for non-locals are shown below.