comparison lisp/emacs-lisp/byte-run.el @ 89909:68c22ea6027c

Sync to HEAD
author Kenichi Handa <handa@m17n.org>
date Fri, 16 Apr 2004 12:51:06 +0000
parents 375f2633d815
children 4c90ffeb71c5
comparison
equal deleted inserted replaced
89908:ee1402f7b568 89909:68c22ea6027c
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.
89 (put fn 'byte-compile 'byte-compile-obsolete)) 89 (put fn 'byte-compile 'byte-compile-obsolete))
90 (put fn 'byte-obsolete-info (list new handler when))) 90 (put fn 'byte-obsolete-info (list new handler when)))
91 fn) 91 fn)
92 92
93 (defun make-obsolete-variable (var new &optional when) 93 (defun make-obsolete-variable (var new &optional when)
94 "Make the byte-compiler warn that VARIABLE is obsolete, 94 "Make the byte-compiler warn that VARIABLE is obsolete.
95 and NEW should be used instead. If NEW is a string, then that is the 95 The warning will say that NEW should be used instead.
96 `use instead' message. 96 If NEW is a string, that is the `use instead' message.
97 If provided, WHEN should be a string indicating when the variable 97 If provided, WHEN should be a string indicating when the variable
98 was first made obsolete, for example a date or a release number." 98 was first made obsolete, for example a date or a release number."
99 (interactive 99 (interactive
100 (list 100 (list
101 (let ((str (completing-read "Make variable obsolete: " obarray 'boundp t))) 101 (let ((str (completing-read "Make variable obsolete: " obarray 'boundp t)))
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."
167 ;; (optimize t) 170 ;; (optimize t)
168 ;; (warnings (- free-vars)) ; Don't warn about free variables 171 ;; (warnings (- free-vars)) ; Don't warn about free variables
169 ;; (file-format emacs19))" 172 ;; (file-format emacs19))"
170 ;; nil) 173 ;; nil)
171 174
175 ;;; arch-tag: 76f8328a-1f66-4df2-9b6d-5c3666dc05e9
172 ;;; byte-run.el ends here 176 ;;; byte-run.el ends here