1: #include "../h/rt.h"
2: #include "../h/record.h"
3:
4: /*
5: * mkrec - create a record.
6: */
7:
8: mkrec(nargs)
9: int nargs;
10: {
11: register int i;
12: register struct b_proc *bp;
13: register struct b_record *rp;
14: extern struct b_record *alcrecd();
15:
16: SetBound;
17: /*
18: * Be sure that call is from a procedure.
19: */
20: if (QUAL(ARG(0)) || TYPE(ARG(0)) != T_PROC)
21: syserr("mkrec: procedure block not on stack");
22:
23: /*
24: * Ensure space for the record to be created.
25: */
26: hneed(sizeof(struct b_record) +
27: BLKLOC(ARG(0))->proc.nfields*sizeof(struct descrip));
28:
29: /*
30: * Get a pointer to the record constructor procedure and allocate
31: * a record with the appropriate number of fields.
32: */
33: bp = (struct b_proc *) BLKLOC(ARG(0));
34: rp = alcrecd(bp->nfields, bp);
35:
36: /*
37: * Set all fields in the new record to null value.
38: */
39: for (i = bp->nfields; i > nargs; i--)
40: rp->fields[i-1] = nulldesc;
41:
42: /*
43: * Assign each argument value to a record element and dereference it.
44: */
45: for ( ; i > 0; i--) {
46: rp->fields[i-1] = ARG(i);
47: DeRef(rp->fields[i-1])
48: }
49:
50: ARGTYPE(0) = D_RECORD;
51: ARGVAL(0) = (int) rp;
52: ClearBound;
53: }
Defined functions
mkrec
defined in line
8;
never used