ACCESS OF NON LOCAL NAMES in COMPILER DESIGN:
i. Non-local names
In a language with nested procedures (or blocks) and static scope (lexical scope), some names are neither local nor global, they are non-local names.
procedure A
real a;
procedure B
real b;
reference a; ß non-local
end B
end A;
Example: Non-local names in C
main () {
int a = 0, b=0; {
int b = 1; {
int a = 2;
print(a,b); }
{
int b = 3;
print(a,b); }
print(a,b);}
print(a,b); }
i. Block-level and Procedure-level ARs
• Each block can be considered as an in-line procedure without parameters. So we could create a new AR for each block. This is block-level AR and is very inefficient.
• In procedure-level AR method, AR is only used for a true procedure. The relative location of variables in individual blocks within a procedure can be computed and fixed at compile time.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment