/* Copyright (c) 1982 Regents of the University of California */
static char sccsid
[] = "@(#)predicates.c 1.4 4/23/82";
* The basic tests on a symbol.
* Test if a symbol is a parameter. This is true if there
* is a cycle from s->func to s via chain pointers.
for (t
= s
->func
; t
!= NIL
; t
= t
->chain
) {
* Test if a symbol is a var parameter, i.e. has class REF.
return (BOOLEAN
) s
->class == REF
;
* Test if a symbol is a variable (actually any addressible quantity
return s
->class == VAR
|| s
->class == FVAR
|| s
->class == REF
;
* Test if a symbol is a block, e.g. function, procedure, or the
return(s
->class == FUNC
|| s
->class == PROC
|| s
->class == PROG
);
* Test if a symbol is builtin, that is, a predefined type or
return(s
->blkno
== 0 && s
->class != PROG
&& s
->class != VAR
);
* Compatible tests if two types are compatible. The issue
* is complicated a bit by ranges.
* Integers and reals are not compatible since they cannot always be mixed.
BOOLEAN
compatible(t1
, t2
)
if (t1
->type
== t2
->type
) {
if (t1
->class == RANGE
&& t2
->class == RANGE
) {
} else if ((t1
->class == SCAL
|| t1
->class == CONST
) &&
(t2
->class == SCAL
|| t2
->class == CONST
)) {
} else if (t1
->type
== t_char
&&
t1
->class == ARRAY
&& t2
->class == ARRAY
) {
* A kludge here for "nil". Should be handled better.
* Opens a pandora's box for integer/pointer compatibility.
} else if ((t1
->class == RANGE
&& t2
->class == PTR
) ||
(t2
->class == RANGE
&& t1
->class == PTR
)) {
* Predicate to test if a symbol should be printed. We don't print
* files, for example, simply because there's no good way to do it.
* The symbol must be within the given function.
BOOLEAN
should_print(s
, f
)
if (s
->func
!= f
|| (s
->class != VAR
&& s
->class != FVAR
)) {
} else if (s
->chain
!= NIL
) {
if (t
== NIL
|| t
->class == FILET
|| t
->class == SET
) {
* Test if the name of a symbol is uniquely defined or not.
t
= st_lookup(symtab
, s
->symbol
);
panic("symbol name vanished");
while (t
!= NIL
&& (s
== t
|| !streq(t
->symbol
, s
->symbol
))) {