comparison lisp/emacs-lisp/byte-run.el @ 54496:94bcfb39cf49

(defsubst): Add edebug spec and use backquote. (dont-compile, eval-when-compile, eval-and-compile): Add edebug spec.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 22 Mar 2004 15:22:34 +0000
parents 9d42c2c9095d
children 1376729a93a7
comparison
equal deleted inserted replaced
54495:fec123d89bd0 54496:94bcfb39cf49
1 ;;; byte-run.el --- byte-compiler support for inlining 1 ;;; byte-run.el --- byte-compiler support for inlining
2 2
3 ;; Copyright (C) 1992 Free Software Foundation, Inc. 3 ;; Copyright (C) 1992, 2004 Free Software Foundation, Inc.
4 4
5 ;; Author: Jamie Zawinski <jwz@lucid.com> 5 ;; Author: Jamie Zawinski <jwz@lucid.com>
6 ;; Hallvard Furuseth <hbf@ulrik.uio.no> 6 ;; Hallvard Furuseth <hbf@ulrik.uio.no>
7 ;; Maintainer: FSF 7 ;; Maintainer: FSF
8 ;; Keywords: internal 8 ;; Keywords: internal
65 ;; fns))) 65 ;; fns)))
66 66
67 ;; This has a special byte-hunk-handler in bytecomp.el. 67 ;; This has a special byte-hunk-handler in bytecomp.el.
68 (defmacro defsubst (name arglist &rest body) 68 (defmacro defsubst (name arglist &rest body)
69 "Define an inline function. The syntax is just like that of `defun'." 69 "Define an inline function. The syntax is just like that of `defun'."
70 (declare (debug defun))
70 (or (memq (get name 'byte-optimizer) 71 (or (memq (get name 'byte-optimizer)
71 '(nil byte-compile-inline-expand)) 72 '(nil byte-compile-inline-expand))
72 (error "`%s' is a primitive" name)) 73 (error "`%s' is a primitive" name))
73 (list 'prog1 74 `(prog1
74 (cons 'defun (cons name (cons arglist body))) 75 (defun ,name ,arglist ,@body)
75 (list 'eval-and-compile 76 (eval-and-compile
76 (list 'put (list 'quote name) 77 (put ',name 'byte-optimizer 'byte-compile-inline-expand))))
77 ''byte-optimizer ''byte-compile-inline-expand))))
78 78
79 (defun make-obsolete (fn new &optional when) 79 (defun make-obsolete (fn new &optional when)
80 "Make the byte-compiler warn that FUNCTION is obsolete. 80 "Make the byte-compiler warn that FUNCTION is obsolete.
81 The warning will say that NEW should be used instead. 81 The warning will say that NEW should be used instead.
82 If NEW is a string, that is the `use instead' message. 82 If NEW is a string, that is the `use instead' message.
107 107
108 (put 'dont-compile 'lisp-indent-hook 0) 108 (put 'dont-compile 'lisp-indent-hook 0)
109 (defmacro dont-compile (&rest body) 109 (defmacro dont-compile (&rest body)
110 "Like `progn', but the body always runs interpreted (not compiled). 110 "Like `progn', but the body always runs interpreted (not compiled).
111 If you think you need this, you're probably making a mistake somewhere." 111 If you think you need this, you're probably making a mistake somewhere."
112 (declare (debug t))
112 (list 'eval (list 'quote (if (cdr body) (cons 'progn body) (car body))))) 113 (list 'eval (list 'quote (if (cdr body) (cons 'progn body) (car body)))))
113 114
114 115
115 ;;; interface to evaluating things at compile time and/or load time 116 ;;; interface to evaluating things at compile time and/or load time
116 ;;; these macro must come after any uses of them in this file, as their 117 ;;; these macro must come after any uses of them in this file, as their
119 120
120 (put 'eval-when-compile 'lisp-indent-hook 0) 121 (put 'eval-when-compile 'lisp-indent-hook 0)
121 (defmacro eval-when-compile (&rest body) 122 (defmacro eval-when-compile (&rest body)
122 "Like `progn', but evaluates the body at compile time. 123 "Like `progn', but evaluates the body at compile time.
123 The result of the body appears to the compiler as a quoted constant." 124 The result of the body appears to the compiler as a quoted constant."
125 (declare (debug t))
124 ;; Not necessary because we have it in b-c-initial-macro-environment 126 ;; Not necessary because we have it in b-c-initial-macro-environment
125 ;; (list 'quote (eval (cons 'progn body))) 127 ;; (list 'quote (eval (cons 'progn body)))
126 (cons 'progn body)) 128 (cons 'progn body))
127 129
128 (put 'eval-and-compile 'lisp-indent-hook 0) 130 (put 'eval-and-compile 'lisp-indent-hook 0)
129 (defmacro eval-and-compile (&rest body) 131 (defmacro eval-and-compile (&rest body)
130 "Like `progn', but evaluates the body at compile time and at load time." 132 "Like `progn', but evaluates the body at compile time and at load time."
133 (declare (debug t))
131 ;; Remember, it's magic. 134 ;; Remember, it's magic.
132 (cons 'progn body)) 135 (cons 'progn body))
133 136
134 (defun with-no-warnings (&optional first &rest body) 137 (defun with-no-warnings (&optional first &rest body)
135 "Like `progn', but prevents compiler warnings in the body." 138 "Like `progn', but prevents compiler warnings in the body."