# 2.11BSD#431 - /usr/src/ucb/PORT/pascal/pdx/sym/print.c

##### Functions

    printcall         X
    printentry        X
    printexit         X
    printouter        X
    printparams       X
    printrtn          X
    printv            X
    printwhich        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[] = "@(#)print.c	5.1 (Berkeley) 6/6/85";
       9: #endif not lint
      10: /*
      11:  * Routines to print out symbols.
      12:  */
      13:
      14: #include "defs.h"
      15: #include "sym.h"
      16: #include "process.h"
      17: #include "tree.h"
      18: #include "runtime.h"
      19: #include "classes.h"
      20: #include "sym.rep"
      21: #include "process/process.rep"
      22:
      23: /*
      24:  * Note the entry of the given block, unless it's the main program.
      25:  */
      26:
      27: printentry(s)
      28: SYM *s;
      29: {
      30:     if (s != program) {
      31:         printf("\nentering %s %s\n", classname(s), s->symbol);
      32:     }
      33: }
      34:
      35: /*
      36:  * Note the exit of the given block
      37:  */
      38:
      39: printexit(s)
      40: SYM *s;
      41: {
      42:     if (s != program) {
      43:         printf("leaving %s %s\n\n", classname(s), s->symbol);
      44:     }
      45: }
      46:
      47: /*
      48:  * Note the call of s from t.
      49:  */
      50:
      51: printcall(s, t)
      52: SYM *s, *t;
      53: {
      54:     printf("calling %s", s->symbol);
      55:     printparams(s, NIL);
      56:     printf(" from %s %s\n", classname(t), t->symbol);
      57: }
      58:
      59: /*
      60:  * Note the return from s.  If s is a function, print the value
      61:  * it is returning.  This is somewhat painful, since the function
      62:  * has actually just returned.
      63:  */
      64:
      65: printrtn(s)
      66: SYM *s;
      67: {
      68:     register SYM *t;
      69:     register int len;
      70:
      71:     printf("returning ");
      72:     if (s->class == FUNC) {
      73:         len = size(s->type);
      74:         dread(sp, process->sp, len);
      75:         sp += len;
      76:         printval(s->type);
      77:         putchar(' ');
      78:     }
      79:     printf("from %s\n", s->symbol);
      80: }
      81:
      82: /*
      83:  * Print the values of the parameters of the given procedure or function.
      84:  * The frame distinguishes recursive instances of a procedure.
      85:  */
      86:
      87: printparams(f, frame)
      88: SYM *f;
      89: FRAME *frame;
      90: {
      91:     SYM *param;
      92:
      93:     for (param = f->chain; param != NIL; param = param->chain) {
      94:         if (param == f->chain) {
      95:             printf("(");
      96:         }
      97:         printv(param, frame);
      98:         if (param->chain != NIL) {
      99:             printf(", ");
     100:         } else {
     101:             printf(")");
     102:         }
     103:     }
     104: }
     105:
     106: /*
     107:  * Print the name and value of a variable.
     108:  */
     109:
     110: printv(s, frame)
     111: SYM *s;
     112: FRAME *frame;
     113: {
     114:     ADDRESS addr;
     115:     int len;
     116:
     117:     if (s->class == REF) {
     118:         dread(&addr, address(s, frame), sizeof(ADDRESS));
     119:         len = size(s->type);
     120:     } else {
     121:         addr = address(s, frame);
     122:         len = size(s);
     123:     }
     124:     printf("%s = ", s->symbol);
     125:     if (!rpush(addr, len)) {
     126:         printf("*** expression too large ***");
     127:     } else {
     128:         if (s->class == REF || s->class == VAR) {
     129:             printval(s->type);
     130:         } else {
     131:             printval(s);
     132:         }
     133:     }
     134: }
     135:
     136: /*
     137:  * Print the fully specified variable that is described by the given identifer.
     138:  */
     139:
     140: printwhich(s)
     141: SYM *s;
     142: {
     143:     printouter(s->func);
     144:     printf("%s", s->symbol);
     145: }
     146:
     147: LOCAL printouter(s)
     148: SYM *s;
     149: {
     150:     if (s->func != NIL) {
     151:         printouter(s->func);
     152:     }
     153:     printf("%s.", s->symbol);
     154: }

#### Defined functions

printcall defined in line 51; never used
printentry defined in line 27; never used
printexit defined in line 39; never used
printouter defined in line 147; used 2 times

- in line 143, 151

printparams defined in line 87; used 1 times

- in line 55

printrtn defined in line 65; never used
printv defined in line 110; used 1 times

- in line 97

printwhich defined in line 140; never used

#### Defined variables

sccsid defined in line 8; never used

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