The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+20 votes
3.3k views

Consider the program given below, in a block-structured pseudo-language with lexical scoping and nesting of procedures permitted.

Program main; 
  Var ...
  
  Procedure A1;
    Var ... 
    Call A2;
  End A1

  Procedure A2;
    Var ...

    Procedure A21;
      Var ...
      Call A1;
    End A21

    Call A21;
  End A2

  Call A1;
End main.

Consider the calling chain: $Main \rightarrow A1 \rightarrow A2 \rightarrow A21 \rightarrow A1$

The correct set of activation records along with their access links is given by:

asked in Compiler Design by Boss (18.3k points)
edited by | 3.3k views
0
can any one describe it more ?
0
Need more explanation of this question
+4
First why we need access link? acess link is used to access the non local data.why we need non local deta what it has to do with access link ? example :: In dynamic scoping we need to access the non local data this done using access link now come to question .....when this code will executed first main will pushed in stack. all the procedure declaration will not run until CALL A1; It will called so it will pushed into stack.now program will try to find the code of A1 so it will go to main using the access link to main .main will give code to A1.so access link will need here .now you are in inside A1 when u execute its code then A2 will be called .again using access link it will go main to find the code of A2 and then pushed into stack so link will be stablished between main to A2 reason is using main you came to know that A2 exist.this process will continue until whole program get executed. below link will be helpfull page 42

https://www.cse.iitk.ac.in/users/karkare/cs335/lectures/13RuntimeSystems.pdf
0
Thanks @a new one.
0
in simple words see the function in which function it is defined, like A(1) is defined in main() so in dynamic scoping for any value lets say "x" will be checked in local function A(1) if it is not present, check in main(), then at global storage area of program. so A(1) access link to main() function.

1 Answer

+1 vote

From main() there are three function calling sequence

1) A1 -> A2

2) A2 ->  A21  ->  A1

3) A1

These 1,2,3 are access links.

Now match with the given answer calling chains:

A)(FALSE)

It shows a linear chain(only one function call from main()) which isn't correct and doesn't follow above sequence at all.

B)(FALSE)

It is false because main() unable to call A1 directly.

C) (FALSE)

It shows there is only two function call made by main(). That is not true and Frame pointer will also get updated by new A1 address block not will be old one.

D) (TRUE)

main() has three function calling sequence present and Frame Pointer is holding the new A1 block address. That is true.

answered by Active (1.7k points)
Answer:

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
47,922 questions
52,324 answers
182,349 comments
67,780 users