Lecture #7 Programming Languages MISHRA 95

G22.2210

Programming Languages: PL

B. Mishra
New York University.


Lecture # 7

---Slide 1---
Runtime Representations

---Slide 2---
Dangling Reference Problem

---Slide 3---
Static Storage Management

---Slide 4---
Activation Record

---Slide 5---
Static Storage Management in FORTRAN

---Slide 6---
Stack Based Modern Languages
(ALGOL-like)

---Slide 7---
Implications of
Call-Time Allocation of AR's

---Slide 8---
Procedure Call

Procedure

Call to P

---Slide 9---
Activation Records (AR)
Stack Based Storage Management

Algol and its relatives:

---Slide 10---
Up-Level Addressing and the Display

---Slide 11---
Reference to the Global Variable

---Slide 12---
Up-level Addressing Problem
Intermediate Non-Local Variables

Algol, Pascal, Ada, --- Scope Rules

    procedure P;
      begin
      var x, y: T1;

      procedure Q;
      begin
        var z: T2;

        procedure R;
          begin
          var: a, b: T3;
            ...       <----------z is accessible in Q & R
          end;
          ...         <----------x, y are accessible in P, Q & R
      end;
      ...
      end;

---Slide 13---
Displays

---Slide 14---
Displays and Setting Them Up

---Slide 15---
Setting the Displays

---Slide 16---
Sample Display Configuration

---Slide 17---
Displays with
Procedure as Parameters

    procedure Q(procedure F);        {LexLev(Q) = n}
      begin ... F(x) ... end;

    procedure P;                     {LexLev(P) = n}
      var a, b: T;
      procedure R(y: T); begin ... a ... end;
      begin
      ... P; ... Q(R); ...           {LexLev(R) = n+1}
      end;
    { Q calls R --- LexLev(R) > LexLev(Q) }

---Slide 18---
Procedure Parameters (Contd.)

---Slide 19---
Allocation of Assignable Data Types

---Slide 20---
AR for Non-Static Arrays

---Slide 21---
Variant Records

\

---Slide 22---
Parameter Passing

---Slide 23---
Evaluation of Actual Parameter List

---Slide 24---
Call-By-Value

---Slide 25---
Call-By-Reference

---Slide 26---
Call-By-Value/Result

---Slide 27---
Call-By-Name [Algol60]

---Slide 28---
Thunks

Note

---Slide 29---
Dynamic Storage

   type ref = ^T;
   var  x  : ref;

   procedure P; begin ... new(x) ... end;

---Last Slide---
Heap Allocation

Storage whose extent is not tied to a particular scope cannot be allocated on the stack.

[End of Lecture #7]