 Now procedures have a special functionality and therefore they need to be treated slightly different. And there are two parts in the procedure. One is the header path which normally has to be done path and all the arguments that we pass in. And the second part is more important where for each procedure we need to generate additional code which will get executed at runtime when the procedure is involved. Now when I am compiling my program I do not know whether the procedure will be involved or not. So if procedure gets involved we need to do a few things and then we need to make sure that I have sufficient code to do those things. So let us look at both the parts together. So first part is that when we are talking about procedure, so what we have is, so what we have is that if I look at the syntax of the procedure called what we are saying is that there is an identification associated with argument list. So at some point of time I am saying calls and procedures with argument list and what is my argument list? Argument list can be recursively defined as a list of arguments where we say that argument list is nothing but p list followed by e and then this is the base value. So this way I can, so I am not worried about whether my arguments are expressions or not because it could be a single variable or an expression depending upon how do we know and when we look at kind of passing mechanisms that will immediately come out. But at this point of time let us assume that I am talking about general expression but most of the time you actually have as an identity part but identity part also is a general expression. Now what are the things we need to do when I look at a sequence like this, when I look at something like this in my grammar loop? Several things. One that I need to create is something known as activation record. At this point of time I will not go into details of activation record that will come when I start in between one time four point procedure but basically what activation record is saying that corresponding to each procedure certain data has to be created on stack and what is the data? I need to have the values of local variables. I need to have values for all the arguments which are being passed. I need to have space for the return value and sometimes there may be resources which are associated with the procedure which invoke this particular procedure and therefore I need to save the machine shakers before I can start completing the procedure and therefore I need to have some space where all this information will be stored and that is always an activation record but we will look at the complete structure of activation record. Then we also have to evaluate all the arguments because some of these arguments would be expressions so I could be passing something like saying all a function with x plus y. So x plus y needs to be evaluated and then copied into the formal parameter. So I need to evaluate all the arguments then I must establish all the environment pointers. Now what are environment pointers? So basically environment pointers are the ones which are going to capture the scope information. So if I have for example nested procedures and functions, if I have a function f1 at this level and within this I have an f2, within this I have f3 and so on, some deep level of my screen and at some point of time I say that I want to invoke this particular procedure. Then I must know that what are the variables of f3 which are going to be fetched from within the scope of f3 and from within the scope of f2 and from within the scope of f1 and so on. And that is going to be some variables which are going to be global. So I must know for each of the variables within f3 that what is the environment from which I need to fetch and therefore I must add pointers to all those environments. And I must save status and return addresses. So I must know what are the values which are available with the registers. I must save them so that the registers can be then used for this procedure invocation and what my return addresses are and then after doing all this I then jump to building of the procedure and start executing the code of the procedure. So before I start executing code of the procedure I need to do a lot of things to set up the environment for calling the procedure and basically these things are the ones which need to be then which is what is known as the runtime system and generate code so that runtime system can effectively start utilizing this input. So procedure calls now as far as 3 address code is concerned what was the 3 address code I had for the procedure functions. So just to remind you what we have were two instructions one was a parameter where I said that t is a parameter and then another was etc. called id with some n where I said that I am invoking a procedure id with n arguments. So these are the only two things I had and rest of the things are going to be part of. So this part is the part of all the evaluation and this is really the part where I say that I need to create all these parameters and then I need to jump. So this is really the fourth part. So these are the things we do that we look at parameters we need to know whether parameters are being passed by reference or are being passed by value. There are many other mechanisms and we will look at what are the parameter passing mechanisms. So when I invoke the procedure I need to know what are the parameter passing mechanisms I have and pass by reference is going to be little more complex than all by value and therefore we need to go into details of more details of all by reference. Storage then I need to worry about whether I am going to statically allocate the storage or I am going to dynamically allocate the storage. Now some language is required that storage will be allocated statically and some language is required that it will be dynamically. You know of some examples of languages where I have dynamic allocation and static allocation. So for example in C is procedure allocation is static or dynamic. So if it is static what is going to happen is that if I have procedure p suppose I have function f1. So this is the allocation I allocate f1 on the stack. Now suppose f1 calls itself, f1 recursively calls itself what happens to all the local variables. Do I need to be initialize local variables in recursion? Yes, no. We do that how we do it in static allocation because this is the fixed storage for f1 and how many instances of f1 can be there on the stack? Potentially infinite depends on the recursion and therefore actually in C the storage is not static it is dynamic. So whenever so if you look at any language any modern language if you look at all class of languages this allocation for procedure is always dynamic. If you look at languages like portal, a portal started in static allocation that you can have a local variable you can exit out of the procedure that you can come back and you find that value of local variable is still available but then recursion is not possible. So these are the kind of questions we have to ask when we are dealing with procedure calls that whether parameters are passed by difference or not whether storage is statically allocated or dynamically allocated then I use all these arguments like then it says that what are the placeholders for the arguments I have? So these are really the placeholders for actual parameters then I call a procedure and we say that we are going to pass pointer to the first argument and saying that I have an argument being passed this particular procedure and pointer to any argument can be obtained by just using the proper offsets because if I just pass the argument to the first, pointer to the first argument then pointer to the arguments we calculated by number of bytes it takes. So when I start doing code generation and this is code generation only for this part and not for the things which is initialization of the static. So this part is actually fairly straightforward that I want to generate free address code and free address code means that first if I have an invocation like this first I will say that have code for evaluation of X plus Y and if once this code is generated there will be some location which is associated with this expression and then I will say that I have parameter T where what is T? T stores value of X plus Y. So this way I will have all the spaces for all the arguments and then I am going to generate a list of parameter which is three address statement and then store arguments in the list okay. So basically all these parameters are the arguments and then when I pass this particular instruction which says all ID list okay that time what will I do that I will say that for each item which is in the queue I am going to emit this instruction okay which is parameter instruction and then finally I am going to emit which will say that all ID which is this and I have now an argument to the list of parameters okay. So this is actually the much simpler part okay. So there is nothing more complex than this whenever I pass this I am saying that every time you have an expression here then you just append it to E place okay at the end of the queue and this one when I see the first argument I am just saying that I initialize okay. So this part as I said is pretty straightforward all I am going to do at end of these activities that I have code for expression evaluation okay and this will then after this I will create a list and then I will generate from the list these instructions sequence of these instructions and finally I will take the code with this function okay. So that really is not a complex problem okay. So for example now so let's take an example suppose I say that I want to invoke F1 where say X plus Y A plus BC okay this is what I want to invoke what is the kind of code I will generate for this I will say that T1 is X plus Y T2 is A plus B for C I don't require a temporary variable that is going to be right there and then I will say instructions like parameter T1 parameter T2 parameter C okay. So these are the three instructions I will generate from this particular Q which has been created of arguments and then I will say after this all F1 okay and what will I pass here either I can say that pointer to this and three arguments or if this list is there then I just pass this pointer to the list and I am done okay. So this is really the code generation for as far as this part is concerned but if you recall I said there were five six steps and this actually corresponds to the last step the first two steps I have not even looked at okay so what are those first few steps okay first few steps are actually part of what is known as runtime environment. So what is going to happen is let's understand what is happening in procedure invocation why procedures are treated slightly differently and our special cases okay one that I do not know whether a procedure or function is going to get invoked second thing I do not know whether it is required space so normally what is done is that no space is allocated third thing that happens is that for all the variables if you look at local variables I do space allocation once okay but for all the local variables of procedure I may have to do multiple allocations depending upon how many times they are invoked and in which environment they are invoked. So suppose a procedure is invoked recursively and n times regression goes deep n times then I have to do n coefficients of all those variables okay and therefore I do all that activity at runtime and not at the time okay but I generate sufficient code so that that code gets executed whenever the program is getting executed okay so that is what my runtime environment is so runtime environment basically is code generation strategy for the co-serious function and the second issue which will come as part of runtime environment is that at some point of time I will also do dynamic allocation of variables now many languages do not support dynamic allocation of memory but many languages do so when you have dynamic allocation of memory how do I allocate space at compile time I cannot so when you do a malloc for example you see and you say that allocate 512 bytes okay somebody has to then allocate that space to you okay it must be in your process space if it is not in your process space you cannot even access it okay so two things have to be managed by runtime environment one procedure function calls space for procedure function at runtime and second dynamic allocation of memory at runtime okay so that is the kind of code generation strategy we have so this gives me runtime environment is basically giving me a relationship between name and date of date of the target machine what does that mean this is now saying that suppose I say this variable X okay now where is this variable X this variable X will be somewhere in memory and different executions of this program will put this variable at different places so runtime environment will give me this mapping saying that every time I want to access X I should go through symbol table and symbol table will only give me an offset but not the base address and then I actually go through my page tables and access this every time I load this data into memory this mapping will keep changing okay so runtime environment is the one that is going to give me this relationship between the name and the data object of the target but runtime support package so when you do a manner and when you free the space okay that time this all this code will come into picture okay and then what we say now is that whenever I execute a program we say that or whenever I execute a function of procedure we say that I am actually putting an activation on the stack or I am saying that a new activation corresponding to that particular procedure is being created okay so what that means is that if procedure is recursive then a procedure may have several activations which are like so for example I just gave you this example that suppose I have a situation where I have inside f I again have all at one okay now depending upon how deep this procedure is called that will depend upon the conditions and the argument but what can happen is at the first time some activation of f1 is going to be on the stack and then next time it is called another activations and I keep on creating these activations of f1 on the stack okay and also the space for local variables every time will have to be replicated and then depending upon again which activation is currently being executed values of the local variables will keep changing in different stacks so if I am suppose this is a current execution and there is some local variable x whose value is changing or let us not confuse with arguments suppose there is some local variables that here whose value is changing in this particular invocation it will not change here right it will only change in this particular activation okay so this needs to be then managed by some time support okay so what we say is that if procedure is recursive there are several activations which may be alive at the same time so this is one sets of local variables and set of arguments and the set of machine statements and now we say that if there are two activations a and b two activations are different of the same procedure okay so a and b could be activations of the same procedure or they could be activations of two different procedures does not matter so beyond this point when I start looking at stack I do not really distinguish between the procedure name what I say is that each time a procedure is invoked and activation is created and I am only looking at now activations okay so now we say that if a and b are two activations then either their lifetime is going to be non-overlapping or it is going to be nested what does that mean what that means is that either a will start here some lifetime so if I just go around the timeline and my program is going to be I will say that lifetime of a starts here and ends here and then b starts here and ends here or it could be nested that means lifetime of a starts and then lifetime of b starts here and ends and a continues I will not have a situation where I say that a starts here and then b starts somewhere and then a finishes and b is continued what that means is that b was invoked by a but b is continuing and a finishes that's not possible okay so only two situations can occur either you have non-overlapping lifetime or you have nested lifetime these kind of lifetimes are not possible for the activations here okay so a and b are activations of two procedures and the lifetime is either non-overlapping or is nested a procedure is recursive if you can have multiple activations of the same procedure at the same okay these are the only two things we need to be concerned with nothing okay so again now coming to the definition of the procedure once again okay our abstraction for procedure is going to be now slightly different for the old generation purposes what we are saying is procedure is nothing but a declaration okay so procedure is declaration of the name which returns the value of certain type and which takes a list of arguments what about the body of the procedure that is a statement which is associated with the procedure that needs to be executed okay so header has to be treated differently than the body now we have already seen how to do coordination for the body part okay so that is really of no issue anymore the only issue is of the header okay and that has to be treated carefully so procedure definition is a declaration that is meant to associate and identify with the statement which is the procedure body so when I look at this FXY I am only really interested in this type what is the return type of F1 what is the procedure name what is the argument list and what is the type of each argument okay what about the body part body part we know is just going to report and we know how to handle that okay we have already done coordination for that part okay and whenever a procedure name appears in an executable statement then we say that it is going to be called at that time so when I say that all F1 this is where I am calling it and this is really the declaration okay and I also have what I know what we know as arguments or formal and actual parameters so whenever I have definition like this I will take that these are my in definition these are called formal parameters and when I invoke so when I am invoking it for example with this so this definition I cannot have X plus 5 kind of situation here but suppose I say I am invoking it with 2 plus 3 okay so this is my formal parameter and my actual parameter is this expression 2 plus 3 okay so I am formal parameter and actual parameter these are standard definitions you will find it any text one programming language is in compliance so actual parameters are the ones which appear in when procedure is going to be called okay now I want to keep this information saying that in which order these activations are to be created okay so I am going to create few data structures we need and the first data structure we look at is activation piece so activation piece basically saying that how control is going in my program when procedures are getting invoked okay now whenever you think of a tree you immediately can see that what are the sub parts of a tree you have to have roots root nodes you have to have the leaf nodes and you have to have the inner nodes okay and then like if I have definition of each of these then I know what tree is okay so the root corresponds to the invocation of the main program and then each internal node corresponds to invocation of a function of procedure and what is the leaf node leaf node is the one which does not invoke any other function just execute something and returns control but internal node is the one that is corresponding to invocation of another procedure of function okay now what about edges okay edges are telling you that which function of procedure is invoking something else okay now that is a standard part of this tree definition okay in activation when we talk of activation we will also talk about left and right systems okay so we will say that in this order okay if I have two activations so execution of procedure starts at the beginning of the body and it returns control at a place where procedure was called okay and a tree is the one which is used to depict this situation so root represents activation of the main tree each node represents activation of a procedure and if node A is parent of node B then we say that control closed A to B okay but now I put another condition which says that if node A is to the left of B then the lifetime of A occurs before lifetime okay so if I have a situation like this what this means is that corresponding to this suppose this is where my invocation of main and then this is lifetime of A and this is lifetime of B this is how the tree is going to look corresponding to this particular procedure okay so left and right sibling relationship is telling me that what happened earlier and what is currently active okay so this way I can capture the full information about the control flow in my program in which order my procedure will go okay so I am not going into the body of the procedure but I am interested in looking at the call graphs and the headers okay of the procedures this is what I am capturing the activation tree information okay so let us take an example and try to create an activation tree for this so here is some code where we say that I have this sort program and then this program we have seen earlier like quick sort we also looked at when we are creating symbol table for this okay so we have this procedure read array then I have a function which is partitioning which is taking two arguments y and z of type integer returning the type integer value which has its own local variable and then again I have quick sort and within quick sort I call partition which returns the value then I interstitially call quick sort and in the main program I first initialize my array and then call quick sort okay now can we create an activation tree for this program okay so let us try to create an activation tree tell me how we will activation tree for this so let me erase this part and let us start drawing the activation tree so it is clear that the first thing will be the sort okay and sort is calling the read array and after read array finishes then I am calling quick sort one nine okay and when I go to quick sort then what do I do I call partition so this calls partition with one nine and now what what is the next thing that happens what is the next node I draw what is the next node I draw quick sort with so first question can I get an activation tree for this program just looking at does it have a unique activation tree if I do not have a unique activation tree what is it that I am drawing so that will be the first thing you should object to if I actually do not know what activation tree for this will be it will depend upon the data I have right so there is nothing unique activation tree it will depend upon the data you supply so activation tree really does not belong to the program I cannot really create it to compile that only when my program is executed at that point of time I will create an activation tree and for different data sets the same program will give me different activation trees right so activation tree is not just the property of the program it is property of then this program gets executed with certain data sets so that is the first thing you have to remember we are talking about now how long we are talking about just with the pipeline so assuming few things that some data is being returned this is how the activation tree may look but this is only one of the instances of activation tree for different data set activation tree could be different that I will first call need array and then I will call quick sort which is going to call partition and now assuming that partition returns value 4 but that is the property of the data so assuming that partition returns value 4 then I am going to call quick sort 1 and then quick sort 1 is going to call partition 1 3 which again lets assume that it returns value 1 I do not know what it will return for a different data set I am going to call quick sort 1 9 and then I am going to call quick sort 2 3 and so on which will again call partition and so on so this is how the control may flow in this particular tree so first thing you have to remember here is that this activation tree is corresponding to that program for a data set and it could be different second thing is that at some point of time you will realize that I do not have to remember the whole this tree now lets look at some random node in this suppose I say that this is the current active procedure that I am executing partition 5 9 if I say that this is the current activation procedure then from this definition when I created I said that left signaling and right signaling what are the procedures which have already been executed and what are the procedures which are which have not been executed and what are the procedures which are currently executed by looking at this tree in this particular data set if I say this is the currently executing procedure what are the procedures which have been which have finished execution so actually all this has finished execution this part is get to execute but these are the current active procedures so if I just take the path from root to this particular procedure that gives me all the procedures which are active everything on left of that path is already inactive they have finished execution and everything on right of that is get to be created so I will only be interested therefore in knowing my current path and knowing therefore which are the current procedures which are active procedures which have finished execution are of no consequence beyond that part and therefore I do not now need to remember the full tree I only need to remember that current is what is active it is what 1 9 is active 5 9 is active at partition 5 9 is active this is the only thing I need to remember and for this obvious data structure we use this stack so what we can do is and every time an activation is called and activation is created I push it on the stack every time it finishes I pop it from the stack so if I then therefore look at this activation tree and say that this is on top of stack then I know immediately that below this this is on the stack below that this is on the stack below this this is on the stack and nothing else like this on the stack this point is clear so what we are using is control stack it says that flow of control in the program corresponds to really this that first traversal of the activation tree and we use this stack called control stack to keep track of only the line procedures not all the procedures so we are only interested in the procedures which are currently lying and I keep them on the stack and then we say that whenever a node is an activation begins you push the nodes on the stack and after it finishes node is at the top after it finishes then I pop it from the stack and if node n is at top of stack then stack contains the nodes which are along the path from n to the root right okay so these are the only activations I will be interested in and not everything else okay so continuing on this information okay now let's look at that how do I capture scope information now scope is something which will keep changing because of front-end bindings so if I say that this is there is some current procedure which is active and I am looking at variables within that then binding of those variables will be determined by the scope rules are now if I look at scope rules okay there is something called lexical scoping or syntactic scoping which says that I can determine all my scoping rules by looking at the program listing I don't have to worry about execution of the program and then their languages will say that scope is going to be so we look at both static scoping or lexical scoping as well as dynamic scoping so let's start this discussion with assuming that I have lexical or static scoping so declaration is syntactic construct which associates information to the name okay so first thing that happens is you have to take every class of languages all these are going to have an explicit declaration of a name and therefore a type associated with this okay so you will have something like a variable which will be a keyword in this language okay and followed by a name of an identifier and a type name or you have languages like Fortress okay where you may have explicit declarations but you may also have implicit declarations okay now I am not dealing with languages which are interpreted so their languages which are interpreted and which again have implicit type names okay but since you are not dealing with interpreted languages we are only interested in compiled languages at this point of time therefore I have picked up this example if you look at languages like basic and Python and so on okay there also declarations are implicit but then they are interpreted okay so we will leave that for the time okay because then that includes something else okay so there what happens is that although declaration is implicit but there is some assumption which is made okay so assumption for example Fortress makes is I, J, K, M and O are or any variable starting with these letters they are integers and any variable starting with any other letter than these six is real unless you explicitly declare it okay and in fact most of the time you will notice that when people write programs this tradition for some reason continues because when the initial Fortress programs are written I was the first integer variable or first letter which was associated with an integer variable and therefore if you see everywhere everyone writes for I1 to N okay because it was very simple thing to do important and therefore other languages other programmers of other languages have picked up this tradition so even now when you write something in C or in basket you still say for I1 to N where I may be a totally meaningless variable okay most of the time people will those who are in software engineering and are worried about quality testing of program they will say that your counter name should be meaningful name okay but people continue to use I there I will be totally non-descript name just associating an integer with it okay so I is assumed to be an integer in languages like Fortress and there may be independent declarations of the same name in a program so what may happen is that same variable X can occur at multiple places in the same program but in different schools will differentize this okay so I need to worry about as compiler writer that how do I associate this variable with the right scope because if I just say X is meaningless unless I say that X occurs in a particular scope okay so there may be independent declarations of the same name in a program that is because of the scope rules and scope rules are the ones which determine which declaration is going to apply to a particular name okay so we need to know this and how does name binding happen at some pie time and run time okay that you have something like a name and a scope range association okay how do I find out which name associates with the scope range that is provided by the environment that means this is provided by the scope okay but what is the value associated with that particular scope range that is provided by the state of the program and the program is executing at that point of time the value in this particular location will be changed okay so this finally comes from the environment and we are only interested in this finally okay so we need to see how to deal with the environment how to deal basically scoping rules to make sure that I am always able to find the right binding once I have allocated a space to this then I can always actually go to this particular symbol table find out what is the address and then determine what is the value in that particular location okay so this is very important that we are able to for each name we are able to bind environments with it so that I can go to the right scope okay this here I mean what is this figure is kind of definite yes okay so let us look at now when I say that I am now creating space for a program okay so when I say that I compile a program some space gets allocated to my process okay now what are the things what are the kind of parts I have in my program okay so I obviously have a target code okay then I have data object so this is the machine code and the data object and then I need two more parts okay where one where I can grow my stack I can have information about the procedures and then I need one part where I can keep all my time in data structures okay which is the heap okay and if this is a total space which is available to me normally you will say that my code and static data I am doing here at the beginning of this allocation and then stack and heap will start going towards each other from two different types okay and this obviously data structure has an obvious advantage okay that if I if I change this data structure for example and rather than fix space for stack and heap what may happen is that I may say that I divide this as code my data stack and heap okay and I say that stack and heap grow in this direction I can end up facing this space possible that my stack will not be full but heap becomes full or heap will not be full and stack becomes full okay but this data structure gives me an advantage because as long as there is some space available either stack or heap can grow okay and now this should also give you a hint now that if you write a program now many times you must have seen these messages that the program is getting executed and then suddenly you say stack overflow what that means is potentially you have gone into an infinite recursion and beyond this stack is not going to grow and say that I have run out of stack space or it says heap overflow that means you are allocating too many dynamic data structures and you are not freeing it and at some point of time you go and get this boundary and say that beyond this your heap is not able to grow okay and this is always a finite state okay it depends upon the model what does it depend upon so most machines today we will say that whatever is the address space you can use all of that okay if you have a 32 bit machine then I can use this total of 4 gigabytes of space for this okay it depends on the address space okay but there are some machines which will restrict saying that each process can have only limited space okay so it is determined by really the operating system okay so that is how we are going to lay out so now we have seen part of this how do we generate code we have seen part of this how do we allocate space for static data we haven't seen this and we haven't seen this so basically in my runtime system we need to deal with how to manage stack and how to manage these are the 2 things we need to deal because if I can deal with this then I know how to manage all the space which has been allocated to okay so what we are dealing with is that this part static data was allocated and all this information was kept in the symbol table code generation we have already seen how to do code generation but this is the part we have not yet seen and therefore we are now getting into this part so first thing we will start with stack and then we will look at the need part to start with stack the first thing I need to know is that for stack management what are the things which are getting allocated there we need activation records so I first must know how my activation record looks and then only I will be able to manage my stack part so how does my activation record look what is the kind of information it contains so first let me give you a layout of my activation record and then we will discuss each of these so this is how a typical activation record in a program may look what are the spaces you put in this activation this is not in any particular order we will discuss order slightly later but this is the information you are going to put in each activation so I have space for temporary release so basically what will happen is that if I look at some port in the procedure I need certain temporary locations to evaluate all those expressions and I put some space for all those temporary locations then each procedure and function is going to have certain local data and I need to put all the information about all the space for local data in this activation record also I need to return certain values so I need location where I can put the return values and I need location where I can copy all the arguments so these are really the parameters now what about this I have these machine status then I have access link and I have control link so if you look at this so this part and this part actually relates to the body of the function and procedure but if you look at this part machine status what it means is that each machine is going to have certain resources so for example suppose you say that I have 16 registers now registers are also going to be used for temporary locations so some registers are like PC value and status registers and so on they correspond to the program but when you now say that I have registers for temporary locations and procedure goes B and A is keeping certain variables in that case now as soon as control comes to B you know that code for A will not get executed and therefore if you keep a register still bound to variables of A you are actually wasting a resource so what I can do is before I start executing B I can say say values of all the registers which can be free and after I finish execution of B I can go and copy those values back into the registers and continue execution of that case so I need to save information about the machine status I need to save all those resources I need to have some space where I can save all those resources so this really is the space for saving all the machine status and what are these links access link is the one which tells me that from where do I get scope of a particular variable so when I say that use a variable X access link is going to tell me that this particular value of X can be found so it could either be in the static data or it could be activation of one of the procedures which invoke and the control links tell me that which procedure invoke me and where the control has to load I so typically this is the information I am going to have on activation interface and every time I create a procedure I invoke a procedure I need to create this data structure initialize it and push it on the stack and every time a procedure returns control I need to copy these values back into the parent activation and then DLP so now I mean if you recall we started with by saying that procedure corresponds to an activation so you can see that what this activation is also it does not have any code it is only dealing with the headers and the data okay procedure code is going to be where is the code of procedures code and I go back to in this where do I store the code for procedures is it in the stack or in the code area procedure has a body corresponding to that I will have a machine code where do I store that in this particular code area or the stack area that code is in the code area stack area only contains the data so stack area basically corresponds to the data which will be active by my procedure is executed so all the variables corresponding to the procedures are going to be here but all the code corresponding to the code is the main program as well as all the procedures that is going to be here so code will all execute or in this case so that is what you have to remember that we are code is and we are data so this is how my activation record and now what are the issues I need to worry about when I am designing my activations and when I am designing my activations access link at this point of time only thing I can explain at this point of time is without going into details so look at a situation like this so suppose I say I have a main program and within main I have let's say I have in tie here then I have in tie here and then within this so let me deal with first the language is not like C but which have deep nesting of two series of functions so within this suppose I have now a declaration of a function let's say float F with its own argument list then the body of this float and here I say X is the sign I plus 5 okay and I not declare it in F suppose I have a program now when I am trying to access I from where do I get this value of I I need to know the location where I is I is obviously not in my local scope it is not in local variable so it will not be in my activation but it will be in some other activation it will either be in this activation or it will be the static activation okay how do I access this now I don't know how many times F has given you okay so my stack will look something like this I will have some so let's say code and static data is here okay and after that somewhere I have activation of F and when I am in this activation that time I say I want to modify this I want to assign to X whatever is value of 5 plus 5 how do I access I okay so activation record is basically saying that I now have enough code to say that I must have when I created this activation of that I must have created a link saying that because of my scope rules this I is coming either from this or from this okay so suppose this was not I this was J then I am saying that this I is actually a global variable and therefore I must have a pointer to that this pointer basically is nothing but access so whenever I am pushing my activations okay I need to have these accesses that's the only thing okay but it is off saying that how do we create accesses okay but this is the basic definition of access which tells me that using the scope information which variable can be accessed and which variable cannot be accessed so how do I have language that has been nesting you mean a language like JavaScript any language you say is nested procedure I will go in fact even C C NCC does not have nested procedures and right actually nested procedures in C and use GCC to compile with him but I mean we should not be writing those kind of programs because those are not standard programs but GCC works for that all the algorithm class of languages will have this okay including modular over on Pascal objected in object C and so on they will all work nested deep level of nesting deep level of nesting is basically saying that nested procedure inside a procedure in C you can in Java you can right okay so I think so before I will take up the next topic I think we will have to wait for the next class so let's stay here today and next class we will start this system