1 ;;;; This file contains compiler code and compiler-related stuff which
2 ;;;; can be built early on. Some of the stuff may be here because it's
3 ;;;; needed early on, some other stuff (e.g. constants) just because
4 ;;;; it might as well be done early so we don't have to think about
5 ;;;; whether it's done early enough.
7 ;;;; This software is part of the SBCL system. See the README file for
10 ;;;; This software is derived from the CMU CL system, which was
11 ;;;; written at Carnegie Mellon University and released into the
12 ;;;; public domain. The software is in the public domain and is
13 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
14 ;;;; files for more information.
18 ;;; FIXME: Shouldn't SB!C::&MORE be in this list?
19 (defconstant-eqx sb!xc:lambda-list-keywords
20 '(&optional &rest &key &aux &body &whole &allow-other-keys &environment)
23 "symbols which are magical in a lambda list")
25 ;;;; cross-compiler-only versions of CL special variables, so that we
26 ;;;; don't have weird interactions with the host compiler
28 (defvar sb!xc:*compile-file-pathname*)
29 (defvar sb!xc:*compile-file-truename*)
30 (defvar sb!xc:*compile-print*)
31 (defvar sb!xc:*compile-verbose*)
33 ;;;; miscellaneous types used both in the cross-compiler and on the target
35 ;;;; FIXME: The INDEX and LAYOUT-DEPTHOID definitions probably belong
36 ;;;; somewhere else, not "early-c", since they're after all not part
39 ;;; the type of LAYOUT-DEPTHOID slot values
40 (def!type sb!kernel::layout-depthoid () '(or index (integer -1 -1)))
42 ;;; possible values for the INLINE-ness of a function.
44 '(member :inline :maybe-inline :notinline nil))
45 (defparameter *inlinep-translations*
47 (notinline . :notinline)
48 (maybe-inline . :maybe-inline)))
50 ;;; the lexical environment we are currently converting in
52 (declaim (type lexenv *lexenv*))
54 ;;; *FREE-VARIABLES* translates from the names of variables referenced
55 ;;; globally to the LEAF structures for them. *FREE-FUNCTIONS* is like
56 ;;; *FREE-VARIABLES*, only it deals with function names.
57 (defvar *free-variables*)
58 (defvar *free-functions*)
59 (declaim (hash-table *free-variables* *free-functions*))
61 ;;; We use the same Constant structure to represent all equal anonymous
62 ;;; constants. This hashtable translates from constants to the Leafs that
65 (declaim (hash-table *constants*))
67 ;;; miscellaneous forward declarations
68 (defvar *code-segment*)
69 #!+sb-dyncount (defvar *collect-dynamic-statistics*)
70 (defvar *component-being-compiled*)
71 (defvar *compiler-error-context*)
72 (defvar *compiler-error-count*)
73 (defvar *compiler-warning-count*)
74 (defvar *compiler-style-warning-count*)
75 (defvar *compiler-note-count*)
76 (defvar *converting-for-interpreter*)
77 (defvar *count-vop-usages*)
78 (defvar *current-path*)
79 (defvar *current-component*)
81 (defvar *interface-policy*)
82 (defvar *dynamic-counts-tn*)
85 (defvar *event-note-threshold*)
89 (defvar *info-environment*)
91 (defvar *source-info*)
92 (defvar *trace-table*)
93 (defvar *undefined-warnings*)
96 ;;;; miscellaneous utilities
98 ;;; Delete any undefined warnings for NAME and KIND. This is for the
99 ;;; benefit of the compiler, but it's sometimes called from stuff like
100 ;;; type-defining code which isn't logically part of the compiler.
101 (declaim (ftype (function ((or symbol cons) keyword) (values))
103 (defun note-name-defined (name kind)
104 ;; We do this BOUNDP check because this function can be called when
105 ;; not in a compilation unit (as when loading top-level forms).
106 (when (boundp '*undefined-warnings*)
107 (setq *undefined-warnings*
108 (delete-if (lambda (x)
109 (and (equal (undefined-warning-name x) name)
110 (eq (undefined-warning-kind x) kind)))
111 *undefined-warnings*)))
114 ;;; to be called when a variable is lexically bound
115 (declaim (ftype (function (symbol) (values)) note-lexical-binding))
116 (defun note-lexical-binding (symbol)
117 (let ((name (symbol-name symbol)))
118 ;; This check is intended to protect us from getting silently
119 ;; burned when we define
122 ;; (DEFUN FOO (X) (+ X *FOO*))
127 ;; and then we happen to compile bar.lisp before foo.lisp.
128 (when (and (char= #\* (aref name 0))
129 (char= #\* (aref name (1- (length name)))))
130 ;; FIXME: should be COMPILER-STYLE-WARNING?
131 (style-warn "using the lexical binding of the symbol ~S, not the~@
132 dynamic binding, even though the symbol name follows the usual naming~@
133 convention (names like *FOO*) for special variables" symbol)))