Use Gnulib's `isnan' and `isinf' modules.
[bpt/guile.git] / libguile / expand.h
CommitLineData
dc3e203e
AW
1/* classes: h_files */
2
3#ifndef SCM_EXPAND_H
4#define SCM_EXPAND_H
5
6/* Copyright (C) 2010
7 * Free Software Foundation, Inc.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 3 of
12 * the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * 02110-1301 USA
23 */
24
25\f
26
27#include "libguile/__scm.h"
28
29
30\f
31
32#ifdef BUILDING_LIBGUILE
33
34/* All private for now. Ask if you want to use this. Surely this should be
35 auto-generated by something; for now I wrangle it with keyboard macros. */
36
37typedef enum
38 {
39 SCM_EXPANDED_VOID,
40 SCM_EXPANDED_CONST,
41 SCM_EXPANDED_PRIMITIVE_REF,
42 SCM_EXPANDED_LEXICAL_REF,
43 SCM_EXPANDED_LEXICAL_SET,
44 SCM_EXPANDED_MODULE_REF,
45 SCM_EXPANDED_MODULE_SET,
46 SCM_EXPANDED_TOPLEVEL_REF,
47 SCM_EXPANDED_TOPLEVEL_SET,
48 SCM_EXPANDED_TOPLEVEL_DEFINE,
49 SCM_EXPANDED_CONDITIONAL,
50 SCM_EXPANDED_APPLICATION,
51 SCM_EXPANDED_SEQUENCE,
52 SCM_EXPANDED_LAMBDA,
53 SCM_EXPANDED_LAMBDA_CASE,
54 SCM_EXPANDED_LET,
55 SCM_EXPANDED_LETREC,
56 SCM_EXPANDED_DYNLET,
57 SCM_NUM_EXPANDED_TYPES,
58 } scm_t_expanded_type;
59
60
61\f
62
63
64/* {Expanded Source}
65 */
66
67SCM_INTERNAL SCM scm_exp_vtable_vtable;
68
69enum
70 {
71 SCM_EXPANDED_TYPE_NAME = scm_vtable_offset_user,
72 SCM_EXPANDED_TYPE_CODE,
73 SCM_EXPANDED_TYPE_FIELDS,
74 };
75
76#define SCM_EXPANDED_P(x) \
77 (SCM_STRUCTP (x) && (SCM_STRUCT_VTABLE (SCM_STRUCT_VTABLE (x)) == scm_exp_vtable_vtable))
78#define SCM_EXPANDED_REF(x,type,field) \
79 (scm_struct_ref (x, SCM_I_MAKINUM (SCM_EXPANDED_##type##_##field)))
80#define SCM_EXPANDED_TYPE(x) \
81 SCM_STRUCT_DATA_REF (SCM_STRUCT_VTABLE (x), SCM_EXPANDED_TYPE_CODE)
82
83
84\f
85
86
87#define SCM_EXPANDED_VOID_TYPE_NAME "void"
88#define SCM_EXPANDED_VOID_FIELD_NAMES \
89 { "src" }
90enum
91 {
92 SCM_EXPANDED_VOID_SRC,
93 SCM_NUM_EXPANDED_VOID_FIELDS,
94 };
95#define SCM_MAKE_EXPANDED_VOID(src) \
96 scm_c_make_struct (exp_vtables[SCM_EXPANDED_VOID], 0, SCM_NUM_EXPANDED_VOID_FIELDS, SCM_UNPACK (src))
97
98#define SCM_EXPANDED_CONST_TYPE_NAME "const"
99#define SCM_EXPANDED_CONST_FIELD_NAMES \
100 { "src", "exp", }
101enum
102 {
103 SCM_EXPANDED_CONST_SRC,
104 SCM_EXPANDED_CONST_EXP,
105 SCM_NUM_EXPANDED_CONST_FIELDS,
106 };
107#define SCM_MAKE_EXPANDED_CONST(src, exp) \
108 scm_c_make_struct (exp_vtables[SCM_EXPANDED_CONST], 0, SCM_NUM_EXPANDED_CONST_FIELDS, SCM_UNPACK (src), SCM_UNPACK (exp))
109
110#define SCM_EXPANDED_PRIMITIVE_REF_TYPE_NAME "primitive-ref"
111#define SCM_EXPANDED_PRIMITIVE_REF_FIELD_NAMES \
112 { "src", "name", }
113enum
114 {
115 SCM_EXPANDED_PRIMITIVE_REF_SRC,
116 SCM_EXPANDED_PRIMITIVE_REF_NAME,
117 SCM_NUM_EXPANDED_PRIMITIVE_REF_FIELDS,
118 };
119#define SCM_MAKE_EXPANDED_PRIMITIVE_REF(src, name) \
120 scm_c_make_struct (exp_vtables[SCM_EXPANDED_PRIMITIVE_REF], 0, SCM_NUM_EXPANDED_PRIMITIVE_REF_FIELDS, SCM_UNPACK (src), SCM_UNPACK (name))
121
122#define SCM_EXPANDED_LEXICAL_REF_TYPE_NAME "lexical-ref"
123#define SCM_EXPANDED_LEXICAL_REF_FIELD_NAMES \
124 { "src", "name", "gensym", }
125enum
126 {
127 SCM_EXPANDED_LEXICAL_REF_SRC,
128 SCM_EXPANDED_LEXICAL_REF_NAME,
129 SCM_EXPANDED_LEXICAL_REF_GENSYM,
130 SCM_NUM_EXPANDED_LEXICAL_REF_FIELDS,
131 };
132#define SCM_MAKE_EXPANDED_LEXICAL_REF(src, name, gensym) \
133 scm_c_make_struct (exp_vtables[SCM_EXPANDED_LEXICAL_REF], 0, SCM_NUM_EXPANDED_LEXICAL_REF_FIELDS, SCM_UNPACK (src), SCM_UNPACK (name), SCM_UNPACK (gensym))
134
135#define SCM_EXPANDED_LEXICAL_SET_TYPE_NAME "lexical-set"
136#define SCM_EXPANDED_LEXICAL_SET_FIELD_NAMES \
137 { "src", "name", "gensym", "exp", }
138enum
139 {
140 SCM_EXPANDED_LEXICAL_SET_SRC,
141 SCM_EXPANDED_LEXICAL_SET_NAME,
142 SCM_EXPANDED_LEXICAL_SET_GENSYM,
143 SCM_EXPANDED_LEXICAL_SET_EXP,
144 SCM_NUM_EXPANDED_LEXICAL_SET_FIELDS,
145 };
146#define SCM_MAKE_EXPANDED_LEXICAL_SET(src, name, gensym, exp) \
147 scm_c_make_struct (exp_vtables[SCM_EXPANDED_LEXICAL_SET], 0, SCM_NUM_EXPANDED_LEXICAL_SET_FIELDS, SCM_UNPACK (src), SCM_UNPACK (name), SCM_UNPACK (gensym), SCM_UNPACK (exp))
148
149#define SCM_EXPANDED_MODULE_REF_TYPE_NAME "module-ref"
150#define SCM_EXPANDED_MODULE_REF_FIELD_NAMES \
e1ca9100 151 { "src", "mod", "name", "public?", }
dc3e203e
AW
152enum
153 {
154 SCM_EXPANDED_MODULE_REF_SRC,
155 SCM_EXPANDED_MODULE_REF_MOD,
156 SCM_EXPANDED_MODULE_REF_NAME,
157 SCM_EXPANDED_MODULE_REF_PUBLIC,
158 SCM_NUM_EXPANDED_MODULE_REF_FIELDS,
159 };
160#define SCM_MAKE_EXPANDED_MODULE_REF(src, mod, name, public) \
161 scm_c_make_struct (exp_vtables[SCM_EXPANDED_MODULE_REF], 0, SCM_NUM_EXPANDED_MODULE_REF_FIELDS, SCM_UNPACK (src), SCM_UNPACK (mod), SCM_UNPACK (name), SCM_UNPACK (public))
162
163#define SCM_EXPANDED_MODULE_SET_TYPE_NAME "module-set"
164#define SCM_EXPANDED_MODULE_SET_FIELD_NAMES \
e1ca9100 165 { "src", "mod", "name", "public?", "exp", }
dc3e203e
AW
166enum
167 {
168 SCM_EXPANDED_MODULE_SET_SRC,
169 SCM_EXPANDED_MODULE_SET_MOD,
170 SCM_EXPANDED_MODULE_SET_NAME,
171 SCM_EXPANDED_MODULE_SET_PUBLIC,
172 SCM_EXPANDED_MODULE_SET_EXP,
173 SCM_NUM_EXPANDED_MODULE_SET_FIELDS,
174 };
175#define SCM_MAKE_EXPANDED_MODULE_SET(src, mod, name, public, exp) \
176 scm_c_make_struct (exp_vtables[SCM_EXPANDED_MODULE_SET], 0, SCM_NUM_EXPANDED_MODULE_SET_FIELDS, SCM_UNPACK (src), SCM_UNPACK (mod), SCM_UNPACK (name), SCM_UNPACK (public), SCM_UNPACK (exp))
177
178#define SCM_EXPANDED_TOPLEVEL_REF_TYPE_NAME "toplevel-ref"
179#define SCM_EXPANDED_TOPLEVEL_REF_FIELD_NAMES \
180 { "src", "name", }
181enum
182 {
183 SCM_EXPANDED_TOPLEVEL_REF_SRC,
184 SCM_EXPANDED_TOPLEVEL_REF_NAME,
185 SCM_NUM_EXPANDED_TOPLEVEL_REF_FIELDS,
186 };
187#define SCM_MAKE_EXPANDED_TOPLEVEL_REF(src, name) \
188 scm_c_make_struct (exp_vtables[SCM_EXPANDED_TOPLEVEL_REF], 0, SCM_NUM_EXPANDED_TOPLEVEL_REF_FIELDS, SCM_UNPACK (src), SCM_UNPACK (name))
189
190#define SCM_EXPANDED_TOPLEVEL_SET_TYPE_NAME "toplevel-set"
191#define SCM_EXPANDED_TOPLEVEL_SET_FIELD_NAMES \
192 { "src", "name", "exp", }
193enum
194 {
195 SCM_EXPANDED_TOPLEVEL_SET_SRC,
196 SCM_EXPANDED_TOPLEVEL_SET_NAME,
197 SCM_EXPANDED_TOPLEVEL_SET_EXP,
198 SCM_NUM_EXPANDED_TOPLEVEL_SET_FIELDS,
199 };
200#define SCM_MAKE_EXPANDED_TOPLEVEL_SET(src, name, exp) \
201 scm_c_make_struct (exp_vtables[SCM_EXPANDED_TOPLEVEL_SET], 0, SCM_NUM_EXPANDED_TOPLEVEL_SET_FIELDS, SCM_UNPACK (src), SCM_UNPACK (name), SCM_UNPACK (exp))
202
203#define SCM_EXPANDED_TOPLEVEL_DEFINE_TYPE_NAME "toplevel-define"
204#define SCM_EXPANDED_TOPLEVEL_DEFINE_FIELD_NAMES \
205 { "src", "name", "exp", }
206enum
207 {
208 SCM_EXPANDED_TOPLEVEL_DEFINE_SRC,
209 SCM_EXPANDED_TOPLEVEL_DEFINE_NAME,
210 SCM_EXPANDED_TOPLEVEL_DEFINE_EXP,
211 SCM_NUM_EXPANDED_TOPLEVEL_DEFINE_FIELDS,
212 };
213#define SCM_MAKE_EXPANDED_TOPLEVEL_DEFINE(src, name, exp) \
214 scm_c_make_struct (exp_vtables[SCM_EXPANDED_TOPLEVEL_DEFINE], 0, SCM_NUM_EXPANDED_TOPLEVEL_DEFINE_FIELDS, SCM_UNPACK (src), SCM_UNPACK (name), SCM_UNPACK (exp))
215
216#define SCM_EXPANDED_CONDITIONAL_TYPE_NAME "conditional"
217#define SCM_EXPANDED_CONDITIONAL_FIELD_NAMES \
218 { "src", "test", "consequent", "alternate", }
219enum
220 {
221 SCM_EXPANDED_CONDITIONAL_SRC,
222 SCM_EXPANDED_CONDITIONAL_TEST,
223 SCM_EXPANDED_CONDITIONAL_CONSEQUENT,
224 SCM_EXPANDED_CONDITIONAL_ALTERNATE,
225 SCM_NUM_EXPANDED_CONDITIONAL_FIELDS,
226 };
227#define SCM_MAKE_EXPANDED_CONDITIONAL(src, test, consequent, alternate) \
228 scm_c_make_struct (exp_vtables[SCM_EXPANDED_CONDITIONAL], 0, SCM_NUM_EXPANDED_CONDITIONAL_FIELDS, SCM_UNPACK (src), SCM_UNPACK (test), SCM_UNPACK (consequent), SCM_UNPACK (alternate))
229
230#define SCM_EXPANDED_APPLICATION_TYPE_NAME "application"
231#define SCM_EXPANDED_APPLICATION_FIELD_NAMES \
e1ca9100 232 { "src", "proc", "args", }
dc3e203e
AW
233enum
234 {
235 SCM_EXPANDED_APPLICATION_SRC,
236 SCM_EXPANDED_APPLICATION_PROC,
e1ca9100 237 SCM_EXPANDED_APPLICATION_ARGS,
dc3e203e
AW
238 SCM_NUM_EXPANDED_APPLICATION_FIELDS,
239 };
e1ca9100
AW
240#define SCM_MAKE_EXPANDED_APPLICATION(src, proc, args) \
241 scm_c_make_struct (exp_vtables[SCM_EXPANDED_APPLICATION], 0, SCM_NUM_EXPANDED_APPLICATION_FIELDS, SCM_UNPACK (src), SCM_UNPACK (proc), SCM_UNPACK (args))
dc3e203e
AW
242
243#define SCM_EXPANDED_SEQUENCE_TYPE_NAME "sequence"
244#define SCM_EXPANDED_SEQUENCE_FIELD_NAMES \
245 { "src", "exps", }
246enum
247 {
248 SCM_EXPANDED_SEQUENCE_SRC,
249 SCM_EXPANDED_SEQUENCE_EXPS,
250 SCM_NUM_EXPANDED_SEQUENCE_FIELDS,
251 };
252#define SCM_MAKE_EXPANDED_SEQUENCE(src, exps) \
253 scm_c_make_struct (exp_vtables[SCM_EXPANDED_SEQUENCE], 0, SCM_NUM_EXPANDED_SEQUENCE_FIELDS, SCM_UNPACK (src), SCM_UNPACK (exps))
254
255#define SCM_EXPANDED_LAMBDA_TYPE_NAME "lambda"
256#define SCM_EXPANDED_LAMBDA_FIELD_NAMES \
257 { "src", "meta", "body", }
258enum
259 {
260 SCM_EXPANDED_LAMBDA_SRC,
261 SCM_EXPANDED_LAMBDA_META,
262 SCM_EXPANDED_LAMBDA_BODY,
263 SCM_NUM_EXPANDED_LAMBDA_FIELDS,
264 };
265#define SCM_MAKE_EXPANDED_LAMBDA(src, meta, body) \
266 scm_c_make_struct (exp_vtables[SCM_EXPANDED_LAMBDA], 0, SCM_NUM_EXPANDED_LAMBDA_FIELDS, SCM_UNPACK (src), SCM_UNPACK (meta), SCM_UNPACK (body))
267
268#define SCM_EXPANDED_LAMBDA_CASE_TYPE_NAME "lambda-case"
269#define SCM_EXPANDED_LAMBDA_CASE_FIELD_NAMES \
270 { "src", "req", "opt", "rest", "kw", "inits", "gensyms", "body", "alternate", }
271enum
272 {
273 SCM_EXPANDED_LAMBDA_CASE_SRC,
274 SCM_EXPANDED_LAMBDA_CASE_REQ,
275 SCM_EXPANDED_LAMBDA_CASE_OPT,
276 SCM_EXPANDED_LAMBDA_CASE_REST,
277 SCM_EXPANDED_LAMBDA_CASE_KW,
278 SCM_EXPANDED_LAMBDA_CASE_INITS,
279 SCM_EXPANDED_LAMBDA_CASE_GENSYMS,
280 SCM_EXPANDED_LAMBDA_CASE_BODY,
281 SCM_EXPANDED_LAMBDA_CASE_ALTERNATE,
282 SCM_NUM_EXPANDED_LAMBDA_CASE_FIELDS,
283 };
284#define SCM_MAKE_EXPANDED_LAMBDA_CASE(src, req, opt, rest, kw, inits, gensyms, body, alternate) \
285 scm_c_make_struct (exp_vtables[SCM_EXPANDED_LAMBDA_CASE], 0, SCM_NUM_EXPANDED_LAMBDA_CASE_FIELDS, SCM_UNPACK (src), SCM_UNPACK (req), SCM_UNPACK (opt), SCM_UNPACK (rest), SCM_UNPACK (kw), SCM_UNPACK (inits), SCM_UNPACK (gensyms), SCM_UNPACK (body), SCM_UNPACK (alternate))
286
287#define SCM_EXPANDED_LET_TYPE_NAME "let"
288#define SCM_EXPANDED_LET_FIELD_NAMES \
289 { "src", "names", "gensyms", "vals", "body", }
290enum
291 {
292 SCM_EXPANDED_LET_SRC,
293 SCM_EXPANDED_LET_NAMES,
294 SCM_EXPANDED_LET_GENSYMS,
295 SCM_EXPANDED_LET_VALS,
296 SCM_EXPANDED_LET_BODY,
297 SCM_NUM_EXPANDED_LET_FIELDS,
298 };
299#define SCM_MAKE_EXPANDED_LET(src, names, gensyms, vals, body) \
300 scm_c_make_struct (exp_vtables[SCM_EXPANDED_LET], 0, SCM_NUM_EXPANDED_LET_FIELDS, SCM_UNPACK (src), SCM_UNPACK (names), SCM_UNPACK (gensyms), SCM_UNPACK (vals), SCM_UNPACK (body))
301
302#define SCM_EXPANDED_LETREC_TYPE_NAME "letrec"
303#define SCM_EXPANDED_LETREC_FIELD_NAMES \
fb6e61ca 304 { "src", "in-order?", "names", "gensyms", "vals", "body", }
dc3e203e
AW
305enum
306 {
307 SCM_EXPANDED_LETREC_SRC,
fb6e61ca 308 SCM_EXPANDED_LETREC_IN_ORDER_P,
dc3e203e
AW
309 SCM_EXPANDED_LETREC_NAMES,
310 SCM_EXPANDED_LETREC_GENSYMS,
311 SCM_EXPANDED_LETREC_VALS,
312 SCM_EXPANDED_LETREC_BODY,
313 SCM_NUM_EXPANDED_LETREC_FIELDS,
314 };
fb6e61ca
AW
315#define SCM_MAKE_EXPANDED_LETREC(src, in_order_p, names, gensyms, vals, body) \
316 scm_c_make_struct (exp_vtables[SCM_EXPANDED_LETREC], 0, SCM_NUM_EXPANDED_LETREC_FIELDS, SCM_UNPACK (src), SCM_UNPACK (in_order_p), SCM_UNPACK (names), SCM_UNPACK (gensyms), SCM_UNPACK (vals), SCM_UNPACK (body))
dc3e203e
AW
317
318#define SCM_EXPANDED_DYNLET_TYPE_NAME "dynlet"
319#define SCM_EXPANDED_DYNLET_FIELD_NAMES \
320 { "src", "fluids", "vals", "body", }
321enum
322 {
323 SCM_EXPANDED_DYNLET_SRC,
324 SCM_EXPANDED_DYNLET_FLUIDS,
325 SCM_EXPANDED_DYNLET_VALS,
326 SCM_EXPANDED_DYNLET_BODY,
327 SCM_NUM_EXPANDED_DYNLET_FIELDS,
328 };
329#define SCM_MAKE_EXPANDED_DYNLET(src, fluids, vals, body) \
330 scm_c_make_struct (exp_vtables[SCM_EXPANDED_DYNLET], 0, SCM_NUM_EXPANDED_DYNLET_FIELDS, SCM_UNPACK (src), SCM_UNPACK (fluids), SCM_UNPACK (vals), SCM_UNPACK (body))
331
332#endif /* BUILDING_LIBGUILE */
333
334\f
335
336SCM_INTERNAL SCM scm_macroexpand (SCM exp);
a310a1d1 337SCM_INTERNAL SCM scm_macroexpanded_p (SCM exp);
dc3e203e
AW
338
339SCM_INTERNAL void scm_init_expand (void);
340
341
342#endif /* SCM_EXPAND_H */
343
344/*
345 Local Variables:
346 c-file-style: "gnu"
347 End:
348*/