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>
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)
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
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 ;;; interface to selectively inlining functions.
28 ;;; This only happens when source-code optimization is turned on.
32 ;; Redefined in byte-optimize.el.
33 ;; This is not documented--it's not clear that we should promote it.
35 (put 'inline
'lisp-indent-hook
0)
38 ;;; Interface to inline functions.
40 ;; (defmacro proclaim-inline (&rest fns)
41 ;; "Cause the named functions to be open-coded when called from compiled code.
42 ;; They will only be compiled open-coded when byte-compile-optimize is true."
43 ;; (cons 'eval-and-compile
44 ;; (mapcar '(lambda (x)
45 ;; (or (memq (get x 'byte-optimizer)
46 ;; '(nil byte-compile-inline-expand))
48 ;; "%s already has a byte-optimizer, can't make it inline"
50 ;; (list 'put (list 'quote x)
51 ;; ''byte-optimizer ''byte-compile-inline-expand))
54 ;; (defmacro proclaim-notinline (&rest fns)
55 ;; "Cause the named functions to no longer be open-coded."
56 ;; (cons 'eval-and-compile
57 ;; (mapcar '(lambda (x)
58 ;; (if (eq (get x 'byte-optimizer) 'byte-compile-inline-expand)
59 ;; (put x 'byte-optimizer nil))
60 ;; (list 'if (list 'eq (list 'get (list 'quote x) ''byte-optimizer)
61 ;; ''byte-compile-inline-expand)
62 ;; (list 'put x ''byte-optimizer nil)))
65 ;; This has a special byte-hunk-handler in bytecomp.el.
66 (defmacro defsubst
(name arglist
&rest body
)
67 "Define an inline function. The syntax is just like that of `defun'."
68 (or (memq (get name
'byte-optimizer
)
69 '(nil byte-compile-inline-expand
))
70 (error "`%s' is a primitive" name
))
72 (cons 'defun
(cons name
(cons arglist body
)))
73 (list 'eval-and-compile
74 (list 'put
(list 'quote name
)
75 ''byte-optimizer
''byte-compile-inline-expand
))))
77 (defun make-obsolete (fn new
)
78 "Make the byte-compiler warn that FUNCTION is obsolete.
79 The warning will say that NEW should be used instead.
80 If NEW is a string, that is the `use instead' message."
81 (interactive "aMake function obsolete: \nxObsoletion replacement: ")
82 (let ((handler (get fn
'byte-compile
)))
83 (if (eq 'byte-compile-obsolete handler
)
84 (setcar (get fn
'byte-obsolete-info
) new
)
85 (put fn
'byte-obsolete-info
(cons new handler
))
86 (put fn
'byte-compile
'byte-compile-obsolete
)))
89 (put 'dont-compile
'lisp-indent-hook
0)
90 (defmacro dont-compile
(&rest body
)
91 "Like `progn', but the body always runs interpreted (not compiled)."
92 (list 'eval
(list 'quote
(if (cdr body
) (cons 'progn body
) (car body
)))))
95 ;;; interface to evaluating things at compile time and/or load time
96 ;;; these macro must come after any uses of them in this file, as their
97 ;;; definition in the file overrides the magic definitions on the
98 ;;; byte-compile-macro-environment.
100 (put 'eval-when-compile
'lisp-indent-hook
0)
101 (defmacro eval-when-compile
(&rest body
)
102 "Like `progn', but evaluates the body at compile time.
103 The result of the body appears to the compiler as a quoted constant."
104 ;; Not necessary because we have it in b-c-initial-macro-environment
105 ;; (list 'quote (eval (cons 'progn body)))
108 (put 'eval-and-compile
'lisp-indent-hook
0)
109 (defmacro eval-and-compile
(&rest body
)
110 "Like `progn', but evaluates the body at compile time and at load time."
111 ;; Remember, it's magic.
115 ;;; I nuked this because it's not a good idea for users to think of using it.
116 ;;; These options are a matter of installation preference, and have nothing to
117 ;;; with particular source files; it's a mistake to suggest to users
118 ;;; they should associate these with particular source files.
119 ;;; There is hardly any reason to change these parameters, anyway.
122 ;; (put 'byte-compiler-options 'lisp-indent-hook 0)
123 ;; (defmacro byte-compiler-options (&rest args)
124 ;; "Set some compilation-parameters for this file. This will affect only the
125 ;; file in which it appears; this does nothing when evaluated, and when loaded
128 ;; Each argument to this macro must be a list of a key and a value.
130 ;; Keys: Values: Corresponding variable:
132 ;; verbose t, nil byte-compile-verbose
133 ;; optimize t, nil, source, byte byte-compile-optimize
134 ;; warnings list of warnings byte-compile-warnings
135 ;; Legal elements: (callargs redefine free-vars unresolved)
136 ;; file-format emacs18, emacs19 byte-compile-compatibility
138 ;; For example, this might appear at the top of a source file:
140 ;; (byte-compiler-options
142 ;; (warnings (- free-vars)) ; Don't warn about free variables
143 ;; (file-format emacs19))"
146 ;;; byte-run.el ends here