Question: [6 points] Consider the following code written in a language with static scoping and nested subprograms. Assume that a is called from main function
![[6 points] Consider the following code written in a language with static](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2020/06/5ed7a0229b3a9_1591189537711.jpg)
[6 points] Consider the following code written in a language with static scoping and nested subprograms. Assume that a is called from main function and on the bottom of the stack there is the activation record instance for main. Additionally, activations records (AR) of all related subprograms are given. What are the offset pairs (in the form of (chain offset, local offset) ) of all the variables in lines designated by pos1 and pos2? function a() { int y,z; function b() { int y; function c() { int x; x = y + z; // posl } C(); } function d(int i) { int x; function e() { int x,y: d(5); x = y + i; // pos2 if (i>0) then b(); else e(); d(e); AR for a AR for d AR for e Local z Localy Dynamic link AR for b AR for c Local x Local y Local y Local x Param i Local x Dynamic link Dynamic link Static link Dynamic link Static link ynamic link Static link Static link Static link Return addr. Return addr. Return addr. Return addr. Return addr. Pos1 x: ( * ) y: ( )z:( Pos2 x: ( : ) y: ( + )i: (
Step by Step Solution
There are 3 Steps involved in it
To solve this problem we need to determine the static chain offsets and local offsets for the variab... View full answer
Get step-by-step solutions from verified subject matter experts
