2
/* the link_desc, is an INT which carries the call information
3
for all uses of that link. It tells whether fcall.nargs is
4
set before the call, whether the VFUN_FUN is set, (to pass in
5
a closure function) or if the number of values is set after the
6
call. It gives the min and max number of args and the result
7
type expected. It describes the arg types.
14
A link arg descriptor:
15
a6a5a4a3a2a1a0rrmmmmmmfffllllll
16
l = least number of args passed
17
m = max number of args passed
18
f = flags bits set according to F_arg_flags, There are F_end flag bits.
19
r = result type in F_arg_types
20
ai = i'th arg type in F_arg_types
23
/* We allow 2 bits for encoding arg types and return type */
24
#define F_TYPE_WIDTH 2
25
#define F_MIN_ARGS(x) (x & MASK_RANGE(0,F_NARG_WIDTH))
26
#define F_NARGS(x) F_MIN_ARGS(x)
27
#define F_ARG_FLAGS_P(x,flag) (x & (1 << (F_NARG_WIDTH + flag)))
28
#define F_ARG_FLAGS(x) ((x >> F_NARG_WIDTH) & MASK_RANGE(0,F_end))
29
#define F_MAX_ARGS(x) ((x >> (F_NARG_WIDTH + F_end )) \
30
& MASK_RANGE(0,F_NARG_WIDTH))
32
#define BITS_PER_CHAR 8
34
#define F_TYPES(x) (((x) >> F_START_TYPES_POS ) \
35
& MASK_RANGE(0, sizeof(int)*BITS_PER_CHAR - F_START_TYPES_POS))
36
#define F_RESULT_TYPE(x) (F_TYPES(x) & MASK_RANGE(0,F_TYPE_WIDTH))
37
#define F_ARG_LIMIT ((1<< F_NARG_WIDTH) -1)
40
where flags and argtypes are already set up as fields
42
#define F_ARGD(min,max,flags, argtypes) \
43
(min | ((flags | (max-min ? (1<<F_requires_nargs) : 0) \
45
| (max << (F_NARG_WIDTH+F_end)) \
46
| (argtypes<< (2* F_NARG_WIDTH + F_end )))
48
#define ONE_VAL (1 << F_caller_sets_one_val)
49
#define CLOS (1 << F_requires_fun_passed)
50
#define VARARG (1 << F_requires_nargs)
51
/* the following may be used as an argument to DEFUN even in the case
52
of varargs, since the F_ARGD macro detects minargs<maxargs and sets this.*/
55
/* we dont want to define all these two letter macros... all the time */
58
#define OO (F_object | F_object << F_TYPE_WIDTH)
59
#define OI (F_object | F_int << F_TYPE_WIDTH)
60
#define OD (F_object | F_double_ptr << F_TYPE_WIDTH)
61
#define IO (F_int | F_object << F_TYPE_WIDTH)
62
#define II (F_int | F_int << F_TYPE_WIDTH)
63
#define ID (F_int | F_double_ptr << F_TYPE_WIDTH)
64
#define DO (F_double_ptr | F_object << F_TYPE_WIDTH)
65
#define DI (F_double_ptr | F_int << F_TYPE_WIDTH)
66
#define DD (F_double_ptr | F_double_ptr << F_TYPE_WIDTH)
69
#define ARGTYPES(a,b,c,d) \
70
(a | (b << (2* F_TYPE_WIDTH)) | (c << (4* F_TYPE_WIDTH)) | (d << (6*F_TYPE_WIDTH)))
73
#define PUSH_FIRST_VAL(x) int nvals = 1 ; object result = (x)
74
#define PUSH_VAL(x) if (nvals>=sizeof(fcall.values)/sizeof(*fcall.values) \
75
FEerror("Too many function call values"); \
76
else fcall.values[nvals++] = (x)
77
#define RETURN_VALS fcall.nvalues= nvals; return result;} 0
79
#define FUNCALL(n,form) (VFUN_NARGS=n,form)