-;;; The ENVIRONMENT structure represents the result of environment analysis.
-(defstruct environment
- ;; the function that allocates this environment
- (function (required-argument) :type clambda)
- ;; a list of all the lambdas that allocate variables in this environment
- (lambdas nil :type list)
- ;; a list of all the lambda-vars and NLX-Infos needed from enclosing
- ;; environments by code in this environment
+;;; A PHYSENV represents the result of physical environment analysis.
+;;;
+;;; As far as I can tell from reverse engineering, this IR1 structure
+;;; represents the physical environment (which is probably not the
+;;; standard Lispy term for this concept, but I dunno what is the
+;;; standard term): those things in the lexical environment which a
+;;; LAMBDA actually interacts with. Thus in
+;;; (DEFUN FROB-THINGS (THINGS)
+;;; (DOLIST (THING THINGS)
+;;; (BLOCK FROBBING-ONE-THING
+;;; (MAPCAR (LAMBDA (PATTERN)
+;;; (WHEN (FITS-P THING PATTERN)
+;;; (RETURN-FROM FROB-THINGS (LIST :FIT THING PATTERN))))
+;;; *PATTERNS*))))
+;;; the variables THINGS, THING, and PATTERN and the block names
+;;; FROB-THINGS and FROBBING-ONE-THING are all in the inner LAMBDA's
+;;; lexical environment, but of those only THING, PATTERN, and
+;;; FROB-THINGS are in its physical environment. In IR1, we largely
+;;; just collect the names of these things; in IR2 an IR2-PHYSENV
+;;; structure is attached to INFO and used to keep track of
+;;; associations between these names and less-abstract things (like
+;;; TNs, or eventually stack slots and registers). -- WHN 2001-09-29
+(def!struct (physenv (:copier nil))
+ ;; the function that allocates this physical environment
+ (lambda (missing-arg) :type clambda :read-only t)
+ ;; This ultimately converges to a list of all the LAMBDA-VARs and
+ ;; NLX-INFOs needed from enclosing environments by code in this
+ ;; physical environment. In the meantime, it may be
+ ;; * NIL at object creation time
+ ;; * a superset of the correct result, generated somewhat later
+ ;; * smaller and smaller sets converging to the correct result as
+ ;; we notice and delete unused elements in the superset