(Fload): Add "source is newer" info to the "loading" and "done" messages.
[emacs.git] / lisp / byte-run.el
blob79b64b241a16573dd1134111ed00544bae21a189
1 ;;; byte-run.el --- byte-compiler support for inlining
3 ;; Copyright (C) 1992 Free Software Foundation, Inc.
5 ;; Author: Jamie Zawinski <jwz@lucid.com>
6 ;; Hallvard Furuseth <hbf@ulrik.uio.no>
7 ;; Keywords: internal
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
26 ;;; Commentary:
28 ;; interface to selectively inlining functions.
29 ;; This only happens when source-code optimization is turned on.
31 ;;; Code:
33 ;; Redefined in byte-optimize.el.
34 ;; This is not documented--it's not clear that we should promote it.
35 (fset 'inline 'progn)
36 (put 'inline 'lisp-indent-hook 0)
39 ;;; Interface to inline functions.
41 ;; (defmacro proclaim-inline (&rest fns)
42 ;; "Cause the named functions to be open-coded when called from compiled code.
43 ;; They will only be compiled open-coded when byte-compile-optimize is true."
44 ;; (cons 'eval-and-compile
45 ;; (mapcar '(lambda (x)
46 ;; (or (memq (get x 'byte-optimizer)
47 ;; '(nil byte-compile-inline-expand))
48 ;; (error
49 ;; "%s already has a byte-optimizer, can't make it inline"
50 ;; x))
51 ;; (list 'put (list 'quote x)
52 ;; ''byte-optimizer ''byte-compile-inline-expand))
53 ;; fns)))
55 ;; (defmacro proclaim-notinline (&rest fns)
56 ;; "Cause the named functions to no longer be open-coded."
57 ;; (cons 'eval-and-compile
58 ;; (mapcar '(lambda (x)
59 ;; (if (eq (get x 'byte-optimizer) 'byte-compile-inline-expand)
60 ;; (put x 'byte-optimizer nil))
61 ;; (list 'if (list 'eq (list 'get (list 'quote x) ''byte-optimizer)
62 ;; ''byte-compile-inline-expand)
63 ;; (list 'put x ''byte-optimizer nil)))
64 ;; fns)))
66 ;; This has a special byte-hunk-handler in bytecomp.el.
67 (defmacro defsubst (name arglist &rest body)
68 "Define an inline function. The syntax is just like that of `defun'."
69 (or (memq (get name 'byte-optimizer)
70 '(nil byte-compile-inline-expand))
71 (error "`%s' is a primitive" name))
72 (list 'prog1
73 (cons 'defun (cons name (cons arglist body)))
74 (list 'eval-and-compile
75 (list 'put (list 'quote name)
76 ''byte-optimizer ''byte-compile-inline-expand))))
78 (defun make-obsolete (fn new)
79 "Make the byte-compiler warn that FUNCTION is obsolete.
80 The warning will say that NEW should be used instead.
81 If NEW is a string, that is the `use instead' message."
82 (interactive "aMake function obsolete: \nxObsoletion replacement: ")
83 (let ((handler (get fn 'byte-compile)))
84 (if (eq 'byte-compile-obsolete handler)
85 (setcar (get fn 'byte-obsolete-info) new)
86 (put fn 'byte-obsolete-info (cons new handler))
87 (put fn 'byte-compile 'byte-compile-obsolete)))
88 fn)
90 (defun make-obsolete-variable (var new)
91 "Make the byte-compiler warn that VARIABLE is obsolete,
92 and NEW should be used instead. If NEW is a string, then that is the
93 `use instead' message."
94 (interactive
95 (list
96 (let ((str (completing-read "Make variable obsolete: " obarray 'boundp t)))
97 (if (equal str "") (error ""))
98 (intern str))
99 (car (read-from-string (read-string "Obsoletion replacement: ")))))
100 (put var 'byte-obsolete-variable new)
101 var)
103 (put 'dont-compile 'lisp-indent-hook 0)
104 (defmacro dont-compile (&rest body)
105 "Like `progn', but the body always runs interpreted (not compiled).
106 If you think you need this, you're probably making a mistake somewhere."
107 (list 'eval (list 'quote (if (cdr body) (cons 'progn body) (car body)))))
110 ;;; interface to evaluating things at compile time and/or load time
111 ;;; these macro must come after any uses of them in this file, as their
112 ;;; definition in the file overrides the magic definitions on the
113 ;;; byte-compile-macro-environment.
115 (put 'eval-when-compile 'lisp-indent-hook 0)
116 (defmacro eval-when-compile (&rest body)
117 "Like `progn', but evaluates the body at compile time.
118 The result of the body appears to the compiler as a quoted constant."
119 ;; Not necessary because we have it in b-c-initial-macro-environment
120 ;; (list 'quote (eval (cons 'progn body)))
121 (cons 'progn body))
123 (put 'eval-and-compile 'lisp-indent-hook 0)
124 (defmacro eval-and-compile (&rest body)
125 "Like `progn', but evaluates the body at compile time and at load time."
126 ;; Remember, it's magic.
127 (cons 'progn body))
130 ;;; I nuked this because it's not a good idea for users to think of using it.
131 ;;; These options are a matter of installation preference, and have nothing to
132 ;;; with particular source files; it's a mistake to suggest to users
133 ;;; they should associate these with particular source files.
134 ;;; There is hardly any reason to change these parameters, anyway.
135 ;;; --rms.
137 ;; (put 'byte-compiler-options 'lisp-indent-hook 0)
138 ;; (defmacro byte-compiler-options (&rest args)
139 ;; "Set some compilation-parameters for this file. This will affect only the
140 ;; file in which it appears; this does nothing when evaluated, and when loaded
141 ;; from a .el file.
143 ;; Each argument to this macro must be a list of a key and a value.
145 ;; Keys: Values: Corresponding variable:
147 ;; verbose t, nil byte-compile-verbose
148 ;; optimize t, nil, source, byte byte-compile-optimize
149 ;; warnings list of warnings byte-compile-warnings
150 ;; Legal elements: (callargs redefine free-vars unresolved)
151 ;; file-format emacs18, emacs19 byte-compile-compatibility
153 ;; For example, this might appear at the top of a source file:
155 ;; (byte-compiler-options
156 ;; (optimize t)
157 ;; (warnings (- free-vars)) ; Don't warn about free variables
158 ;; (file-format emacs19))"
159 ;; nil)
161 ;;; byte-run.el ends here