BSD 3 development
[unix-history] / usr / src / cmd / lisp / eval2.c
CommitLineData
8cd657f4
JF
1#include "global.h"
2lispval
3Iarray(fun,args)
4register lispval fun,args;
5{
6 register lispval reg, temp;
7 register struct argent *lbot, *np;
8 snpand(2);
9
10 lbot = np;
11 if(np + 3 > nplim)
12 namerr();
13 np++->val = fun->accfun;
14 np++->val = args;
15 np++->val = fun;
16 return(vtemp = Lfuncal());
17
18}
19#define FINTF 1
20#define FDOUBF 2
21#define FORTSUB 0
22
23lispval
24Ifcall(a)
25register lispval a;
26{
27 int *alloca();
28 register int *arglist;
29 register int index;
30 register struct argent *mynp;
31 register lispval ltemp;
32 register struct argent *lbot;
33 register struct argent *np;
34 int nargs = np - lbot;
35
36 arglist = alloca((nargs + 1) * sizeof(int));
37 mynp = lbot;
38 *arglist = nargs;
39 for(index = 1; index <= nargs; index++) {
40 switch(TYPE(mynp->val)) {
41 case INT:
42 arglist[index] = sp();
43 stack(0);
44 *(int *) arglist[index] = mynp->val->i;
45 break;
46 case DOUB:
47 stack(0);
48 arglist[index] = sp();
49 stack(0);
50 *(double *) arglist[index] = mynp->val->r;
51 break;
52 case ARRAY:
53 arglist[index] = (int) mynp->val->data;
54 }
55 mynp++;
56 }
57 switch(a->discipline->i) {
58 case FINTF:
59 ltemp = inewint(callg(a->entry,arglist));
60 break;
61
62 case FDOUBF:
63 ltemp = newdoub();
64 ltemp->r = (* ((double (*)()) callg))(a->entry,arglist);
65 break;
66
67 default:
68 case FORTSUB:
69 callg(a->entry,arglist);
70 ltemp = tatom;
71 }
72}
73callg(funct,arglist)
74lispval (*funct)();
75int *arglist;
76{
77 asm(" callg *8(ap),*4(ap)");
78}