4
#define PADDR(i) ((char *)(sSPinit->s.s_dbind->fixa.fixa_self[Mfix(i)]))
6
MakeAfun(addr,F_ARGD(min,max,flags,ARGTYPES(a,b,c,d)),0);
7
MakeAfun(addr,F_ARGD(2,3,NONE,ARGTYPES(OO,OO,OO,OO)),0);
9
object MakeAfun(addr,argd,data)
10
object data, (*addr) ();
12
{int type = (F_ARG_FLAGS_P(argd,F_requires_fun_passed) ? t_closure : t_afun);
13
object x = alloc_object(type);
14
x->sfn.sfn_name = Cnil;
15
x->sfn.sfn_self = addr;
16
x->sfn.sfn_argd = argd;
17
if (type == t_closure)
20
x->sfn.sfn_data = data;
26
fSmakefun(sym,addr,argd)
27
object sym, (*addr) ();
29
{object ans = MakeAfun(addr,argd,
30
(sSPmemory && sSPmemory->s.s_dbind &&
31
type_of(sSPmemory->s.s_dbind)==t_cfdata) ?
32
sSPmemory->s.s_dbind : 0);
33
ans->sfn.sfn_name = sym;
38
ImakeClosure(addr,argd,n,va_alist)
42
{ object x = fSmakefun(Cnil,addr,argd);
53
{ /* this will change so that we can allocate 'hunks' which will be little
54
blocks the size of an array header say with only one header word. This
55
will be more economical. Because of gc, we can't allocate relblock, it
56
might move while in the closure. */
58
if (type_of(x) != t_closure)
59
{ FEerror("Not a closure",0);}
60
if (x->cl.cl_envdim < n)
61
{BEGIN_NO_INTERRUPT; x->cl.cl_env = (object *)alloc_contblock(n);
67
{ *p++ = va_arg(ap,object);
71
DEFUN("INITFUN",object,fSinitfun,SI,3,ARG_LIMIT,NONE,OO,OO,OO,OO,
72
"Store a compiled function on SYMBOL whose body is in the VV array at \
73
INDEX, and whose argd descriptor is ARGD. If more arguments IND1, IND2,.. \
74
are supplied these are indices in the VV array for the environment of this \
76
(sym,addr_ind,argd,va_alist)
77
object sym,addr_ind,argd; va_dcl
78
{ int nargs = F_NARGS(VFUN_NARGS) -3;
80
object fun = fSmakefun(IisSymbol(sym),PADDR(addr_ind),Mfix(argd));
83
IsetClosure(fun,nargs,ap);
85
/* the things put in by IsetClosure were only the indices
86
of the closure variables not the actual variables */
87
{ fun->cl.cl_env[nargs]= (object) PADDR(fun->cl.cl_env[nargs]);}
94
DEFUN("INITMACRO",object,fSinitmacro,SI,3,ARG_LIMIT,NONE,OO,OO,OO,OO,
95
"Like INITFUN, but makes then sets the 'macro' flag on this symbol")
101
res = Iapply_ap(fSinitfun,ap);
107
DEFUN("SET-KEY-STRUCT",object,fSset_key_struct,SI,1,1,NONE,OO,OO,OO,OO,
108
"Called inside the loader. The keystruct is set up in the file with \
109
indexes rather than the actual entries. We change these indices to \
112
object key_struct_ind;
114
{ set_key_struct(PADDR(key_struct_ind),sSPmemory->s.s_dbind);
120
SI_makefun(strg,fn,argd)
124
{ object sym = make_si_ordinary(strg);
125
fSfset(sym, fSmakefun(sym,fn,argd));
129
LISP_makefun(strg,fn,argd)
133
{ object sym = make_ordinary(strg);
134
fSfset(sym, fSmakefun(sym,fn,argd));
139
MakeClosure(n,argd,data,fn,va_alist)
146
x = alloc_object(t_closure);
147
x->cl.cl_name = Cnil;
149
x->cl.cl_data = data;
150
x->cl.cl_argd = argd;
152
x->cl.cl_env = (object *)alloc_contblock(n*sizeof(object));
155
{ object *p = x->cl.cl_env;
157
{ *p++ = va_arg(ap,object);}
163
DEFUN("INVOKE",object,fSinvoke,SI,1,ARG_LIMIT,NONE,OO,OO,OO,OO,
164
"Invoke a C function whose body is at INDEX in the VV array")
168
fn = (void *) PADDR(x);