X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/0f4556f12c8f75078501c9d1338ae7648a97f975..95f51977ddc18faa2e212f30c00a39540b39f325:/usr/src/ucb/pascal/src/clas.c diff --git a/usr/src/ucb/pascal/src/clas.c b/usr/src/ucb/pascal/src/clas.c index 17aba5c750..9a0e9379af 100644 --- a/usr/src/ucb/pascal/src/clas.c +++ b/usr/src/ucb/pascal/src/clas.c @@ -1,10 +1,16 @@ -/* Copyright (c) 1979 Regents of the University of California */ - -static char sccsid[] = "@(#)clas.c 1.6 11/11/82"; +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ +#ifndef lint +static char sccsid[] = "@(#)clas.c 5.2 (Berkeley) 6/5/85"; +#endif not lint #include "whoami.h" #include "0.h" #include "tree.h" +#include "tree_ty.h" /* * This is the array of class @@ -48,7 +54,7 @@ classify(p1) p = p1; swit: - if (p == NIL) { + if (p == NLNIL) { nocascade(); return (NIL); } @@ -68,6 +74,7 @@ swit: return (TSTR); case SET: return (TSET); + case CRANGE: case RANGE: p = p->type; goto swit; @@ -82,7 +89,10 @@ swit: case SCAL: return (TSCAL); default: - panic("clas"); + { + panic("clas"); + return(NIL); + } } } @@ -104,19 +114,20 @@ text(p) * its argument if its argument * is a SCALar else NIL. */ +struct nl * scalar(p1) struct nl *p1; { register struct nl *p; p = p1; - if (p == NIL) - return (NIL); - if (p->class == RANGE) + if (p == NLNIL) + return (NLNIL); + if (p->class == RANGE || p->class == CRANGE) p = p->type; - if (p == NIL) - return (NIL); - return (p->class == SCAL ? p : NIL); + if (p == NLNIL) + return (NLNIL); + return (p->class == SCAL ? p : NLNIL); } /* @@ -141,8 +152,9 @@ isa(p, s) * map ranges down to * the base type */ - if (p->class == RANGE) + if (p->class == RANGE) { p = p->type; + } /* * the following character/class * associations are made: @@ -161,6 +173,19 @@ isa(p, s) case SCAL: i = 0; break; + case CRANGE: + /* + * find the base type of a conformant array range + */ + switch (classify(p->type)) { + case TBOOL: i = 1; break; + case TCHAR: i = 2; break; + case TINT: i = 3; break; + case TSCAL: i = 0; break; + default: + panic( "isa" ); + } + break; default: i = p - nl; } @@ -178,6 +203,8 @@ isa(p, s) * Isnta is !isa */ isnta(p, s) + struct nl *p; + char *s; { return (!isa(p, s)); @@ -186,18 +213,22 @@ isnta(p, s) /* * "shorthand" */ +char * nameof(p) +struct nl *p; { return (clnames[classify(p)]); } #ifndef PI0 -nowexp(r) - int *r; +/* find out for sure what kind of node this is being passed + possibly several different kinds of node are passed to it */ +int nowexp(r) + struct tnode *r; { - if (r[0] == T_WEXP) { - if (r[2] == NIL) + if (r->tag == T_WEXP) { + if (r->var_node.cptr == NIL) error("Oct/hex allowed only on writeln/write calls"); else error("Width expressions allowed only in writeln/write calls"); @@ -214,8 +245,8 @@ nowexp(r) * positives are parameters * negative evens are locals */ -whereis( level , offset , other_flags ) - int level; +/*ARGSUSED*/ +whereis( offset , other_flags ) int offset; char other_flags; { @@ -225,6 +256,8 @@ whereis( level , offset , other_flags ) # endif OBJ # ifdef PC switch ( other_flags & ( NGLOBAL | NPARAM | NLOCAL | NNLOCAL) ) { + default: + panic( "whereis" ); case NGLOBAL: return GLOBALVAR; case NPARAM: @@ -233,8 +266,6 @@ whereis( level , offset , other_flags ) return NAMEDLOCALVAR; case NLOCAL: return LOCALVAR; - default: - panic( "whereis" ); } # endif PC }