Initial revision
[sbcl.git] / src / compiler / lexenv.lisp
1 ;;;; the representation of a lexical environment
2
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
11
12 (in-package "SB!C")
13
14 (file-comment
15   "$Header$")
16
17 #!-sb-fluid (declaim (inline internal-make-lexenv)) ; only called in one place
18
19 ;;; The LEXENV represents the lexical environment used for IR1 conversion.
20 ;;; (This is also what shows up as an ENVIRONMENT value in macroexpansion.)
21 #!-sb-fluid (declaim (inline internal-make-lexenv)) ; only called in one place
22 (def!struct (lexenv
23              ;; FIXME: should probably be called MAKE-EMPTY-LEXENV or
24              ;; MAKE-NULL-LEXENV
25              (:constructor make-null-lexenv ())
26              (:constructor internal-make-lexenv
27                            (functions variables blocks tags type-restrictions
28                                       lambda cleanup cookie
29                                       interface-cookie options)))
30   ;; Alist (name . what), where What is either a Functional (a local function),
31   ;; a DEFINED-FUNCTION, representing an INLINE/NOTINLINE declaration, or
32   ;; a list (MACRO . <function>) (a local macro, with the specifier
33   ;; expander.)    Note that Name may be a (SETF <name>) function.
34   (functions nil :type list)
35   ;; An alist translating variable names to Leaf structures. A special binding
36   ;; is indicated by a :Special Global-Var leaf. Each special binding within
37   ;; the code gets a distinct leaf structure, as does the current "global"
38   ;; value on entry to the code compiled. (locally (special ...)) is handled
39   ;; by adding the most recent special binding to the front of the list.
40   ;;
41   ;; If the CDR is (MACRO . <exp>), then <exp> is the expansion of a symbol
42   ;; macro.
43   (variables nil :type list)
44   ;; Blocks and Tags are alists from block and go-tag names to 2-lists of the
45   ;; form (<entry> <continuation>), where <continuation> is the continuation to
46   ;; exit to, and <entry> is the corresponding Entry node.
47   (blocks nil :type list)
48   (tags nil :type list)
49   ;; An alist (Thing . CType) which is used to keep track of "pervasive" type
50   ;; declarations. When Thing is a leaf, this is for type declarations that
51   ;; pertain to the type in a syntactic extent which does not correspond to a
52   ;; binding of the affected name. When Thing is a continuation, this is used
53   ;; to track the innermost THE type declaration.
54   (type-restrictions nil :type list)
55   ;; The lexically enclosing lambda, if any.
56   ;; 
57   ;; FIXME: This should be :TYPE (OR CLAMBDA NULL), but it was too hard
58   ;; to get CLAMBDA defined in time for the cross-compiler.
59   (lambda nil) 
60   ;; The lexically enclosing cleanup, or NIL if none enclosing within Lambda.
61   ;;
62   ;; FIXME: This should be :TYPE (OR CLEANUP NULL), but it was too hard
63   ;; to get CLEANUP defined in time for the cross-compiler.
64   (cleanup nil)
65   ;; The representation of the current OPTIMIZE policy.
66   (cookie *default-cookie* :type cookie)
67   ;; The policy that takes effect in XEPs and related syntax parsing functions.
68   ;; Slots in this cookie may be null to indicate that the normal value in
69   ;; effect.
70   (interface-cookie *default-interface-cookie* :type cookie)
71   ;; an alist of miscellaneous options that are associated with the lexical
72   ;; environment
73   (options nil :type list))