-
Notifications
You must be signed in to change notification settings - Fork 11
/
accessors.h
509 lines (488 loc) · 17.5 KB
/
accessors.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
// Autogenerated file; see corresponding .js
/* accessors for simple type #1 or t (tag) implemented as tag_t */
#define MAX_t LONG_LONG_MAX
#define CTYPE_t tag_t
#define T_t 1
#define IS_t(v) ( (v)->t==1 )
#define AS_t(v,n) ({ \
ASSERT(IS_t(v)==1, "AS_t: type not t");\
tag_t __x=EL(v,tag_t,n); __x; })
/* create a single-item tag containing C value x (a tag_t) */
static inline VP xt(tag_t x) { VP a; a=xalloc(1,1); EL(a,tag_t,0)=x; a->n=1; return a; }
/* create an empty tag */
static inline VP xt0() { VP a=xalloc(1,1); return a; }
/* return an empty tag of size sz */
static inline VP xtsz(int sz) { VP a=xalloc(1,sz); return a; }
/* append C value y (a tag_t) to x */
static inline VP xta(VP x, tag_t y) { x=xrealloc(x,x->n++); EL(x,tag_t,x->n-1)=y; return x; }
/* create a tag using C variable arguments - VP r = xtn(2, tag_t_a, tag_t_b) */
static inline VP xtn(int nargs,...) {
VP a; va_list args; int i; long long x;
a=xalloc(T_t,nargs); a->n=nargs;
va_start(args,nargs);
for(i=0;i<nargs;i++){ x=va_arg(args,long long); EL(a,tag_t,i)=x; }
return a;
}
/* append to tag using var args */
static inline VP xtan(VP a, int nargs,...) {
va_list args; int i; tag_t x;
a=xrealloc(a,a->n+nargs); va_start(args,nargs);
for(i=0;i<nargs;i++) {
x=va_arg(args,long long);
EL(a,tag_t,(a->n)+i)=x;
}
a->n+=nargs;
return a;
}
/* accessors for simple type #2 or c (char) implemented as char */
#define MAX_c SCHAR_MAX
#define CTYPE_c char
#define T_c 2
#define IS_c(v) ( (v)->t==2 )
#define AS_c(v,n) ({ \
ASSERT(IS_c(v)==1, "AS_c: type not c");\
char __x=EL(v,char,n); __x; })
/* create a single-item char containing C value x (a char) */
static inline VP xc(char x) { VP a; a=xalloc(2,1); EL(a,char,0)=x; a->n=1; return a; }
/* create an empty char */
static inline VP xc0() { VP a=xalloc(2,1); return a; }
/* return an empty char of size sz */
static inline VP xcsz(int sz) { VP a=xalloc(2,sz); return a; }
/* append C value y (a char) to x */
static inline VP xca(VP x, char y) { x=xrealloc(x,x->n++); EL(x,char,x->n-1)=y; return x; }
/* create a char using C variable arguments - VP r = xcn(2, char_a, char_b) */
static inline VP xcn(int nargs,...) {
VP a; va_list args; int i; int x;
a=xalloc(T_c,nargs); a->n=nargs;
va_start(args,nargs);
for(i=0;i<nargs;i++){ x=va_arg(args,int); EL(a,char,i)=x; }
return a;
}
/* append to char using var args */
static inline VP xcan(VP a, int nargs,...) {
va_list args; int i; char x;
a=xrealloc(a,a->n+nargs); va_start(args,nargs);
for(i=0;i<nargs;i++) {
x=va_arg(args,int);
EL(a,char,(a->n)+i)=x;
}
a->n+=nargs;
return a;
}
/* accessors for simple type #3 or b (byte) implemented as int8_t */
#define MAX_b SCHAR_MAX
#define CTYPE_b int8_t
#define T_b 3
#define IS_b(v) ( (v)->t==3 )
#define AS_b(v,n) ({ \
ASSERT(IS_b(v)==1, "AS_b: type not b");\
int8_t __x=EL(v,int8_t,n); __x; })
/* create a single-item byte containing C value x (a int8_t) */
static inline VP xb(int8_t x) { VP a; a=xalloc(3,1); EL(a,int8_t,0)=x; a->n=1; return a; }
/* create an empty byte */
static inline VP xb0() { VP a=xalloc(3,1); return a; }
/* return an empty byte of size sz */
static inline VP xbsz(int sz) { VP a=xalloc(3,sz); return a; }
/* append C value y (a int8_t) to x */
static inline VP xba(VP x, int8_t y) { x=xrealloc(x,x->n++); EL(x,int8_t,x->n-1)=y; return x; }
/* create a byte using C variable arguments - VP r = xbn(2, int8_t_a, int8_t_b) */
static inline VP xbn(int nargs,...) {
VP a; va_list args; int i; int x;
a=xalloc(T_b,nargs); a->n=nargs;
va_start(args,nargs);
for(i=0;i<nargs;i++){ x=va_arg(args,int); EL(a,int8_t,i)=x; }
return a;
}
/* append to byte using var args */
static inline VP xban(VP a, int nargs,...) {
va_list args; int i; int8_t x;
a=xrealloc(a,a->n+nargs); va_start(args,nargs);
for(i=0;i<nargs;i++) {
x=va_arg(args,int);
EL(a,int8_t,(a->n)+i)=x;
}
a->n+=nargs;
return a;
}
/* accessors for simple type #4 or i (int) implemented as int */
#define MAX_i INT_MAX
#define CTYPE_i int
#define T_i 4
#define IS_i(v) ( (v)->t==4 )
#define AS_i(v,n) ({ \
ASSERT(IS_i(v)==1, "AS_i: type not i");\
int __x=EL(v,int,n); __x; })
/* create a single-item int containing C value x (a int) */
static inline VP xi(int x) { VP a; a=xalloc(4,1); EL(a,int,0)=x; a->n=1; return a; }
/* create an empty int */
static inline VP xi0() { VP a=xalloc(4,1); return a; }
/* return an empty int of size sz */
static inline VP xisz(int sz) { VP a=xalloc(4,sz); return a; }
/* append C value y (a int) to x */
static inline VP xia(VP x, int y) { x=xrealloc(x,x->n++); EL(x,int,x->n-1)=y; return x; }
/* create a int using C variable arguments - VP r = xin(2, int_a, int_b) */
static inline VP xin(int nargs,...) {
VP a; va_list args; int i; int x;
a=xalloc(T_i,nargs); a->n=nargs;
va_start(args,nargs);
for(i=0;i<nargs;i++){ x=va_arg(args,int); EL(a,int,i)=x; }
return a;
}
/* append to int using var args */
static inline VP xian(VP a, int nargs,...) {
va_list args; int i; int x;
a=xrealloc(a,a->n+nargs); va_start(args,nargs);
for(i=0;i<nargs;i++) {
x=va_arg(args,int);
EL(a,int,(a->n)+i)=x;
}
a->n+=nargs;
return a;
}
/* accessors for simple type #5 or j (long) implemented as __int64_t */
#define MAX_j LONG_MAX
#define CTYPE_j __int64_t
#define T_j 5
#define IS_j(v) ( (v)->t==5 )
#define AS_j(v,n) ({ \
ASSERT(IS_j(v)==1, "AS_j: type not j");\
__int64_t __x=EL(v,__int64_t,n); __x; })
/* create a single-item long containing C value x (a __int64_t) */
static inline VP xj(__int64_t x) { VP a; a=xalloc(5,1); EL(a,__int64_t,0)=x; a->n=1; return a; }
/* create an empty long */
static inline VP xj0() { VP a=xalloc(5,1); return a; }
/* return an empty long of size sz */
static inline VP xjsz(int sz) { VP a=xalloc(5,sz); return a; }
/* append C value y (a __int64_t) to x */
static inline VP xja(VP x, __int64_t y) { x=xrealloc(x,x->n++); EL(x,__int64_t,x->n-1)=y; return x; }
/* create a long using C variable arguments - VP r = xjn(2, __int64_t_a, __int64_t_b) */
static inline VP xjn(int nargs,...) {
VP a; va_list args; int i; int x;
a=xalloc(T_j,nargs); a->n=nargs;
va_start(args,nargs);
for(i=0;i<nargs;i++){ x=va_arg(args,int); EL(a,__int64_t,i)=x; }
return a;
}
/* append to long using var args */
static inline VP xjan(VP a, int nargs,...) {
va_list args; int i; __int64_t x;
a=xrealloc(a,a->n+nargs); va_start(args,nargs);
for(i=0;i<nargs;i++) {
x=va_arg(args,int);
EL(a,__int64_t,(a->n)+i)=x;
}
a->n+=nargs;
return a;
}
/* accessors for simple type #6 or o (octa) implemented as __int128_t */
#define MAX_o LONG_LONG_MAX
#define CTYPE_o __int128_t
#define T_o 6
#define IS_o(v) ( (v)->t==6 )
#define AS_o(v,n) ({ \
ASSERT(IS_o(v)==1, "AS_o: type not o");\
__int128_t __x=EL(v,__int128_t,n); __x; })
/* create a single-item octa containing C value x (a __int128_t) */
static inline VP xo(__int128_t x) { VP a; a=xalloc(6,1); EL(a,__int128_t,0)=x; a->n=1; return a; }
/* create an empty octa */
static inline VP xo0() { VP a=xalloc(6,1); return a; }
/* return an empty octa of size sz */
static inline VP xosz(int sz) { VP a=xalloc(6,sz); return a; }
/* append C value y (a __int128_t) to x */
static inline VP xoa(VP x, __int128_t y) { x=xrealloc(x,x->n++); EL(x,__int128_t,x->n-1)=y; return x; }
/* create a octa using C variable arguments - VP r = xon(2, __int128_t_a, __int128_t_b) */
static inline VP xon(int nargs,...) {
VP a; va_list args; int i; int x;
a=xalloc(T_o,nargs); a->n=nargs;
va_start(args,nargs);
for(i=0;i<nargs;i++){ x=va_arg(args,int); EL(a,__int128_t,i)=x; }
return a;
}
/* append to octa using var args */
static inline VP xoan(VP a, int nargs,...) {
va_list args; int i; __int128_t x;
a=xrealloc(a,a->n+nargs); va_start(args,nargs);
for(i=0;i<nargs;i++) {
x=va_arg(args,int);
EL(a,__int128_t,(a->n)+i)=x;
}
a->n+=nargs;
return a;
}
/* accessors for simple type #7 or f (float) implemented as double */
#define MAX_f DBL_MAX
#define CTYPE_f double
#define T_f 7
#define IS_f(v) ( (v)->t==7 )
#define AS_f(v,n) ({ \
ASSERT(IS_f(v)==1, "AS_f: type not f");\
double __x=EL(v,double,n); __x; })
/* create a single-item float containing C value x (a double) */
static inline VP xf(double x) { VP a; a=xalloc(7,1); EL(a,double,0)=x; a->n=1; return a; }
/* create an empty float */
static inline VP xf0() { VP a=xalloc(7,1); return a; }
/* return an empty float of size sz */
static inline VP xfsz(int sz) { VP a=xalloc(7,sz); return a; }
/* append C value y (a double) to x */
static inline VP xfa(VP x, double y) { x=xrealloc(x,x->n++); EL(x,double,x->n-1)=y; return x; }
/* create a float using C variable arguments - VP r = xfn(2, double_a, double_b) */
static inline VP xfn(int nargs,...) {
VP a; va_list args; int i; double x;
a=xalloc(T_f,nargs); a->n=nargs;
va_start(args,nargs);
for(i=0;i<nargs;i++){ x=va_arg(args,double); EL(a,double,i)=x; }
return a;
}
/* append to float using var args */
static inline VP xfan(VP a, int nargs,...) {
va_list args; int i; double x;
a=xrealloc(a,a->n+nargs); va_start(args,nargs);
for(i=0;i<nargs;i++) {
x=va_arg(args,double);
EL(a,double,(a->n)+i)=x;
}
a->n+=nargs;
return a;
}
/* accessors for simple type #10 or 1 (f1) implemented as unaryFunc* */
#define MAX_1 0
#define CTYPE_1 unaryFunc*
#define T_1 10
#define IS_1(v) ( (v)->t==10 )
#define AS_1(v,n) ({ \
ASSERT(IS_1(v)==1, "AS_1: type not 1");\
unaryFunc* __x=EL(v,unaryFunc*,n); __x; })
/* create a single-item f1 containing C value x (a unaryFunc*) */
static inline VP x1(unaryFunc* x) { VP a; a=xalloc(10,1); EL(a,unaryFunc*,0)=x; a->n=1; return a; }
/* create an empty f1 */
static inline VP x10() { VP a=xalloc(10,1); return a; }
/* return an empty f1 of size sz */
static inline VP x1sz(int sz) { VP a=xalloc(10,sz); return a; }
/* append C value y (a unaryFunc*) to x */
static inline VP x1a(VP x, unaryFunc* y) { x=xrealloc(x,x->n++); EL(x,unaryFunc*,x->n-1)=y; return x; }
/* create a f1 using C variable arguments - VP r = x1n(2, unaryFunc*_a, unaryFunc*_b) */
static inline VP x1n(int nargs,...) {
VP a; va_list args; int i; unaryFunc* x;
a=xalloc(T_1,nargs); a->n=nargs;
va_start(args,nargs);
for(i=0;i<nargs;i++){ x=va_arg(args,unaryFunc*); EL(a,unaryFunc*,i)=x; }
return a;
}
/* append to f1 using var args */
static inline VP x1an(VP a, int nargs,...) {
va_list args; int i; unaryFunc* x;
a=xrealloc(a,a->n+nargs); va_start(args,nargs);
for(i=0;i<nargs;i++) {
x=va_arg(args,unaryFunc*);
EL(a,unaryFunc*,(a->n)+i)=x;
}
a->n+=nargs;
return a;
}
/* accessors for simple type #11 or 2 (f2) implemented as binaryFunc* */
#define MAX_2 0
#define CTYPE_2 binaryFunc*
#define T_2 11
#define IS_2(v) ( (v)->t==11 )
#define AS_2(v,n) ({ \
ASSERT(IS_2(v)==1, "AS_2: type not 2");\
binaryFunc* __x=EL(v,binaryFunc*,n); __x; })
/* create a single-item f2 containing C value x (a binaryFunc*) */
static inline VP x2(binaryFunc* x) { VP a; a=xalloc(11,1); EL(a,binaryFunc*,0)=x; a->n=1; return a; }
/* create an empty f2 */
static inline VP x20() { VP a=xalloc(11,1); return a; }
/* return an empty f2 of size sz */
static inline VP x2sz(int sz) { VP a=xalloc(11,sz); return a; }
/* append C value y (a binaryFunc*) to x */
static inline VP x2a(VP x, binaryFunc* y) { x=xrealloc(x,x->n++); EL(x,binaryFunc*,x->n-1)=y; return x; }
/* create a f2 using C variable arguments - VP r = x2n(2, binaryFunc*_a, binaryFunc*_b) */
static inline VP x2n(int nargs,...) {
VP a; va_list args; int i; binaryFunc* x;
a=xalloc(T_2,nargs); a->n=nargs;
va_start(args,nargs);
for(i=0;i<nargs;i++){ x=va_arg(args,binaryFunc*); EL(a,binaryFunc*,i)=x; }
return a;
}
/* append to f2 using var args */
static inline VP x2an(VP a, int nargs,...) {
va_list args; int i; binaryFunc* x;
a=xrealloc(a,a->n+nargs); va_start(args,nargs);
for(i=0;i<nargs;i++) {
x=va_arg(args,binaryFunc*);
EL(a,binaryFunc*,(a->n)+i)=x;
}
a->n+=nargs;
return a;
}
/* accessors for simple type #12 or p (proj) implemented as Proj */
#define MAX_p 0
#define CTYPE_p Proj
#define T_p 12
#define IS_p(v) ( (v)->t==12 )
#define AS_p(v,n) ({ \
ASSERT(IS_p(v)==1, "AS_p: type not p");\
Proj __x=EL(v,Proj,n); __x; })
/* create a single-item proj containing C value x (a Proj) */
static inline VP xp(Proj x) { VP a; a=xalloc(12,1); EL(a,Proj,0)=x; a->n=1; return a; }
/* create an empty proj */
static inline VP xp0() { VP a=xalloc(12,1); return a; }
/* return an empty proj of size sz */
static inline VP xpsz(int sz) { VP a=xalloc(12,sz); return a; }
/* append C value y (a Proj) to x */
static inline VP xpa(VP x, Proj y) { x=xrealloc(x,x->n++); EL(x,Proj,x->n-1)=y; return x; }
/* create a proj using C variable arguments - VP r = xpn(2, Proj_a, Proj_b) */
static inline VP xpn(int nargs,...) {
VP a; va_list args; int i; Proj x;
a=xalloc(T_p,nargs); a->n=nargs;
va_start(args,nargs);
for(i=0;i<nargs;i++){ x=va_arg(args,Proj); EL(a,Proj,i)=x; }
return a;
}
/* append to proj using var args */
static inline VP xpan(VP a, int nargs,...) {
va_list args; int i; Proj x;
a=xrealloc(a,a->n+nargs); va_start(args,nargs);
for(i=0;i<nargs;i++) {
x=va_arg(args,Proj);
EL(a,Proj,(a->n)+i)=x;
}
a->n+=nargs;
return a;
}
/* accessors for container type #0 or l (list) implemented as VP */
#define MAX_l 0
#define CTYPE_l VP
#define T_l 0
#define IS_l(v) ( (v)->t==0 )
#define AS_l(v,n) ({ \
ASSERT(IS_l(v)==1, "AS_l: type not l");\
VP __x=EL(v,VP,n); __x; })
/* create a list containing a VP */
static inline VP xl(VP x) { VP a; a=xalloc(0,1); EL(a,VP,0)=xref(x); a->n=1; return a; }
/* create an empty list */
static inline VP xl0() { VP a=xalloc(0,1); return a; }
/* create an empty but presized list of length sz */
static inline VP xlsz(int sz) { VP a=xalloc(0,sz); return a; }
/* append VP x to list a */
static inline VP xla(VP a, VP x) { a=xrealloc(a,a->n++); EL(a,VP,a->n-1)=xref(x); return a; }
/* create a list from var args */
static inline VP xln(int nargs,...) {
VP a; va_list args; int i; VP x;
a=xalloc(0,nargs); a->n=nargs; va_start(args,nargs);
for(i=0;i<nargs;i++){ x=va_arg(args,VP); EL(a,VP,i)=xref(x); }
return a;
}
/* append to list a with var args */
static inline VP xlan(VP a, int nargs,...) {
va_list args; int i; VP x;
a=xrealloc(a,a->n+nargs); va_start(args,nargs);
for(i=0;i<nargs;i++) {
x=va_arg(args,VP);
EL(a,VP,(a->n)+i)=xref(x);
}
a->n+=nargs;
return a;
}
/* accessors for container type #8 or d (dict) implemented as VP */
#define MAX_d 0
#define CTYPE_d VP
#define T_d 8
#define IS_d(v) ( (v)->t==8 )
#define AS_d(v,n) ({ \
ASSERT(IS_d(v)==1, "AS_d: type not d");\
VP __x=EL(v,VP,n); __x; })
/* create a dict containing a VP */
static inline VP xd(VP x) { VP a; a=xalloc(8,1); EL(a,VP,0)=xref(x); a->n=1; return a; }
/* create an empty dict */
static inline VP xd0() { VP a=xalloc(8,1); return a; }
/* create an empty but presized dict of length sz */
static inline VP xdsz(int sz) { VP a=xalloc(8,sz); return a; }
/* append VP x to dict a */
static inline VP xda(VP a, VP x) { a=xrealloc(a,a->n++); EL(a,VP,a->n-1)=xref(x); return a; }
/* create a dict from var args */
static inline VP xdn(int nargs,...) {
VP a; va_list args; int i; VP x;
a=xalloc(8,nargs); a->n=nargs; va_start(args,nargs);
for(i=0;i<nargs;i++){ x=va_arg(args,VP); EL(a,VP,i)=xref(x); }
return a;
}
/* append to dict a with var args */
static inline VP xdan(VP a, int nargs,...) {
va_list args; int i; VP x;
a=xrealloc(a,a->n+nargs); va_start(args,nargs);
for(i=0;i<nargs;i++) {
x=va_arg(args,VP);
EL(a,VP,(a->n)+i)=xref(x);
}
a->n+=nargs;
return a;
}
/* accessors for container type #9 or a (table) implemented as VP */
#define MAX_a 0
#define CTYPE_a VP
#define T_a 9
#define IS_a(v) ( (v)->t==9 )
#define AS_a(v,n) ({ \
ASSERT(IS_a(v)==1, "AS_a: type not a");\
VP __x=EL(v,VP,n); __x; })
/* create a table containing a VP */
static inline VP xa(VP x) { VP a; a=xalloc(9,1); EL(a,VP,0)=xref(x); a->n=1; return a; }
/* create an empty table */
static inline VP xa0() { VP a=xalloc(9,1); return a; }
/* create an empty but presized table of length sz */
static inline VP xasz(int sz) { VP a=xalloc(9,sz); return a; }
/* append VP x to table a */
static inline VP xaa(VP a, VP x) { a=xrealloc(a,a->n++); EL(a,VP,a->n-1)=xref(x); return a; }
/* create a table from var args */
static inline VP xan(int nargs,...) {
VP a; va_list args; int i; VP x;
a=xalloc(9,nargs); a->n=nargs; va_start(args,nargs);
for(i=0;i<nargs;i++){ x=va_arg(args,VP); EL(a,VP,i)=xref(x); }
return a;
}
/* append to table a with var args */
static inline VP xaan(VP a, int nargs,...) {
va_list args; int i; VP x;
a=xrealloc(a,a->n+nargs); va_start(args,nargs);
for(i=0;i<nargs;i++) {
x=va_arg(args,VP);
EL(a,VP,(a->n)+i)=xref(x);
}
a->n+=nargs;
return a;
}
/* accessors for container type #13 or x (ctx) implemented as VP */
#define MAX_x 0
#define CTYPE_x VP
#define T_x 13
#define IS_x(v) ( (v)->t==13 )
#define AS_x(v,n) ({ \
ASSERT(IS_x(v)==1, "AS_x: type not x");\
VP __x=EL(v,VP,n); __x; })
/* create a ctx containing a VP */
static inline VP xx(VP x) { VP a; a=xalloc(13,1); EL(a,VP,0)=xref(x); a->n=1; return a; }
/* create an empty ctx */
static inline VP xx0() { VP a=xalloc(13,1); return a; }
/* create an empty but presized ctx of length sz */
static inline VP xxsz(int sz) { VP a=xalloc(13,sz); return a; }
/* append VP x to ctx a */
static inline VP xxa(VP a, VP x) { a=xrealloc(a,a->n++); EL(a,VP,a->n-1)=xref(x); return a; }
/* create a ctx from var args */
static inline VP xxn(int nargs,...) {
VP a; va_list args; int i; VP x;
a=xalloc(13,nargs); a->n=nargs; va_start(args,nargs);
for(i=0;i<nargs;i++){ x=va_arg(args,VP); EL(a,VP,i)=xref(x); }
return a;
}
/* append to ctx a with var args */
static inline VP xxan(VP a, int nargs,...) {
va_list args; int i; VP x;
a=xrealloc(a,a->n+nargs); va_start(args,nargs);
for(i=0;i<nargs;i++) {
x=va_arg(args,VP);
EL(a,VP,(a->n)+i)=xref(x);
}
a->n+=nargs;
return a;
}
static int MAX_TYPE = 13;