Partially sync files.el from XEmacs 21.5 for wildcard support.
[sxemacs] / src / bytecode.h
1 /* Definitions for bytecode interpretation and compiled-function objects.
2    Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc.
3
4 This file is part of SXEmacs
5
6 SXEmacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 SXEmacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
18
19
20 /* Synched up with: Not in FSF. */
21
22 /* Authorship:
23
24    FSF: long ago.
25    Mly: rewrote for 19.8, properly abstracted.
26    Jon Reid: some changes for I18N3 (domain, etc), for 19.8.
27  */
28
29 #ifndef INCLUDED_bytecode_h_
30 #define INCLUDED_bytecode_h_
31
32 /* Meanings of slots in a Lisp_Compiled_Function.
33    Don't use these!  For backward compatibility only.  */
34 #define COMPILED_ARGLIST        0
35 #define COMPILED_INSTRUCTIONS   1
36 #define COMPILED_CONSTANTS      2
37 #define COMPILED_STACK_DEPTH    3
38 #define COMPILED_DOC_STRING     4
39 #define COMPILED_INTERACTIVE    5
40 #define COMPILED_DOMAIN         6
41
42 /* It doesn't make sense to have this and also have load-history */
43 /* #define COMPILED_FUNCTION_ANNOTATION_HACK */
44
45 struct Lisp_Compiled_Function {
46         struct lrecord_header lheader;
47         unsigned short stack_depth;
48         unsigned short specpdl_depth;
49         struct {
50                 unsigned int documentationp:1;
51                 unsigned int interactivep:1;
52                 /* Only used if I18N3, but always defined for simplicity. */
53                 unsigned int domainp:1;
54                 /* Non-zero if this bytecode came from a v18 or v19 file.
55                    We need to Ebolify the `assoc', `delq', etc. functions. */
56                 unsigned int ebolified:1;
57         } flags;
58         Lisp_Object instructions;
59         Lisp_Object constants;
60         Lisp_Object arglist;
61         /* This uses the minimal number of conses; see accessors in data.c. */
62         Lisp_Object doc_and_interactive;
63 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
64         /* Something indicating where the bytecode came from */
65         Lisp_Object annotated;
66 #endif
67 };
68 typedef struct Lisp_Compiled_Function Lisp_Compiled_Function;
69
70 Lisp_Object run_byte_code(Lisp_Object compiled_function_or_instructions, ...);
71
72 Lisp_Object compiled_function_arglist(Lisp_Compiled_Function * f);
73 Lisp_Object compiled_function_instructions(Lisp_Compiled_Function * f);
74 Lisp_Object compiled_function_constants(Lisp_Compiled_Function * f);
75 int compiled_function_stack_depth(Lisp_Compiled_Function * f);
76 Lisp_Object compiled_function_documentation(Lisp_Compiled_Function * f);
77 Lisp_Object compiled_function_annotation(Lisp_Compiled_Function * f);
78 Lisp_Object compiled_function_domain(Lisp_Compiled_Function * f);
79 Lisp_Object compiled_function_interactive(Lisp_Compiled_Function * f);
80
81 void set_compiled_function_documentation(Lisp_Compiled_Function * f,
82                                          Lisp_Object new_doc);
83
84 Lisp_Object funcall_compiled_function(Lisp_Object fun,
85                                       int nargs, Lisp_Object args[]);
86 void optimize_compiled_function(Lisp_Object compiled_function);
87
88 DECLARE_LRECORD(compiled_function, Lisp_Compiled_Function);
89 #define XCOMPILED_FUNCTION(x) XRECORD (x, compiled_function, \
90                                        Lisp_Compiled_Function)
91 #define XSETCOMPILED_FUNCTION(x, p) XSETRECORD (x, p, compiled_function)
92 #define COMPILED_FUNCTIONP(x) RECORDP (x, compiled_function)
93 #define CHECK_COMPILED_FUNCTION(x) CHECK_RECORD (x, compiled_function)
94 #define CONCHECK_COMPILED_FUNCTION(x) CONCHECK_RECORD (x, compiled_function)
95
96 extern Lisp_Object Qbyte_code;
97
98 /* total 1765 internal 101 doc-and-int 775 doc-only 389 int-only 42 neither 559
99  no doc slot, no int slot
100     overhead                        : (* 1765 0) =    0
101     doc-and-int (args . (doc . int)): (*  775 4) = 3100
102     doc-only    (args . doc)        : (*  389 2) =  778
103     int-only    (args . int)        : (*   42 2) =   84
104     neither     args                : (*  559 0) =    0 = 3962
105  combined
106     overhead                        : (* 1765 1) = 1765
107     doc-and-int (doc . int)         : (*  775 2) = 1550
108     doc-only    doc                 : (*  389 0) =    0
109     int-only    int                 : (*   42 0) =    0
110     neither     -                   : (*  559 0) =    0 = 3315
111  both
112     overhead                        : (* 1765 2) = 3530
113     doc-and-int -                   : (*  775 0) =    0
114     doc-only    -                   : (*  389 0) =    0
115     int-only    -                   : (*   42 0) =    0
116     neither     -                   : (*  559 0)  =   0 = 3530
117 */
118
119 #endif                          /* INCLUDED_bytecode_h_ */