Access to non local names .
. Suppose procedure p at depth np refers to a non- local a at depth na, then storage for a can be found as
- follow (np-na) access links from the record at the top of the stack
- after following (np-na) links we reach procedure for which a is local
. Therefore, address of a non local a in procedure p can be stored in symbol table as
(np-na, offset of a in record of activation having a )
Suppose procedure p at depth np refers to a non-local a with nesting depth na = np. The storage for a can be found as follows:
. When control is in p, an activation record for p is at the top of the stack. Follow the (np - na) access links from the record at the top of the stack.
. After following (np - na) links, we reach an activation record for the procedure that a is local to. As discussed earlier, its storage is at a fixed offset relative to a position in the record. In particular, the offset can be relative to the access link.
The address of non-local a in procedure p is stored as following in the symbol table:
(np - na, offset within the activation record containing a)
|