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

[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

1 Expert Approved Answer
Step: 1 Unlock

To solve this problem we need to determine the static chain offsets and local offsets for the variab... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!