* Copyright (c) 1980 The Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)clas.c 5.3 (Berkeley) 4/16/91";
* 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
) ) {