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