This phase consists of four passes over the CPS version of the program. As with the earlier preliminary analysis, each pass determines one related set of information and attaches this information to nodes of the program tree and to property lists.
The first pass (CENV-ANALYZE) analyzes variable references for the CPS
version in a manner similar to that of the first pass of the preliminary
analysis. The results of this previous analysis are used here in the case of
trivial expressions; with this exception the analysis is redone completely,
because additional variables are introduced by the CPS conversion. (None of
these new variables can appear in an ASET', however, and so the analysis of
written variables need not be done over.) In addition, for each variable
reference which does not occur in the function position of a combination, we mark
that variable with a non-nil VARIABLE-REFP property, used later to determine
whether closures need to be created for known functions.
The second pass (BIND-ANALYZE) determines for each LAMBDA-expression
whether a closure will be needed for it at run time. There are three
possibilities:
(1) If the function denoted by the LAMBDA-expression is bound to some
variable, and that variable is referenced other than in function position,
then the closure is being treated as data, and must be a full (standard CBETA
format) closure. If the function itself occurs in non-function position other
than in a LAMBDA-combination, it must be fully closed.