-
Notifications
You must be signed in to change notification settings - Fork 0
/
defmacro.lisp
57 lines (54 loc) · 1.93 KB
/
defmacro.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
;;;
;;; defmacro.lisp - definitions of the `%defmacro' function from src/code/defmacro.lisp
;;;
(in-package :sb-c)
(defmacro define-%defmacro ()
`(defun %defmacro (name definition lambda-list doc debug-name)
,@(unless set-p
'((declare (ignore lambda-list debug-name))))
(ecase (info :function :kind name)
((nil))
(:function
(undefine-fun-name name)
(style-warn
"~S is being redefined as a macro when it was ~
previously ~(~A~) to be a function."
name
(info :function :where-from name)))
(:macro)
(:special-form
(error "The special form ~S can't be redefined as a macro."
name)))
(clear-info :function :where-from name)
(setf (macro-function name) definition)
(push name sb-sandbox::*defined-macros*) ;; <<--
,(when set-p
`(setf (%fun-doc definition) doc
(%fun-lambda-list definition) lambda-list
(%fun-name definition) debug-name))
name)))
(defmacro undefine-%defmacro ()
`(let ((*package* (find-package :sb-c)))
(defun %defmacro (name definition lambda-list doc debug-name)
,@(unless set-p
'((declare (ignore lambda-list debug-name))))
(ecase (info :function :kind name)
((nil))
(:function
(undefine-fun-name name)
(style-warn
"~S is being redefined as a macro when it was ~
previously ~(~A~) to be a function."
name
(info :function :where-from name)))
(:macro)
(:special-form
(error "The special form ~S can't be redefined as a macro."
name)))
(clear-info :function :where-from name)
(setf (macro-function name) definition)
,(when set-p
`(setf (%fun-doc definition) doc
(%fun-lambda-list definition) lambda-list
(%fun-name definition) debug-name))
name)))