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