Mercurial > hg > xemacs-beta
comparison lisp/bytecomp.el @ 4677:8f1ee2d15784
Support full Common Lisp multiple values in C.
lisp/ChangeLog
2009-08-11 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el :
Update this file to support full C-level multiple values. This
involves:
-- Four new bytecodes, and special compiler functions to compile
multiple-value-call, multiple-value-list-internal, values,
values-list, and, since it now needs to pass back multiple values
and is a special form, throw.
-- There's a new compiler variable, byte-compile-checks-on-load,
which is a list of forms that are evaluated at the very start of a
file, with an error thrown if any of them give nil.
-- The header is now inserted *after* compilation, giving a chance
for the compilation process to influence what those checks
are. There is still a check done before compilation for non-ASCII
characters, to try to turn off dynamic docstrings if appopriate,
in `byte-compile-maybe-reset-coding'.
Space is reserved for checks; comments describing the version of
the byte compiler generating the file are inserted if space
remains for them.
* bytecomp.el (byte-compile-version):
Update this, we're a newer version of the byte compiler.
* byte-optimize.el (byte-optimize-funcall):
Correct a comment.
* bytecomp.el (byte-compile-lapcode):
Discard the arg with byte-multiple-value-call.
* bytecomp.el (byte-compile-checks-and-comments-space):
New variable, describe how many octets to reserve for checks at
the start of byte-compiled files.
* cl-compat.el:
Remove the fake multiple-value implementation. Have the functions
that use it use the real multiple-value implementation instead.
* cl-macs.el (cl-block-wrapper, cl-block-throw):
Revise the byte-compile properties of these symbols to work now
we've made throw into a special form; keep the byte-compile
properties as anonymous lambdas, since we don't have docstrings
for them.
* cl-macs.el (multiple-value-bind, multiple-value-setq)
(multiple-value-list, nth-value):
Update these functions to work with the C support for multiple
values.
* cl-macs.el (values):
Modify the setf handler for this to call
#'multiple-value-list-internal appropriately.
* cl-macs.el (cl-setf-do-store):
If the store form is a cons, treat it specially as wrapping the
store value.
* cl.el (cl-block-wrapper):
Make this an alias of #'and, not #'identity, since it needs to
pass back multiple values.
* cl.el (multiple-value-apply):
We no longer support this, mark it obsolete.
* lisp-mode.el (eval-interactive-verbose):
Remove a useless space in the docstring.
* lisp-mode.el (eval-interactive):
Update this function and its docstring. It now passes back a list,
basically wrapping any eval calls with multiple-value-list. This
allows multiple values to be printed by default in *scratch*.
* lisp-mode.el (prin1-list-as-multiple-values):
New function, printing a list as multiple values in the manner of
Bruno Haible's clisp, separating each entry with " ;\n".
* lisp-mode.el (eval-last-sexp):
Call #'prin1-list-as-multiple-values on the return value of
#'eval-interactive.
* lisp-mode.el (eval-defun):
Call #'prin1-list-as-multiple-values on the return value of
#'eval-interactive.
* mouse.el (mouse-eval-sexp):
Deal with lists corresponding to multiple values from
#'eval-interactive. Call #'cl-prettyprint, which is always
available, instead of sometimes calling #'pprint and sometimes
falling back to prin1.
* obsolete.el (obsolete-throw):
New function, called from eval.c when #'funcall encounters an
attempt to call #'throw (now a special form) as a function. Only
needed for compatibility with 21.4 byte-code.
man/ChangeLog addition:
2009-08-11 Aidan Kehoe <kehoea@parhasard.net>
* cl.texi (Organization):
Remove references to the obsolete multiple-value emulating code.
src/ChangeLog addition:
2009-08-11 Aidan Kehoe <kehoea@parhasard.net>
* bytecode.c (enum Opcode /* Byte codes */):
Add four new bytecodes, to deal with multiple values.
(POP_WITH_MULTIPLE_VALUES): New macro.
(POP): Modify this macro to ignore multiple values.
(DISCARD_PRESERVING_MULTIPLE_VALUES): New macro.
(DISCARD): Modify this macro to ignore multiple values.
(TOP_WITH_MULTIPLE_VALUES): New macro.
(TOP_ADDRESS): New macro.
(TOP): Modify this macro to ignore multiple values.
(TOP_LVALUE): New macro.
(Bcall): Ignore multiple values where appropriate.
(Breturn): Pass back multiple values.
(Bdup): Preserve multiple values.
Use TOP_LVALUE with most bytecodes that assign anything to
anything.
(Bbind_multiple_value_limits, Bmultiple_value_call,
Bmultiple_value_list_internal, Bthrow): Implement the new
bytecodes.
(Bgotoifnilelsepop, Bgotoifnonnilelsepop, BRgotoifnilelsepop,
BRgotoifnonnilelsepop):
Discard any multiple values.
* callint.c (Fcall_interactively):
Ignore multiple values when calling #'eval, in two places.
* device-x.c (x_IO_error_handler):
* macros.c (pop_kbd_macro_event):
* eval.c (Fsignal):
* eval.c (flagged_a_squirmer):
Call throw_or_bomb_out, not Fthrow, now that the latter is a
special form.
* eval.c:
Make Qthrow, Qobsolete_throw available as symbols.
Provide multiple_value_current_limit, multiple-values-limit (the
latter as specified by Common Lisp.
* eval.c (For):
Ignore multiple values when comparing with Qnil, but pass any
multiple values back for the last arg.
* eval.c (Fand):
Ditto.
* eval.c (Fif):
Ignore multiple values when examining the result of the
condition.
* eval.c (Fcond):
Ignore multiple values when comparing what the clauses give, but
pass them back if a clause gave non-nil.
* eval.c (Fprog2):
Never pass back multiple values.
* eval.c (FletX, Flet):
Ignore multiple when evaluating what exactly symbols should be
bound to.
* eval.c (Fwhile):
Ignore multiple values when evaluating the test.
* eval.c (Fsetq, Fdefvar, Fdefconst):
Ignore multiple values.
* eval.c (Fthrow):
Declare this as a special form; ignore multiple values for TAG,
preserve them for VALUE.
* eval.c (throw_or_bomb_out):
Make this available to other files, now Fthrow is a special form.
* eval.c (Feval):
Ignore multiple values when calling a compiled function, a
non-special-form subr, or a lambda expression.
* eval.c (Ffuncall):
If we attempt to call #'throw (now a special form) as a function,
don't error, call #'obsolete-throw instead.
* eval.c (make_multiple_value, multiple_value_aset)
(multiple_value_aref, print_multiple_value, mark_multiple_value)
(size_multiple_value):
Implement the multiple_value type. Add a long comment describing
our implementation.
* eval.c (bind_multiple_value_limits):
New function, used by the bytecode and by #'multiple-value-call,
#'multiple-value-list-internal.
* eval.c (multiple_value_call):
New function, used by the bytecode and #'multiple-value-call.
* eval.c (Fmultiple_value_call):
New special form.
* eval.c (multiple_value_list_internal):
New function, used by the byte code and
#'multiple-value-list-internal.
* eval.c (Fmultiple_value_list_internal, Fmultiple_value_prog1):
New special forms.
* eval.c (Fvalues, Fvalues_list):
New Lisp functions.
* eval.c (values2):
New function, for C code returning multiple values.
* eval.c (syms_of_eval):
Make our new Lisp functions and symbols available.
* eval.c (multiple-values-limit):
Make this available to Lisp.
* event-msw.c (dde_eval_string):
* event-stream.c (execute_help_form):
* glade.c (connector):
* glyphs-widget.c (glyph_instantiator_to_glyph):
* glyphs.c (evaluate_xpm_color_symbols):
* gui-x.c (wv_set_evalable_slot, button_item_to_widget_value):
* gui.c (gui_item_value, gui_item_display_flush_left):
* lread.c (check_if_suppressed):
* menubar-gtk.c (menu_convert, menu_descriptor_to_widget_1):
* menubar-msw.c (populate_menu_add_item):
* print.c (Fwith_output_to_temp_buffer):
* symbols.c (Fsetq_default):
Ignore multiple values when calling Feval.
* symeval.h:
Add the header declarations necessary for the multiple-values
implementation.
* inline.c:
#include symeval.h, now that it has some inline functions.
* lisp.h:
Update Fthrow's declaration. Make throw_or_bomb_out available to
all files.
* lrecord.h (enum lrecord_type):
Add the multiple_value type here.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sun, 16 Aug 2009 20:55:49 +0100 |
parents | 7757334005ae |
children | 0cc9d22c3732 |
comparison
equal
deleted
inserted
replaced
4676:e3feb329bda9 | 4677:8f1ee2d15784 |
---|---|
8 ;; Ben Wing <ben@xemacs.org> | 8 ;; Ben Wing <ben@xemacs.org> |
9 ;; Martin Buchholz <martin@xemacs.org> | 9 ;; Martin Buchholz <martin@xemacs.org> |
10 ;; Richard Stallman <rms@gnu.org> | 10 ;; Richard Stallman <rms@gnu.org> |
11 ;; Keywords: internal lisp | 11 ;; Keywords: internal lisp |
12 | 12 |
13 (defconst byte-compile-version "2.27 XEmacs; 2000-09-12.") | 13 (defconst byte-compile-version "2.28 XEmacs; 2009-08-09.") |
14 | 14 |
15 ;; This file is part of XEmacs. | 15 ;; This file is part of XEmacs. |
16 | 16 |
17 ;; XEmacs is free software; you can redistribute it and/or modify it | 17 ;; XEmacs is free software; you can redistribute it and/or modify it |
18 ;; under the terms of the GNU General Public License as published by | 18 ;; under the terms of the GNU General Public License as published by |
213 (or (fboundp 'defsubst) | 213 (or (fboundp 'defsubst) |
214 ;; This really ought to be loaded already! | 214 ;; This really ought to be loaded already! |
215 (load-library "bytecomp-runtime")) | 215 (load-library "bytecomp-runtime")) |
216 | 216 |
217 (eval-when-compile | 217 (eval-when-compile |
218 (defvar byte-compile-single-version nil | 218 (defvar byte-compile-single-version t |
219 "If this is true, the choice of emacs version (v19 or v20) byte-codes will | 219 "If this is true, the choice of emacs version (v19 or v20) byte-codes will |
220 be hard-coded into bytecomp when it compiles itself. If the compiler itself | 220 be hard-coded into bytecomp when it compiles itself. If the compiler itself |
221 is compiled with optimization, this causes a speedup.") | 221 is compiled with optimization, this causes a speedup.") |
222 | 222 |
223 (cond | 223 (cond |
302 ;; XEmacs addition | 302 ;; XEmacs addition |
303 (defvar byte-compile-new-bytecodes nil | 303 (defvar byte-compile-new-bytecodes nil |
304 "This is completely ignored. It is only around for backwards | 304 "This is completely ignored. It is only around for backwards |
305 compatibility.") | 305 compatibility.") |
306 | 306 |
307 (defvar byte-compile-checks-on-load '((featurep 'xemacs)) | |
308 "A list of expressions to check when first loading a file. | |
309 Emacs will throw an error if any of them fail; checks will be made in | |
310 reverse order.") | |
307 | 311 |
308 ;; FSF enables byte-compile-dynamic-docstrings but not byte-compile-dynamic | 312 ;; FSF enables byte-compile-dynamic-docstrings but not byte-compile-dynamic |
309 ;; by default. This would be a reasonable conservative approach except | 313 ;; by default. This would be a reasonable conservative approach except |
310 ;; for the fact that if you enable either of these, you get incompatible | 314 ;; for the fact that if you enable either of these, you get incompatible |
311 ;; byte code that can't be read by XEmacs 19.13 or before or FSF 19.28 or | 315 ;; byte code that can't be read by XEmacs 19.13 or before or FSF 19.28 or |
438 "Alist of variables bound in the context of the current form, | 442 "Alist of variables bound in the context of the current form, |
439 that is, the current lexical environment. This list lives partly | 443 that is, the current lexical environment. This list lives partly |
440 on the specbind stack. The cdr of each cell is an integer bitmask.") | 444 on the specbind stack. The cdr of each cell is an integer bitmask.") |
441 | 445 |
442 (defvar byte-compile-force-escape-quoted nil | 446 (defvar byte-compile-force-escape-quoted nil |
443 "If non-nil, `byte-compile-insert-header' always adds a coding cookie. | 447 "If t, `byte-compile-maybe-reset-coding' always chooses `escape-quoted' |
444 | 448 |
445 This is for situations where the byte compiler output file needs to be | 449 This is for situations where the byte compiler output file needs to be |
446 able to encode character values above ?\\xFF, but this cannot be | 450 able to encode character values above ?\\xFF, but this cannot be |
447 easily determined from the input file.") | 451 easily determined from the input file.") |
448 | 452 |
731 | 735 |
732 (byte-defop 175 nil byte-listN) | 736 (byte-defop 175 nil byte-listN) |
733 (byte-defop 176 nil byte-concatN) | 737 (byte-defop 176 nil byte-concatN) |
734 (byte-defop 177 nil byte-insertN) | 738 (byte-defop 177 nil byte-insertN) |
735 | 739 |
736 ;; unused: 178-181 | 740 (byte-defop 178 1 byte-bind-multiple-value-limits) |
741 (byte-defop 179 -3 byte-multiple-value-list-internal) | |
742 (byte-defop 180 0 byte-multiple-value-call) | |
743 (byte-defop 181 -1 byte-throw) | |
737 | 744 |
738 ;; these ops are new to v20 | 745 ;; these ops are new to v20 |
739 (byte-defop 182 -1 byte-member) | 746 (byte-defop 182 -1 byte-member) |
740 (byte-defop 183 -1 byte-assq) | 747 (byte-defop 183 -1 byte-assq) |
741 | 748 |
831 (cons byte-constant2 bytes)))))) | 838 (cons byte-constant2 bytes)))))) |
832 ((and (<= byte-listN (symbol-value op)) | 839 ((and (<= byte-listN (symbol-value op)) |
833 (<= (symbol-value op) byte-insertN)) | 840 (<= (symbol-value op) byte-insertN)) |
834 (setq pc (+ 2 pc)) | 841 (setq pc (+ 2 pc)) |
835 (cons off (cons (symbol-value op) bytes))) | 842 (cons off (cons (symbol-value op) bytes))) |
843 ((= byte-multiple-value-call (symbol-value op)) | |
844 (setq pc (1+ pc)) | |
845 ;; Ignore off. | |
846 (cons (symbol-value op) bytes)) | |
836 ((< off 6) | 847 ((< off 6) |
837 (setq pc (1+ pc)) | 848 (setq pc (1+ pc)) |
838 (cons (+ (symbol-value op) off) bytes)) | 849 (cons (+ (symbol-value op) off) bytes)) |
839 ((< off 256) | 850 ((< off 256) |
840 (setq pc (+ 2 pc)) | 851 (setq pc (+ 2 pc)) |
1384 ;; | 1395 ;; |
1385 (byte-compile-verbose byte-compile-verbose) | 1396 (byte-compile-verbose byte-compile-verbose) |
1386 (byte-optimize byte-optimize) | 1397 (byte-optimize byte-optimize) |
1387 (byte-compile-emacs19-compatibility | 1398 (byte-compile-emacs19-compatibility |
1388 byte-compile-emacs19-compatibility) | 1399 byte-compile-emacs19-compatibility) |
1400 (byte-compile-checks-on-load | |
1401 byte-compile-checks-on-load) | |
1389 (byte-compile-dynamic byte-compile-dynamic) | 1402 (byte-compile-dynamic byte-compile-dynamic) |
1390 (byte-compile-dynamic-docstrings | 1403 (byte-compile-dynamic-docstrings |
1391 byte-compile-dynamic-docstrings) | 1404 byte-compile-dynamic-docstrings) |
1392 (byte-compile-warnings (if (eq byte-compile-warnings t) | 1405 (byte-compile-warnings (if (eq byte-compile-warnings t) |
1393 byte-compile-default-warnings | 1406 byte-compile-default-warnings |
1716 ;; #### This is bound in b-c-close-variables. | 1729 ;; #### This is bound in b-c-close-variables. |
1717 ;; (byte-compile-warnings (if (eq byte-compile-warnings t) | 1730 ;; (byte-compile-warnings (if (eq byte-compile-warnings t) |
1718 ;; byte-compile-warning-types | 1731 ;; byte-compile-warning-types |
1719 ;; byte-compile-warnings)) | 1732 ;; byte-compile-warnings)) |
1720 (byte-compile-force-escape-quoted byte-compile-force-escape-quoted) | 1733 (byte-compile-force-escape-quoted byte-compile-force-escape-quoted) |
1721 (byte-compile-using-dynamic nil) | 1734 (byte-compile-using-dynamic nil)) |
1722 (byte-compile-using-escape-quoted nil) | |
1723 ) | |
1724 (byte-compile-close-variables | 1735 (byte-compile-close-variables |
1725 (save-excursion | 1736 (save-excursion |
1726 (setq byte-compile-outbuffer | 1737 (setq byte-compile-outbuffer |
1727 (set-buffer (get-buffer-create " *Compiler Output*"))) | 1738 (set-buffer (get-buffer-create " *Compiler Output*"))) |
1728 (erase-buffer) | 1739 (erase-buffer) |
1729 ;; (emacs-lisp-mode) | 1740 ;; (emacs-lisp-mode) |
1730 (setq case-fold-search nil) | 1741 (setq case-fold-search nil) |
1731 (and filename | 1742 (and filename |
1732 (not eval) | 1743 (not eval) |
1733 (byte-compile-insert-header filename | 1744 (byte-compile-maybe-reset-coding byte-compile-inbuffer |
1734 byte-compile-inbuffer | 1745 byte-compile-outbuffer)) |
1735 byte-compile-outbuffer)) | |
1736 (setq byte-compile-using-dynamic | 1746 (setq byte-compile-using-dynamic |
1737 (or (symbol-value-in-buffer 'byte-compile-dynamic | 1747 (or (symbol-value-in-buffer 'byte-compile-dynamic |
1738 byte-compile-inbuffer) | 1748 byte-compile-inbuffer) |
1739 (symbol-value-in-buffer 'byte-compile-dynamic-docstrings | 1749 (symbol-value-in-buffer 'byte-compile-dynamic-docstrings |
1740 byte-compile-inbuffer))) | 1750 byte-compile-inbuffer))) |
1761 (not (eobp))) | 1771 (not (eobp))) |
1762 (byte-compile-file-form (read byte-compile-inbuffer))) | 1772 (byte-compile-file-form (read byte-compile-inbuffer))) |
1763 | 1773 |
1764 ;; Compile pending forms at end of file. | 1774 ;; Compile pending forms at end of file. |
1765 (byte-compile-flush-pending) | 1775 (byte-compile-flush-pending) |
1776 (byte-compile-insert-header filename byte-compile-inbuffer | |
1777 byte-compile-outbuffer) | |
1766 (byte-compile-warn-about-unresolved-functions) | 1778 (byte-compile-warn-about-unresolved-functions) |
1767 ;; Should we always do this? When calling multiple files, it | 1779 ;; Should we always do this? When calling multiple files, it |
1768 ;; would be useful to delay this warning until all have | 1780 ;; would be useful to delay this warning until all have |
1769 ;; been compiled. | 1781 ;; been compiled. |
1770 (setq byte-compile-unresolved-functions nil))) | 1782 (setq byte-compile-unresolved-functions nil))) |
1795 (end-of-file nil)) | 1807 (end-of-file nil)) |
1796 (eval form))) | 1808 (eval form))) |
1797 (kill-buffer byte-compile-outbuffer) | 1809 (kill-buffer byte-compile-outbuffer) |
1798 nil))) | 1810 nil))) |
1799 | 1811 |
1812 (defvar byte-compile-checks-and-comments-space 475 | |
1813 "Number of octets of space for checks and comments; used by the dynamic | |
1814 docstrings code.") | |
1815 | |
1800 (defun byte-compile-insert-header (filename byte-compile-inbuffer | 1816 (defun byte-compile-insert-header (filename byte-compile-inbuffer |
1801 byte-compile-outbuffer) | 1817 byte-compile-outbuffer) |
1802 (set-buffer byte-compile-inbuffer) | 1818 (set-buffer byte-compile-inbuffer) |
1803 (let ((dynamic-docstrings byte-compile-dynamic-docstrings)) | 1819 (let (checks-string comments) |
1804 (set-buffer byte-compile-outbuffer) | 1820 (set-buffer byte-compile-outbuffer) |
1821 (delete-region 1 (1+ byte-compile-checks-and-comments-space)) | |
1805 (goto-char 1) | 1822 (goto-char 1) |
1806 ;; | 1823 ;; |
1807 ;; The magic number of .elc files is ";ELC", or 0x3B454C43. After that is | 1824 ;; The magic number of .elc files is ";ELC", or 0x3B454C43. After that is |
1808 ;; the file-format version number (19 or 20) as a byte, followed by some | 1825 ;; the file-format version number (19 or 20) as a byte, followed by some |
1809 ;; nulls. The primary motivation for doing this is to get some binary | 1826 ;; nulls. The primary motivation for doing this is to get some binary |
1815 ;; >4 byte x version %d | 1832 ;; >4 byte x version %d |
1816 ;; | 1833 ;; |
1817 (insert | 1834 (insert |
1818 ";ELC" | 1835 ";ELC" |
1819 (if (byte-compile-version-cond byte-compile-emacs19-compatibility) 19 20) | 1836 (if (byte-compile-version-cond byte-compile-emacs19-compatibility) 19 20) |
1820 "\000\000\000\n" | 1837 "\000\000\000\n") |
1821 ) | 1838 (when (not (eq (find-coding-system 'raw-text-unix) |
1822 (insert ";;; compiled by " | 1839 (find-coding-system buffer-file-coding-system))) |
1823 (or (and (boundp 'user-mail-address) user-mail-address) | 1840 (insert (format ";;;###coding system: %s\n" |
1824 (concat (user-login-name) "@" (system-name))) | 1841 (coding-system-name buffer-file-coding-system)))) |
1825 " on " | 1842 (insert (format |
1826 (current-time-string) "\n;;; from file " filename "\n") | 1843 "\n(or %s\n (error \"Loading this file requires: %s\"))\n" |
1827 (insert ";;; emacs version " emacs-version ".\n") | 1844 (setq checks-string |
1828 (insert ";;; bytecomp version " byte-compile-version "\n;;; " | 1845 (let ((print-readably t)) |
1829 (cond | 1846 (prin1-to-string (if (> (length |
1830 ((eq byte-optimize 'source) "source-level optimization only") | 1847 byte-compile-checks-on-load) |
1831 ((eq byte-optimize 'byte) "byte-level optimization only") | 1848 1) |
1832 (byte-optimize "optimization is on") | 1849 (cons 'and |
1833 (t "optimization is off")) | 1850 (reverse |
1834 (if (byte-compile-version-cond byte-compile-emacs19-compatibility) | 1851 byte-compile-checks-on-load)) |
1835 "; compiled with Emacs 19 compatibility.\n" | 1852 (car byte-compile-checks-on-load))))) |
1836 ".\n")) | 1853 checks-string)) |
1837 (if (not (byte-compile-version-cond byte-compile-emacs19-compatibility)) | 1854 (setq comments |
1838 (insert ";;; this file uses opcodes which do not exist in Emacs 19.\n" | 1855 (with-string-as-buffer-contents "" |
1839 ;; Have to check if emacs-version is bound so that this works | 1856 (insert "\n;;; compiled by " |
1840 ;; in files loaded early in loadup.el. | 1857 (or (and (boundp 'user-mail-address) user-mail-address) |
1841 "\n(if (and (boundp 'emacs-version)\n" | 1858 (concat (user-login-name) "@" (system-name))) |
1842 "\t (or (and (boundp 'epoch::version) epoch::version)\n" | 1859 " on " |
1843 "\t (string-lessp emacs-version \"20\")))\n" | 1860 (current-time-string) "\n;;; from file " filename "\n") |
1844 " (error \"`" | 1861 (insert ";;; emacs version " emacs-version ".\n") |
1845 ;; prin1-to-string is used to quote backslashes. | 1862 (insert ";;; bytecomp version " byte-compile-version "\n;;; " |
1846 (substring (prin1-to-string (file-name-nondirectory filename)) | 1863 (cond |
1847 1 -1) | 1864 ((eq byte-optimize 'source) |
1848 "' was compiled for Emacs 20\"))\n\n")) | 1865 "source-level optimization only") |
1849 (insert "(or (boundp 'current-load-list) (setq current-load-list nil))\n" | 1866 ((eq byte-optimize 'byte) "byte-level optimization only") |
1850 "\n") | 1867 (byte-optimize "optimization is on") |
1851 (if (and (byte-compile-version-cond byte-compile-emacs19-compatibility) | 1868 (t "optimization is off")) |
1852 dynamic-docstrings) | 1869 "\n"))) |
1853 (insert ";;; this file uses opcodes which do not exist prior to\n" | 1870 |
1854 ";;; XEmacs 19.14/GNU Emacs 19.29 or later." | 1871 ;; We won't trip this unless the byte-compiler changes, in which case |
1855 ;; Have to check if emacs-version is bound so that this works | 1872 ;; it's just a matter of upping the space. |
1856 ;; in files loaded early in loadup.el. | 1873 (assert (natnump (- (1+ byte-compile-checks-and-comments-space) (point))) |
1857 "\n(if (and (boundp 'emacs-version)\n" | 1874 t "Not enough space for the feature checks!") |
1858 "\t (or (and (boundp 'epoch::version) epoch::version)\n" | 1875 |
1859 "\t (and (not (string-match \"XEmacs\" emacs-version))\n" | 1876 (if (natnump (- (1+ byte-compile-checks-and-comments-space) |
1860 "\t (string-lessp emacs-version \"19.29\"))\n" | 1877 (+ (point) (length comments)))) |
1861 "\t (string-lessp emacs-version \"19.14\")))\n" | 1878 (insert comments)) |
1862 " (error \"`" | 1879 (insert-char ?\ (- (1+ byte-compile-checks-and-comments-space) |
1863 ;; prin1-to-string is used to quote backslashes. | 1880 (point))))) |
1864 (substring (prin1-to-string (file-name-nondirectory filename)) | 1881 |
1865 1 -1) | 1882 (defun byte-compile-maybe-reset-coding (byte-compile-inbuffer |
1866 "' was compiled for XEmacs 19.14/Emacs 19.29 or later\"))\n\n" | 1883 byte-compile-outbuffer) |
1867 ) | 1884 ;; We also reserve some space for the feature checks: |
1868 )) | 1885 (goto-char 1) |
1869 | 1886 (insert-char ?\ byte-compile-checks-and-comments-space) |
1870 ;; back in the inbuffer; determine and set the coding system for the .elc | |
1871 ;; file if under Mule. If there are any extended characters in the | |
1872 ;; input file, use `escape-quoted' to make sure that both binary and | |
1873 ;; extended characters are output properly and distinguished properly. | |
1874 ;; Otherwise, use `raw-text' for maximum portability with non-Mule | |
1875 ;; Emacsen. | |
1876 (if (or (featurep '(not mule)) ;; Don't scan buffer if we are not muleized | 1887 (if (or (featurep '(not mule)) ;; Don't scan buffer if we are not muleized |
1877 (and | 1888 (and |
1878 (not byte-compile-force-escape-quoted) | 1889 (not byte-compile-force-escape-quoted) |
1879 (save-excursion | 1890 (save-excursion |
1880 (set-buffer byte-compile-inbuffer) | 1891 (set-buffer byte-compile-inbuffer) |
1883 ;; escapes. Any such occurrences in a @#COUNT comment will lead | 1894 ;; escapes. Any such occurrences in a @#COUNT comment will lead |
1884 ;; to an escape-quoted coding cookie being inserted, but this is | 1895 ;; to an escape-quoted coding cookie being inserted, but this is |
1885 ;; not true of ordinary comments. | 1896 ;; not true of ordinary comments. |
1886 (let ((non-latin-1-re | 1897 (let ((non-latin-1-re |
1887 (concat "[^\000-\377]" | 1898 (concat "[^\000-\377]" |
1888 #r"\|\\u[0-9a-fA-F]\{4,4\}\|\\U[0-9a-fA-F]\{8,8\}")) | 1899 #r"\|\\u[0-9a-fA-F]\{4,4\}\|\\U[0-9a-fA-F]" |
1900 "\\{8,8\\}")) | |
1889 (case-fold-search nil)) | 1901 (case-fold-search nil)) |
1890 (catch 'need-to-escape-quote | 1902 (catch 'need-to-escape-quote |
1891 (while (re-search-forward non-latin-1-re nil t) | 1903 (while (re-search-forward non-latin-1-re nil t) |
1892 (skip-chars-backward "^;" (point-at-bol)) | 1904 (skip-chars-backward "^;" (point-at-bol)) |
1893 (if (bolp) (throw 'need-to-escape-quote nil)) | 1905 (if (bolp) (throw 'need-to-escape-quote nil)) |
1894 (forward-line 1)) | 1906 (forward-line 1)) |
1895 t))))) | 1907 t))))) |
1896 (setq buffer-file-coding-system 'raw-text-unix) | 1908 (setq buffer-file-coding-system 'raw-text-unix) |
1897 (insert "(or (featurep 'mule) (error \"Loading this file requires Mule support\")) | |
1898 ;;;###coding system: escape-quoted\n") | |
1899 (setq buffer-file-coding-system 'escape-quoted) | 1909 (setq buffer-file-coding-system 'escape-quoted) |
1900 ;; #### Lazy loading not yet implemented for MULE files | 1910 (pushnew '(featurep 'mule) byte-compile-checks-on-load) |
1901 ;; mrb - Fix this someday. | |
1902 (save-excursion | 1911 (save-excursion |
1903 (set-buffer byte-compile-inbuffer) | 1912 (set-buffer byte-compile-inbuffer) |
1904 (setq byte-compile-dynamic nil | 1913 (setq byte-compile-dynamic nil |
1905 byte-compile-dynamic-docstrings nil)) | 1914 byte-compile-dynamic-docstrings nil)))) |
1906 ;;(external-debugging-output (prin1-to-string (buffer-local-variables)))) | |
1907 ) | |
1908 ) | |
1909 | |
1910 | 1915 |
1911 (defun byte-compile-output-file-form (form) | 1916 (defun byte-compile-output-file-form (form) |
1912 ;; writes the given form to the output buffer, being careful of docstrings | 1917 ;; writes the given form to the output buffer, being careful of docstrings |
1913 ;; in defun, defmacro, defvar, defconst and autoload because make-docfile is | 1918 ;; in defun, defmacro, defvar, defconst and autoload because make-docfile is |
1914 ;; so amazingly stupid. | 1919 ;; so amazingly stupid. |
3082 (byte-defop-compiler delete-region 2+1) | 3087 (byte-defop-compiler delete-region 2+1) |
3083 (byte-defop-compiler narrow-to-region 2+1) | 3088 (byte-defop-compiler narrow-to-region 2+1) |
3084 (byte-defop-compiler (% byte-rem) 2) | 3089 (byte-defop-compiler (% byte-rem) 2) |
3085 (byte-defop-compiler aset 3) | 3090 (byte-defop-compiler aset 3) |
3086 | 3091 |
3092 (byte-defop-compiler-1 bind-multiple-value-limits) | |
3093 (byte-defop-compiler multiple-value-list-internal) | |
3094 (byte-defop-compiler-1 multiple-value-call) | |
3095 (byte-defop-compiler throw) | |
3096 | |
3087 (byte-defop-compiler-rmsfun member 2) | 3097 (byte-defop-compiler-rmsfun member 2) |
3088 (byte-defop-compiler-rmsfun assq 2) | 3098 (byte-defop-compiler-rmsfun assq 2) |
3089 | 3099 |
3090 ;;####(byte-defop-compiler move-to-column 1) | 3100 ;;####(byte-defop-compiler move-to-column 1) |
3091 (byte-defop-compiler-1 interactive byte-compile-noop) | 3101 (byte-defop-compiler-1 interactive byte-compile-noop) |
3100 ;; compiler. Note also that `%' is more efficient than `mod' because the | 3110 ;; compiler. Note also that `%' is more efficient than `mod' because the |
3101 ;; former is byte-coded and the latter is not. | 3111 ;; former is byte-coded and the latter is not. |
3102 ;;(byte-defop-compiler (mod byte-rem) 2) | 3112 ;;(byte-defop-compiler (mod byte-rem) 2) |
3103 | 3113 |
3104 | 3114 |
3105 (defun byte-compile-subr-wrong-args (form n) | 3115 (defun byte-compile-warn-wrong-args (form n) |
3106 (when (memq 'subr-callargs byte-compile-warnings) | 3116 (when (memq 'subr-callargs byte-compile-warnings) |
3107 (byte-compile-warn "%s called with %d arg%s, but requires %s" | 3117 (byte-compile-warn "%s called with %d arg%s, but requires %s" |
3108 (car form) (length (cdr form)) | 3118 (car form) (length (cdr form)) |
3109 (if (= 1 (length (cdr form))) "" "s") n)) | 3119 (if (= 1 (length (cdr form))) "" "s") n))) |
3120 | |
3121 (defun byte-compile-subr-wrong-args (form n) | |
3122 (byte-compile-warn-wrong-args form n) | |
3110 ;; get run-time wrong-number-of-args error. | 3123 ;; get run-time wrong-number-of-args error. |
3111 (byte-compile-normal-call form)) | 3124 (byte-compile-normal-call form)) |
3112 | 3125 |
3113 (defun byte-compile-no-args (form) | 3126 (defun byte-compile-no-args (form) |
3114 (case (length (cdr form)) | 3127 (case (length (cdr form)) |
3639 (setq for-effect nil)) | 3652 (setq for-effect nil)) |
3640 | 3653 |
3641 (byte-defop-compiler-1 inline byte-compile-progn) | 3654 (byte-defop-compiler-1 inline byte-compile-progn) |
3642 (byte-defop-compiler-1 progn) | 3655 (byte-defop-compiler-1 progn) |
3643 (byte-defop-compiler-1 prog1) | 3656 (byte-defop-compiler-1 prog1) |
3657 (byte-defop-compiler-1 multiple-value-prog1) | |
3658 (byte-defop-compiler-1 values) | |
3659 (byte-defop-compiler-1 values-list) | |
3644 (byte-defop-compiler-1 prog2) | 3660 (byte-defop-compiler-1 prog2) |
3645 (byte-defop-compiler-1 if) | 3661 (byte-defop-compiler-1 if) |
3646 (byte-defop-compiler-1 cond) | 3662 (byte-defop-compiler-1 cond) |
3647 (byte-defop-compiler-1 and) | 3663 (byte-defop-compiler-1 and) |
3648 (byte-defop-compiler-1 or) | 3664 (byte-defop-compiler-1 or) |
3658 (defun byte-compile-progn (form) | 3674 (defun byte-compile-progn (form) |
3659 (byte-compile-body-do-effect (cdr form))) | 3675 (byte-compile-body-do-effect (cdr form))) |
3660 | 3676 |
3661 (defun byte-compile-prog1 (form) | 3677 (defun byte-compile-prog1 (form) |
3662 (setq form (cdr form)) | 3678 (setq form (cdr form)) |
3679 ;; #'prog1 never returns multiple values: | |
3680 (byte-compile-form-do-effect (list 'values (pop form))) | |
3681 (byte-compile-body form t)) | |
3682 | |
3683 (defun byte-compile-multiple-value-prog1 (form) | |
3684 (setq form (cdr form)) | |
3663 (byte-compile-form-do-effect (pop form)) | 3685 (byte-compile-form-do-effect (pop form)) |
3664 (byte-compile-body form t)) | 3686 (byte-compile-body form t)) |
3687 | |
3688 (defun byte-compile-values (form) | |
3689 (if (and (= 2 (length form)) | |
3690 (byte-compile-constp (second form))) | |
3691 (byte-compile-form-do-effect (second form)) | |
3692 (byte-compile-normal-call form))) | |
3693 | |
3694 (defun byte-compile-values-list (form) | |
3695 (if (and (= 2 (length form)) | |
3696 (or (null (second form)) | |
3697 (and (consp (second form)) | |
3698 (eq (car (second form)) | |
3699 'quote) | |
3700 (not (symbolp (car-safe (cdr (second form)))))))) | |
3701 (byte-compile-form-do-effect (car-safe (cdr (second form)))) | |
3702 (byte-compile-normal-call form))) | |
3665 | 3703 |
3666 (defun byte-compile-prog2 (form) | 3704 (defun byte-compile-prog2 (form) |
3667 (setq form (cdr form)) | 3705 (setq form (cdr form)) |
3668 (byte-compile-form (pop form) t) | 3706 (byte-compile-form (pop form) t) |
3669 (byte-compile-form-do-effect (pop form)) | 3707 ;; #'prog2 never returns multiple values: |
3708 (byte-compile-form-do-effect (list 'values (pop form))) | |
3670 (byte-compile-body form t)) | 3709 (byte-compile-body form t)) |
3671 | 3710 |
3672 (defmacro byte-compile-goto-if (cond discard tag) | 3711 (defmacro byte-compile-goto-if (cond discard tag) |
3673 `(byte-compile-goto | 3712 `(byte-compile-goto |
3674 (if ,cond | 3713 (if ,cond |
3950 (byte-compile-form (car (cdr form))) | 3989 (byte-compile-form (car (cdr form))) |
3951 (byte-compile-out 'byte-temp-output-buffer-setup 0) | 3990 (byte-compile-out 'byte-temp-output-buffer-setup 0) |
3952 (byte-compile-body (cdr (cdr form))) | 3991 (byte-compile-body (cdr (cdr form))) |
3953 (byte-compile-out 'byte-temp-output-buffer-show 0)) | 3992 (byte-compile-out 'byte-temp-output-buffer-show 0)) |
3954 | 3993 |
3994 (defun byte-compile-multiple-value-call (form) | |
3995 (if (< (length form) 2) | |
3996 (progn | |
3997 (byte-compile-warn-wrong-args form 1) | |
3998 (byte-compile-normal-call | |
3999 `(signal 'wrong-number-of-arguments '(,(car form) | |
4000 ,(length (cdr form)))))) | |
4001 (setq form (cdr form)) | |
4002 (byte-compile-form (car form)) | |
4003 (byte-compile-push-constant 0) | |
4004 (byte-compile-variable-ref 'byte-varref 'multiple-values-limit) | |
4005 ;; bind-multiple-value-limits leaves two existing values on the stack, | |
4006 ;; and pushes a new value, the specpdl_depth() at the time it was | |
4007 ;; called. | |
4008 (byte-compile-out 'byte-bind-multiple-value-limits 0) | |
4009 (mapcar 'byte-compile-form (cdr form)) | |
4010 ;; Most of the other code puts this sort of value in the program stream, | |
4011 ;; not pushing it on the stack. | |
4012 (byte-compile-push-constant (+ 3 (length form))) | |
4013 (byte-compile-out 'byte-multiple-value-call (+ 3 (length form))) | |
4014 (pushnew '(subrp (symbol-function 'multiple-value-call)) | |
4015 byte-compile-checks-on-load | |
4016 :test #'equal))) | |
4017 | |
4018 (defun byte-compile-multiple-value-list-internal (form) | |
4019 (if (/= 4 (length form)) | |
4020 (progn | |
4021 (byte-compile-warn-wrong-args form 3) | |
4022 (byte-compile-normal-call | |
4023 `(signal 'wrong-number-of-arguments '(,(car form) | |
4024 ,(length (cdr form)))))) | |
4025 (byte-compile-form (nth 1 form)) | |
4026 (byte-compile-form (nth 2 form)) | |
4027 (byte-compile-out 'byte-bind-multiple-value-limits 0) | |
4028 (byte-compile-form (nth 3 form)) | |
4029 (byte-compile-out (get (car form) 'byte-opcode) 0) | |
4030 (pushnew '(subrp (symbol-function 'multiple-value-call)) | |
4031 byte-compile-checks-on-load | |
4032 :test #'equal))) | |
4033 | |
4034 (defun byte-compile-throw (form) | |
4035 ;; We can't use byte-compile-two-args for throw because in the event that | |
4036 ;; the form does not have two args, it tries to #'funcall it expecting a | |
4037 ;; runtime wrong-number-of-arguments error. Now that #'throw is a special | |
4038 ;; form, it provokes an invalid-function error instead (or at least it | |
4039 ;; should; there's a kludge around for the moment in eval.c that avoids | |
4040 ;; that, but this file should not assume that that will always be there). | |
4041 (if (/= 2 (length (cdr form))) | |
4042 (progn | |
4043 (byte-compile-warn-wrong-args form 2) | |
4044 (byte-compile-normal-call | |
4045 `(signal 'wrong-number-of-arguments '(,(car form) | |
4046 ,(length (cdr form)))))) | |
4047 (byte-compile-form (nth 1 form)) ;; Push the arguments | |
4048 (byte-compile-form (nth 2 form)) | |
4049 (byte-compile-out (get (car form) 'byte-opcode) 0) | |
4050 (pushnew '(null (function-max-args 'throw)) | |
4051 byte-compile-checks-on-load | |
4052 :test #'equal))) | |
3955 | 4053 |
3956 ;;; top-level forms elsewhere | 4054 ;;; top-level forms elsewhere |
3957 | 4055 |
3958 (byte-defop-compiler-1 defun) | 4056 (byte-defop-compiler-1 defun) |
3959 (byte-defop-compiler-1 defmacro) | 4057 (byte-defop-compiler-1 defmacro) |
4113 (setq byte-compile-depth (- byte-compile-depth offset))) | 4211 (setq byte-compile-depth (- byte-compile-depth offset))) |
4114 (byte-return | 4212 (byte-return |
4115 ;; This is actually an unnecessary case, because there should be | 4213 ;; This is actually an unnecessary case, because there should be |
4116 ;; no more opcodes behind byte-return. | 4214 ;; no more opcodes behind byte-return. |
4117 (setq byte-compile-depth nil)) | 4215 (setq byte-compile-depth nil)) |
4216 (byte-multiple-value-call | |
4217 (setq byte-compile-depth (- byte-compile-depth offset))) | |
4118 (t | 4218 (t |
4119 (setq byte-compile-depth (+ byte-compile-depth | 4219 (setq byte-compile-depth (+ byte-compile-depth |
4120 (or (aref byte-stack+-info | 4220 (or (aref byte-stack+-info |
4121 (symbol-value opcode)) | 4221 (symbol-value opcode)) |
4122 (- (1- offset)))) | 4222 (- (1- offset)))) |