~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to h/funlink.h

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
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.
 
8
   enum F_arg_flags
 
9
 
 
10
 
 
11
*/
 
12
    
 
13
/*
 
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
 
21
*/
 
22
 
 
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))
 
31
 
 
32
#define BITS_PER_CHAR 8
 
33
#define MAX_ARGS 63
 
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)
 
38
 
 
39
/* make an argd slot
 
40
   where flags and argtypes are already set up as fields
 
41
 */                    
 
42
#define F_ARGD(min,max,flags, argtypes) \
 
43
      (min | ((flags | (max-min ? (1<<F_requires_nargs) : 0) \
 
44
               << F_NARG_WIDTH)) \
 
45
       | (max << (F_NARG_WIDTH+F_end)) \
 
46
       | (argtypes<< (2* F_NARG_WIDTH + F_end )))
 
47
 
 
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.*/
 
53
#define NONE 0    
 
54
 
 
55
/* we dont want to define all these two letter macros... all the time */
 
56
 
 
57
#ifndef NO_DEFUN
 
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)
 
67
#endif
 
68
 
 
69
#define ARGTYPES(a,b,c,d) \
 
70
  (a | (b << (2* F_TYPE_WIDTH)) | (c << (4* F_TYPE_WIDTH)) | (d << (6*F_TYPE_WIDTH)))
 
71
 
 
72
 
 
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
 
78
 
 
79
#define FUNCALL(n,form) (VFUN_NARGS=n,form)
 
80