Compiler Construction
Spring 1999
Assignment IV

Due : April 12.

1. From text: problem 6.26. 

2. One of the important run-time attributes of a subprogram is the size of
its activation record. Modify the tree-walker routine to compute the size in
bytes of the activation record for a function or procedure. Include the size
of the formals and of all the declared variables in the subprogram.  For
purposes of this assignment, consider only scalar types and one-dimensional
arrays with static bounds. For an array type, the attribute First_Index is
a node that describes the discrete type that is used to index the array. The
Etype of such a node is an entity  that denotes a type or subtype. For a
discrete type, the attribute Type_Low_Bound and Type_High_Bound provide the
bounds that you need. They can be expressions in general, but for the
purposes of this assignment they will be literals whose value you can use to
compute the space occupied by an object of that type.

Full details on the representation of arrays (and everything else) can be
found in the spec. of Einfo. Array type declarations are analyzed in
sem_ch3, and expressions involving arrays are analyzed in sem_ch4 (analyze_
indexed_expression) and sem_res (resolve_indexed_expression).

Input to the tree-walker should be a subprogram body, or a package that
contains several of them. The output should be the name of the subprogram
and the size in bytes of its activation record. You should add 12 to the
value you compute, 4 for the return address, 4 for the static link, and
4 for the saved stack pointer.