static char *sccsid
= "@(#)eval2.c 35.2 5/18/81";
/* Iarray - handle array call.
* args - arguments to the array call , most likely subscripts.
* evalp - flag, if TRUE then the arguments should be evaluated when they
register lispval fun
,args
;
register lispval reg
, temp
;
register struct argent
*lbot
, *np
;
for ( ; args
!= nil
; args
= args
->d
.cdr
) /* stack subscripts */
if(evalp
) protect(eval(args
->d
.car
));
else protect(args
->d
.car
);
return(vtemp
= Lfuncal());
/* Ifcall :: call foreign function/subroutine
* Ifcall is handed a binary object which is the function to call.
* This function has already been determined to be a foreign function
* by noticing that its discipline field is a string.
* The arguments to pass have already been evaluated and stacked. We
* create on the stack a 'callg' type argument list to give to the
* function. What is passed to the foreign function depends on the
* type of argument. Certain args are passes directly, others must be
* copied since the foreign function my want to change them.
* When the foreign function returns, we may have to box the result,
* depending on the type of foreign function.
register struct argent
*mynp
;
register struct argent
*lbot
;
register struct argent
*np
;
arglist
= alloca((nargs
+ 1) * sizeof(int));
for(index
= 1; index
<= nargs
; index
++) {
switch(TYPE(ltemp
=mynp
->val
)) {
/* fixnums and flonums must be reboxed */
*(int *) arglist
[index
] = ltemp
->i
;
*(double *) arglist
[index
] = ltemp
->r
;
/* these can all be sent directly */
arglist
[index
] = (int) ltemp
;
/* these cause only part of the structure to be sent */
arglist
[index
] = (int) ltemp
->ar
.data
;
arglist
[index
] = (int) ltemp
->bcd
.entry
;
error("foreign call: illegal argument ",FALSE
);
switch(((char *)a
->bcd
.discipline
)[0]) {
case 'i': /* integer-function */
ltemp
= inewint(callg(a
->bcd
.entry
,arglist
));
case 'r': /* real-function*/
ltemp
->r
= (* ((double (*)()) callg
))(a
->bcd
.entry
,arglist
);
ltemp
= (lispval
) callg(a
->bcd
.entry
,arglist
);
case 's': /* subroutine */
callg(a
->bcd
.entry
,arglist
);
asm(" callg *8(ap),*4(ap)");