Changeset 859
- Timestamp:
- Aug 10, 2004, 5:54:24 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ccl/level-1/l1-readloop.lisp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/level-1/l1-readloop.lisp
r687 r859 212 212 213 213 (defun %symbol-macroexpand-1 (sym env) 214 (if (and env (not (istruct-typep env 'lexical-environment))) 214 (flet ((expand-it (expansion) 215 (funcall *macroexpand-hook* 216 (constantly expansion) 217 sym 218 env))) 219 (if (and env (not (istruct-typep env 'lexical-environment))) 215 220 (report-bad-arg env 'lexical-environment)) 216 (do* ((env env (lexenv.parent-env env)))217 ((null env))218 (if (eq (%svref env 0) 'definition-environment)221 (do* ((env env (lexenv.parent-env env))) 222 ((null env)) 223 (if (eq (%svref env 0) 'definition-environment) 219 224 (let* ((info (assq sym (defenv.symbol-macros env)))) 220 225 (if info 221 (return-from %symbol-macroexpand-1 (values ( cdr info) t))226 (return-from %symbol-macroexpand-1 (values (expand-it (cdr info)) t)) 222 227 (return))) 223 228 (let* ((vars (lexenv.variables env))) … … 225 230 (let* ((info (dolist (var vars) 226 231 (if (eq (var-name var) sym) 227 (return var)))))232 (return var))))) 228 233 (when info 229 234 (if (and (consp (setq info (var-expansion info))) 230 235 (eq (%car info) :symbol-macro)) 231 (return-from %symbol-macroexpand-1 (values (%cdr info) t))232 (return-from %symbol-macroexpand-1 (values sym nil)))))))))233 ;; Look it up globally.234 (multiple-value-bind (expansion win) (gethash sym *symbol-macros*)235 (if win (values expansion t) (values sym nil))))236 (return-from %symbol-macroexpand-1 (values (expand-it (%cdr info)) t)) 237 (return-from %symbol-macroexpand-1 (values sym nil))))))))) 238 ;; Look it up globally. 239 (multiple-value-bind (expansion win) (gethash sym *symbol-macros*) 240 (if win (values (expand-it expansion) t) (values sym nil))))) 236 241 237 242 (defun macroexpand-1 (form &optional env &aux fn) … … 357 362 (verify-arg-count form 1 1) 358 363 (cond ((symbolp (setq sym (%cadr form))) 364 (multiple-value-bind (kind local-p) 365 (function-information sym env) 366 (if (and local-p (eq kind :macro)) 367 (error "~s can't be used to reference lexically defined macro ~S" 'function sym))) 359 368 (%function sym)) 360 369 ((and (consp sym) (eq (%car sym) 'setf) (consp (%cdr sym)) (null (%cddr sym))) 370 (multiple-value-bind (kind local-p) 371 (function-information sym env) 372 (if (and local-p (eq kind :macro)) 373 (error "~s can't be used to reference lexically defined macro ~S" 'function sym))) 361 374 (%function (setf-function-name (%cadr sym)))) 362 375 (t (%make-function nil sym env))))
Note:
See TracChangeset
for help on using the changeset viewer.
