8dd2b5e77a692cb4f7e9262c216242d5294b6d38
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
static char sccsid
[] = "@(#)clas.c 5.2 (Berkeley) %G%";
* This is the array of class
* names for the classes returned
* by classify. The order of the
* classes is the same as the base
* of the namelist, with special
* negative index entries for structures,
* scalars, pointers, sets and strings
char **clnames
= &clnxxxx
[-(TFIRST
)];
* Classify takes a pointer
* to a type and returns one
* of several interesting group
* classifications for easy use.
if ( p
== &nl
[ TSET
] ) {
if (p
->type
== nl
+T1CHAR
)
return (p
!= NIL
&& p
->class == FILET
&& p
->type
== nl
+T1CHAR
);
* Scalar returns a pointer to
* the the base scalar type of
* its argument if its argument
if (p
->class == RANGE
|| p
->class == CRANGE
)
return (p
->class == SCAL
? p
: NLNIL
);
* classes wanted are specified
* by the characters in s.
* (Note that s would more efficiently,
* if less clearly, be given by a mask.)
* the following character/class
* find the base type of a conformant array range
switch (classify(p
->type
)) {
case TBOOL
: i
= 1; break;
case TCHAR
: i
= 2; break;
case TSCAL
: i
= 0; break;
if (i
>= 0 && i
<= TDOUBLE
+1) {
return (clnames
[classify(p
)]);
/* find out for sure what kind of node this is being passed
possibly several different kinds of node are passed to it */
if (r
->var_node
.cptr
== NIL
)
error("Oct/hex allowed only on writeln/write calls");
error("Width expressions allowed only in writeln/write calls");
* is a variable a local, a formal parameter, or a global?
* all this from just the offset:
* globals are at levels 0 or 1
* positives are parameters
* negative evens are locals
whereis( offset
, other_flags
)
return ( offset
>= 0 ? PARAMVAR
: LOCALVAR
);
switch ( other_flags
& ( NGLOBAL
| NPARAM
| NLOCAL
| NNLOCAL
) ) {