1: #include "../h/rt.h"
2: #include "../h/record.h"
3:
4: /*
5: * x.y - access field y of record x.
6: */
7:
8: field(nargs, arg2, arg1, arg0)
9: int nargs;
10: struct descrip arg2, arg1, arg0;
11: {
12: register int fnum;
13: register struct b_record *rp;
14: register struct descrip *dp;
15: extern int *ftab, *records;
16:
17: SetBound;
18:
19: DeRef(arg1)
20: /*
21: * x must be a record and y must be a field number.
22: */
23: if (QUAL(arg1) || TYPE(arg1) != T_RECORD)
24: runerr(107, &arg1);
25: if (QUAL(arg2) || TYPE(arg2) != T_INTEGER)
26: syserr("field: second operand not field number");
27:
28: /*
29: * Map the field number into a field number for the record x.
30: */
31: rp = (struct b_record *) BLKLOC(arg1);
32: fnum = ftab[INTVAL(arg2) * *records + rp->recptr->recnum - 1];
33: /*
34: * If fnum < 0, x doesn't contain the specified field.
35: */
36: if (fnum < 0)
37: runerr(207, &arg1);
38:
39: /*
40: * Return a pointer to the descriptor for the appropriate field.
41: */
42: dp = &rp->fields[fnum];
43: arg0.type = D_VAR + ((int *)dp - (int *)rp);
44: BLKLOC(arg0) = (union block *) dp;
45: ClearBound;
46: }
Defined functions
field
defined in line
8;
never used