105
105
;;; Check if the symbol has a symbol macro
107
(defun chk-symbol-macrolet (symbol)
109
((not (symbolp form)) form)
111
;; At the end, loof for a DEFINE-SYMBOL-MACRO definition
112
(let ((expansion (get-sysprop form 'si::symbol-macro)))
114
(setq form (funcall expansion form nil))
115
(return-from chk-symbol-macrolet form))))
116
;; Search for a SYMBOL-MACROLET definition
118
(when (eq (first v) form)
119
(setq form (second v))
122
((eq (var-name v) form)
123
;; Any macro definition has been shadowed by LET/LET*, etc.
124
(return-from chk-symbol-macrolet form))))))
126
;;; During Pass 1, *vars* emulates the environment: it holds a list of var
127
;;; objects and the symbols 'CB' (Closure Boundary) and 'LB' (Level Boundary).
128
;;; 'CB' is pushed on *vars* when the compiler begins to process a closure.
129
;;; 'LB' is pushed on *vars* when *level* is incremented.
130
;;; *GLOBALS* holds a list of var objects for those variables that are
131
;;; not defined. This list is used only to suppress duplicated warnings when
132
;;; undefined variables are detected.
107
(defun chk-symbol-macrolet (form)
109
(when (not (symbolp form))
111
(let ((new-form (macroexpand-1 form *cmp-env*)))
112
(when (eq new-form form)
114
(setf form new-form))))
134
116
(defun c1make-var (name specials ignores types)
135
117
(cmpck (not (symbolp name)) "The variable ~s is not a symbol." name)
187
169
;;; A variable reference (vref for short) is a list: pair
188
170
;;; ( var-object ) Beppe(ccb) ccb-reference )
190
(defun c1vref (name &aux (ccb nil) (clb nil))
192
(declare (type var var))
193
(cond ((eq var 'CB) (setq ccb t)) ; closure boundary
194
((eq var 'LB) (setq clb t)) ; level boundary
196
(when (eq (first var) name) ; symbol macrolet
198
(return-from c1vref (c1expr (second var)))))
199
((eq (var-name var) name)
173
(multiple-value-bind (var ccb clb unw)
174
(cmp-env-search-var name)
176
(c1make-global-variable name :warn t
177
:type (or (get-sysprop name 'CMP-TYPE) t)))
200
182
(when (minusp (var-ref var)) ; IGNORE.
201
183
(cmpwarn "The ignored variable ~s is used." name)
202
184
(setf (var-ref var) 0))
208
190
(clb (setf (var-ref-clb var) t
209
191
(var-loc var) 'OBJECT))))
210
192
(incf (var-ref var))
211
(return-from c1vref var)))) ; ccb
212
(c1make-global-variable name :warn t
213
:type (or (get-sysprop name 'CMP-TYPE) t)))
216
;;; At each variable binding, the variable is added to *vars* which
217
;;; emulates the environment.
218
;;; The index is computed, which is used by similar to compare functions.
220
195
(defun push-vars (v)
221
(setf (var-index v) (length *vars*))
196
(setf (var-index v) (length (cmp-env-variables)))
197
(cmp-env-register-var v))
224
199
(defun unboxed (var)
225
200
(not (eq (var-rep-type var) :object)))
299
274
(defun c1declare-specials (globals)
301
(push (c1make-global-variable v :warn nil :kind 'SPECIAL) *vars*)))
275
(mapc #'cmp-env-declare-special globals))
303
277
(defun si::register-global (name)
304
278
(unless (check-global name)