Given a function
of Definition 1 and the static slicing function
, colors of all the subexpressions in the function body
can be defined as follows.
And, having the static slicing function
computed, color of
each subexpression can be directly analyzed from this definition.
ApLabels is the set of labels attached to the accumulation parameters of recursive calls.
Whenever an expression
uses any value of the accumulation parameters, labels in
ApLabels are included in the static slice for
. ApUse is the set of
such expressions.
is the set of expressions which do not
use any value of the accumulation parameters. RecResults is the set of labels of
variable patterns to which results of recursive calls are assigned. RecResults
is divided into RedResults and BlackResults, where RedResults are
labels of variable patterns which use no accumulation parameter, and BlackResults
are labels of variable patterns which use some accumulation parameters.
Using above sets, the set of subexpressions which belong to each color can be directly computed.
,
and
expressions
do not use the value of the accumulation parameters. So, their labels are included in
.
,
and
expressions can use the value of the accumulation
parameters. So, their labels are included in
.
Figure 5 is the result of coloring analysis of the inorder program.
Analyzed colors are attached to every subexpression, where W, R, B,
Y, G and Bk represent
,
,
,
,
, and
respectively.
In the program, t1 and t2 are
results because value of the accumulation parameter
n is used to compute the first result. And s1 and s2 are
results because
n is not used to compute the size of the tree. Since
subexpression ((1:W+n:Y):Y+s1:B):Y evaluates the
accumulation parameter of the second recursion using the accumulation parameter n,
it is a
expression and must be computed along recursive calls.
Expression ((s1:R+s2:R):R+1:W):R uses
results and is used to evaluate
results. So it belongs to
and
values from the expression must be computed along the return of recursive calls.
In the result part of let expression,
though (n:G+s1:B):G uses an accumulation parameter and a
result, its value
is not used to compute any accumulation parameter or
result. So, values of (n:G+s1:B):G
can be computed using map skeleton after
and
expressions are evaluated.