/* Copyright (c) 1982 Regents of the University of California */
static char sccsid
[] = "@(#)check.c 1.3 %G%";
* Check a tree for semantic correctness.
* Check that the nodes in a tree have the correct arguments
* in order to be evaluated. Basically the error checking here
* frees the evaluation routines from worrying about anything
* except dynamic errors, e.g. subscript out of range.
if (p
->value
.arg
[0]->op
== O_SYM
) {
f
= p
->value
.arg
[0]->value
.sym
;
if (not isblock(f
) or ismodule(f
)) {
error("\"%s\" is not a procedure or function", symname(f
));
error("\"%s\" is empty", symname(f
));
* Check arguments to a trace command.
} else if (exp
->op
== O_LCON
or exp
->op
== O_QLINE
) {
error("unexpected \"at\" or \"in\"");
} else if (place
!= nil
and (place
->op
== O_QLINE
or place
->op
== O_LCON
)) {
if (exp
->op
!= O_RVAL
and exp
->op
!= O_SYM
and exp
->op
!= O_CALL
) {
error("can't trace expressions");
* Check arguments to a stop command.
if (exp
->op
!= O_RVAL
and exp
->op
!= O_SYM
) {
fprintf(stderr
, "expected variable, found ");
} else if (cond
!= nil
) {
} else if (place
->op
== O_SYM
) {
* Check to see that the given node specifies some subprogram.
* Nil is ok since that means the entire program.
fprintf(stderr
, "expected subprogram, found ");
} else if (not isblock(b
->value
.sym
) or ismodule(b
->value
.sym
)) {
error("\"%s\" is not a subprogram", symname(b
->value
.sym
));
* Check to make sure a node corresponds to a source line.
} else if (p
->op
!= O_QLINE
and p
->op
!= O_LCON
) {
error("expected source line number, found \"%t\"", p
);
* Check to make sure a node corresponds to an address.
error("missing address");
} else if (p
->op
!= O_LCON
and p
->op
!= O_QLINE
) {
fprintf(stderr
, "expected address, found \"");