/* Copyright (c) 1979 Regents of the University of California */
* pi - Pascal interpreter code translator
* Charles Haley, Bill Joy UCB
* Version 1.2 November 1978
* Call generates code for calls to
* user defined procedures and functions
* and is called by proc and funccod.
* P is the result of the lookup
* of the procedure/function symbol,
* and porf is PROC or FUNC.
* Psbn is the block number of p.
call(p
, argv
, porf
, psbn
)
register struct nl
*p1
, *q
;
* for the function return type
put2(O_PUSH
, even(-width(p
->type
)));
* Loop and process each of
* arguments to the proc/func.
for (p1
= p
->chain
; p1
!= NIL
; p1
= p1
->chain
) {
error("Not enough arguments to %s", p
->symbol
);
if (r
!= NIL
&& r
[0] != T_VAR
) {
error("Expression given (variable required) for var parameter %s of %s", p1
->symbol
, p
->symbol
);
q
= lvalue( (int *) argv
[1], MOD
);
error("Parameter type not identical to type of var parameter %s of %s", p1
->symbol
, p
->symbol
);
q
= rvalue(argv
[1], p1
->type
);
if (incompat(q
, p1
->type
, argv
[1])) {
cerror("Expression type clashed with type of value parameter %s of %s", p1
->symbol
, p
->symbol
);
if (isa(p1
->type
, "bcsi"))
error("Too many arguments to %s", p
->symbol
);
put2(O_CALL
| psbn
<< 9, p
->entloc
);
put2(O_POP
, p
->value
[NL_OFFS
]-DPOFF2
);
for (; al
!= NIL
; al
= al
[2])
rvalue( (int *) al
[1], NLNIL
);