# 2.11BSD#431 - /usr/src/ucb/PORT/pascal/src/lookup.c

##### Functions

    lookup            X
    lookup1           X
    nlfund            X

##### Variables

    disptab           X
    flagwas           X

       1: /*
       2:  * Copyright (c) 1980 Regents of the University of California.
       3:  * All rights reserved.  The Berkeley software License Agreement
       4:  * specifies the terms and conditions for redistribution.
       5:  */
       6:
       7: #ifndef lint
       8: static char sccsid[] = "@(#)lookup.c	5.1 (Berkeley) 6/5/85";
       9: #endif not lint
      10:
      11: #include "whoami.h"
      12: #include "0.h"
      13:
      14: struct nl *disptab[077+1];
      15:
      16: /*
      17:  * Lookup is called to
      18:  * find a symbol in the
      19:  * block structure symbol
      20:  * table and returns a pointer to
      21:  * its namelist entry.
      22:  */
      23: struct nl *
      24: lookup(s)
      25:     register char *s;
      26: {
      27:     register struct nl *p;
      28:     register struct udinfo;
      29:
      30:     if (s == NIL) {
      31:         nocascade();
      32:         return (NLNIL);
      33:     }
      34:     p = lookup1(s);
      35:     if (p == NLNIL) {
      36:         derror("%s is undefined", s);
      37:         return (NLNIL);
      38:     }
      39:     if (p->class == FVAR) {
      40:         p = p->chain;
      41:         bn--;
      42:     }
      43:     return (p);
      44: }
      45:
      46: #ifndef PI0
      47: int flagwas;
      48: #endif
      49: /*
      50:  * Lookup1 is an internal lookup.
      51:  * It is not an error to call lookup1
      52:  * if the symbol is not defined.  Also
      53:  * lookup1 will return FVARs while
      54:  * lookup never will, thus asgnop
      55:  * calls it when it thinks you are
      56:  * assigning to the function variable.
      57:  */
      58:
      59: struct nl *
      60: lookup1(s)
      61:     register char *s;
      62: {
      63:     register struct nl *p;
      64: #ifndef PI0
      65:     register struct nl *q;
      66: #endif
      67:     register int i;
      68:
      69:     if (s == NIL)
      70:         return (NLNIL);
      71:     bn = cbn;
      72: #ifndef PI0
      73:     /*
      74: 	 * We first check the field names
      75: 	 * of the currently active with
      76: 	 * statements (expensive since they
      77: 	 * are not hashed).
      78: 	 */
      79:     for (p = withlist; p != NLNIL; p = p->nl_next) {
      80:         q = p->type;
      81:         if (q == NLNIL)
      82:             continue;
      83:         if (reclook(q, s) != NIL)
      84:             /*
      85: 			 * Return the WITHPTR, lvalue understands.
      86: 			 */
      87:             return (p);
      88:     }
      89: #endif
      90:     /*
      91: 	 * Symbol table is a 64 way hash
      92: 	 * on the low bits of the character
      93: 	 * pointer value. (Simple, but effective)
      94: 	 */
      95:     i = (int) s & 077;
      96:     for (p = disptab[i]; p != NLNIL; p = p->nl_next)
      97:         if (p->symbol == s && p->class != FIELD && p->class != BADUSE) {
      98:             bn = (p->nl_block & 037);
      99: #ifndef PI0
     100:             flagwas = p->nl_flags;
     101:             p->nl_flags |= NUSED;
     102: #endif
     103:             return (p);
     104:         }
     105:     return (NLNIL);
     106: }
     107:
     108: #ifndef PI01
     109: nlfund(sp)
     110:     char *sp;
     111: {
     112:     register struct nl *p;
     113:     register int i;
     114:
     115:     i = (int) sp & 077;
     116:     for (p = disptab[i]; p != NLNIL; p = p->nl_next)
     117:     if (p->symbol == sp && (p->nl_block & 037) == 0)
     118:         return (nloff(p));
     119:     return (0);
     120: }
     121: #endif

#### Defined functions

lookup defined in line 23; used 21 times

- in /usr/src/ucb/PORT/pascal/src/0.h line 710
- in /usr/src/ucb/PORT/pascal/src/const.c line 159
- in /usr/src/ucb/PORT/pascal/src/cset.c line 96, 145
- in /usr/src/ucb/PORT/pascal/src/flvalue.c line 49
- in /usr/src/ucb/PORT/pascal/src/forop.c line 130
- in /usr/src/ucb/PORT/pascal/src/func.c line 45
- in /usr/src/ucb/PORT/pascal/src/lab.c line 138, 192-195(2), 241
- in /usr/src/ucb/PORT/pascal/src/lval.c line 72
- in /usr/src/ucb/PORT/pascal/src/pcfunc.c line 52
- in /usr/src/ucb/PORT/pascal/src/pclval.c line 65
- in /usr/src/ucb/PORT/pascal/src/pcproc.c line 98
- in /usr/src/ucb/PORT/pascal/src/proc.c line 92
- in /usr/src/ucb/PORT/pascal/src/rval.c line 126, 1139
- in /usr/src/ucb/PORT/pascal/src/stab.c line 601
- in /usr/src/ucb/PORT/pascal/src/stkrval.c line 75
- in /usr/src/ucb/PORT/pascal/src/type.c line 151

lookup1 defined in line 59; used 5 times

- in line 34
- in /usr/src/ucb/PORT/pascal/src/0.h line 732
- in /usr/src/ucb/PORT/pascal/src/fend.c line 226
- in /usr/src/ucb/PORT/pascal/src/fhdr.c line 62
- in /usr/src/ucb/PORT/pascal/src/stat.c line 306

nlfund defined in line 109; used 1 times

- in /usr/src/ucb/PORT/pascal/src/string.c line 125

#### Defined variables

disptab defined in line 14; used 13 times

- in line 96, 116
- in /usr/src/ucb/PORT/pascal/src/fdec.c line 180, 210
- in /usr/src/ucb/PORT/pascal/src/fend.c line 164, 320, 414
- in /usr/src/ucb/PORT/pascal/src/lookup.c line 96, 116
- in /usr/src/ucb/PORT/pascal/src/nl.c line 830, 842
- in /usr/src/ucb/PORT/pascal/src/yyid.c line 49, 83

flagwas defined in line 47; used 3 times

- in line 100
- in /usr/src/ucb/PORT/pascal/src/lval.c line 78
- in /usr/src/ucb/PORT/pascal/src/pclval.c line 74

sccsid defined in line 8; never used

Last modified: 1985-06-05 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 740 |