# Ullman (Compiler Design) Edition 2 Exercise 6.5 Question 2 (Page No. 399)

1 vote
236 views
As in Ada, suppose that each expression must have a unique type, but that from a subexpression, by itself, all we can deduce is a set of  possible types. That is, the application of function $E_{1}$ to argument $E_{2}$ , represented by $E\rightarrow E_{l}(E_{2})$, has the associated rule

$E.type=\{t\mid \text{for some$s$in} \:E_{2}.type,s\rightarrow t\: \text{is in}\: E_{1}.type\}$

Describe an SDD that determines a unique type for each subexpression by using an attribute $type$ to synthesize a set of possible types bottom-up, and, once the unique type of the overall expression is determined, proceeds top-down to determine attribute $unique$ for the type of each subexpression.

## Related questions

1
114 views
Assuming that function $widen$ in Fig. $6.26$ can handle any of the types in the hierarchy of Fig. $6.25(a)$, translate the expressions below. Assume that c and d are characters, $s$ and $t$ are short integers, $i$ and $j$ are integers, and $x$ is a float. $x=s+c$ $i=s+c$ $x=(s+c)\ast(t+d)$
Generalize formula $(6.7)$ to multidimensional arrays, and indicate what values can be stored in the symbol table and used to compute offsets. Consider the following cases: An array $A$ of two dimensions, in row-major form. The first dimension has indexes running from $l_{1}$ ... has indexes running from $l_{j}$ to $h_{j}$.The same as $(c)$ but with the array stored in column-major form.
$A$ real array $A[i, j, k]$ has index $i$ ranging from $1$ to $4$, index $j$ ranging from $0$ to $4$, and index $k$ ranging from $5$ to $10$. Reals take $8$ bytes each. Suppose array $A$ is stored starting at byte $0$. Find the location of: $A[3,4,5]$ $A[1,2,7]$ $A[4,3,9]$ if $A$ is stored in column-major order.
$A$ real array $A[i, j, k]$ has index $i$ ranging from $1$ to $4$, index $j$ ranging from $0$ to $4$, and index $k$ ranging from $5$ to $10$. Reals take $8$ bytes each. Suppose array $A$ is stored starting at byte $0$. Find the location of: $A[3,4,5]$ $A[1,2,7]$ $A[4,3,9]$