/* Copyright (c) 1979 Regents of the University of California */
static char sccsid
[] = "@(#)func.c 1.8 %G%";
* Funccod generates code for
* built in function calls and calls
* call to generate calls to user
* defined functions and procedures.
* Verify that the given name
* is defined and the name of
if (p
->class != FUNC
&& p
->class != FFUNC
) {
error("%s is not a function", p
->symbol
);
* Call handles user defined
* procedures and functions
return (call(p
, argv
, FUNC
, bn
));
for (al
= argv
; al
!= NIL
; al
= al
[2])
* Built-in functions have
* their interpreter opcode
op
= p
->value
[0] &~ NSTAND
;
if (opt('s') && (p
->value
[0] & NSTAND
)) {
error("%s is a nonstandard function", p
->symbol
);
* Parameterless functions
error("%s takes no arguments", p
->symbol
);
error("%s takes either zero or one argument", p
->symbol
);
* All other functions take
error("%s takes exactly one argument", p
->symbol
);
if (op
== O_EOF
|| op
== O_EOLN
)
p1
= stklval((int *) argv
[1], NLNIL
, LREQ
);
p1
= stkrval((int *) argv
[1], NLNIL
, RREQ
);
convert( nl
+T4INT
, nl
+TDOUBLE
);
else if (isnta(p1
, "d")) {
error("%s's argument must be integer or real, not %s", p
->symbol
, nameof(p1
));
error("seed's argument must be an integer, not %s", nameof(p1
));
error("%s's argument must be a real, not %s", p
->symbol
, nameof(p1
));
put(1, op
+ O_ABS8
-O_ABS2
);
put(1, op
+ (width(p1
) >> 2));
error("%s's argument must be an integer or real, not %s", p
->symbol
, nameof(p1
));
if (isa(p1
, "bcis") || classify(p1
) == TPTR
) {
error("ord's argument must be of scalar type or a pointer, not %s", nameof(p1
));
error("%s is forbidden for reals", p
->symbol
);
if ( isnta( p1
, "bcsi" ) ) {
error("%s's argument must be of scalar type, not %s", p
->symbol
, nameof(p1
));
tempnlp
= p1
-> class == TYPE
? p1
-> type
: p1
;
op
+= O_PRED24
- O_PRED2
;
put(3, op
, (int)tempnlp
->range
[0],
put(3, op
, tempnlp
->range
[0],
put(3, op
, (int)tempnlp
->range
[0],
error("odd's argument must be an integer, not %s", nameof(p1
));
put(1, op
+ (width(p1
) >> 2));
error("chr's argument must be an integer, not %s", nameof(p1
));
put(1, op
+ (width(p1
) >> 2));
error("Argument to card must be a set, not %s", nameof(p1
));
put(2, O_CARD
, width(p1
));
error("Argument to eoln must be a text file, not %s", nameof(p1
));
if (p1
->class != FILET
) {
error("Argument to eof must be file, not %s", nameof(p1
));
error("%s is an unimplemented 6000-3.4 extension", p
->symbol
);