accept rmothers -O flag.
[unix-history] / usr / src / usr.bin / pascal / pxp / 0.h
CommitLineData
289fd223 1/* static char *sccsid = "@(#)0.h 1.3 (Berkeley) %G%";*/
5912a8dc
PK
2/* Copyright (c) 1979 Regents of the University of California */
3/* #define DEBUG */
4#define CHAR
5#define STATIC
6/*
7 * pxp - Pascal execution profiler
8 *
9 * Bill Joy
10 * University of California, Berkeley (UCB)
11 * Version 1.1 February 1978
12 */
13
14/*
15 * Option flags
16 *
17 * The following options are recognized on the command line by pxp.
18 * Only the u, w, and z options here have effect in comments in the
19 * program; the others are command line only, and unrelated
20 * to the options with the same designations in comments.
21 *
22 * a Print all routines in a profile; normally, routines
23 * which have never been executed have their bodies suppressed.
24 *
25 * c Extract profile data from the file core, or the file
26 * named after the last argument rather than the file 'pmon.out'.
27 * Must be used with z to have an effect.
28 *
29 * d Suppress declarations
30 *
31 * f Fully parenthesize expressions.
32 *
33 * j Left justify all procedures and functions rather than
34 * indenting them.
35 *
36 * n Eject a new page in the listing as each 'include' file
37 * is incorporated into the profile.
38 *
39 * o Put output prettyprint in first argument file
40 *
41 * p Pretty print a main program without processing
42 * the include statements.
43 *
44 * t Print a table summarizing procedure and function call counts.
45 *
46 * u Card image mode; only the first 72 chars on a line count.
47 *
48 * w Suppress certain warning diagnostics.
49 *
50 * z Generate an execution profile of the program.
51 * May also be followed by a list of procedure and function
52 * names mixed, if desired, with include file names.
53 * Only these procedures and functions, and the contents
54 * of the specified include files will then be profiled.
55 *
56 * [23456789] Use the specified number of spaces for the basic
57 * indenting unit in the program.
58 *
59 * _ Underline keywords in the output.
60 */
61
62char all, core, nodecl, full, justify, pmain, stripcomm, table, underline;
63char profile, onefile;
64char *firstname, *stdoutn;
65#ifdef DEBUG
66char fulltrace, errtrace, testtrace, yyunique, typetest;
67#endif
68int unit;
69
70/*
71 * The flag nojunk means that header lines
72 * of procedures and functions are to be suppressed
73 * when the z option is off.
74 * It is the default when command line z option
75 * control is specified.
76 *
77 * The flag noinclude indicates that include statements are not
78 * to be processed since we are pretty-printing the contents
79 * of a single file.
80 *
81 * The flag bracket indicates that the source code should be
82 * bracketed with lines of the form
83 * program x(output);
84 * and
85 * begin end.
86 * so that an include will pretty print without syntax errors.
87 */
88char nojunk, noinclude, bracket;
89
90/*
91 * IMPORTANT NOTE
92 *
93 * Many of the following globals are shared by pi and pxp.
94 * For more discussion of these see the available documentation
95 * on the structure of pi.
96 */
97
98/*
99 * Each option has a stack of 17 option values, with opts giving
100 * the current, top value, and optstk the value beneath it.
101 * One refers to option `l' as, e.g., opt('l') in the text for clarity.
102 */
103char opts[26];
104int optstk[26];
105
106#define opt(c) opts[c-'a']
107\f
108/*
109 * NOTES ON THE DYNAMIC NATURE OF THE DATA STRUCTURES
110 *
111 * Pxp uses expandable tables for its string table
112 * hash table, and parse tree space. The following
113 * definitions specify the size of the increments
114 * for these items in fundamental units so that
115 * each uses approximately 1024 bytes.
116 */
117
118#define STRINC 1024 /* string space increment */
119#define TRINC 512 /* tree space increment */
120#define HASHINC 509 /* hash table size in words, each increment */
121
122/*
123 * The initial sizes of the structures.
124 * These should be large enough to profile
125 * an "average" sized program so as to minimize
126 * storage requests.
127 * On a small system or and 11/34 or 11/40
128 * these numbers can be trimmed to make the
129 * profiler smaller.
130 */
131#define ITREE 2000
132#define IHASH 509
133
134/*
135 * The following limits on hash and tree tables currently
136 * allow approximately 1200 symbols and 20k words of tree
137 * space. The fundamental limit of 64k total data space
138 * should be exceeded well before these are full.
139 */
140#define MAXHASH 4
141#define MAXTREE 30
142#define MAXDEPTH 150
143\f
144/*
145 * ERROR RELATED DEFINITIONS
146 */
147
148/*
149 * Exit statuses to pexit
150 *
151 * AOK
152 * ERRS Compilation errors inhibit obj productin
153 * NOSTART Errors before we ever got started
154 * DIED We ran out of memory or some such
155 */
156#define AOK 0
157#define ERRS 1
158#define NOSTART 2
159#define DIED 3
160
161char Recovery;
162/*
163 * The flag eflg is set whenever we have a hard error.
164 * The character in errpfx will precede the next error message.
165 */
166int eflg;
167char errpfx;
168
169#define setpfx(x) errpfx = x
170
171#define standard() setpfx('s')
172#define warning() setpfx('w')
173#define recovered() setpfx('e')
174#define quit() setpfx('Q')
289fd223 175#define continuation() setpfx(' ')
5912a8dc
PK
176\f
177/*
178 * SEMANTIC DEFINITIONS
179 */
180
181#define NIL 0
182
183/*
184 * NOCON and SAWCON are flags in the tree telling whether
185 * a constant set is part of an expression.
186 */
187#define NOCON 0
188#define SAWCON 1
189
190/*
191 * The variable cbn gives the current block number.
192 * The variable lastbn gives the block number before
193 * it last changed and is used to know that we were
194 * in a nested procedure so that we can print
195 * begin { solve }
196 * when solve has nested procedures or functions in it.
197 */
198int cbn, lastbn;
199
200/*
201 * The variable line is the current semantic
202 * line and is set in stat.c from the numbers
203 * embedded in statement type tree nodes.
204 */
205int line;
206
207/*
208 * The size of the display
209 * which defines the maximum nesting
210 * of procedures and functions allowed.
211 */
212#define DSPLYSZ 20
213\f
214/*
215 * Routines which need types
216 * other than "integer" to be
217 * assumed by the compiler.
218 */
219int *tree();
220int *hash();
221char *alloc();
222long cntof();
223long nowcnt();
224
225/*
226 * Funny structures to use
227 * pointers in wild and wooly ways
228 */
229struct {
230 char pchar;
231};
232struct {
233 int pint;
234 int pint2;
235};
236struct {
237 long plong;
238};
239struct {
240 double pdouble;
241};
242
243#define OCT 1
244#define HEX 2
245\f
246/*
247 * MAIN PROGRAM GLOBALS, MISCELLANY
248 */
249
250/*
251 * Variables forming a data base referencing
252 * the command line arguments with the "z" option.
253 */
254char **pflist;
255int pflstc;
256int pfcnt;
257
258char *filename; /* current source file name */
259char *lastname; /* last file name printed */
260long tvec; /* mod time of the source file */
261long ptvec; /* time profiled */
262char printed; /* current file has been printed */
263char hadsome; /* had some output */
264\f
265/*
266 * PROFILING AND FORMATTING DEFINITIONS
267 */
268
269/*
270 * The basic counter information recording structure.
271 * This is global only because people outside
272 * the cluster in pmon.c need to know its size.
273 */
274struct pxcnt {
275 long ntimes; /* the count this structure is all about */
276 int counter; /* a unique counter number for us */
277 int gos; /* global goto count when we hatched */
278 int printed; /* are we considered to have been printed? */
279} pfcnts[DSPLYSZ];
280
281/*
282 * The pieces we divide the output line indents into:
283 * line# PRFN label: STAT 999.---| DECL text
284 */
285#define STAT 0
286#define DECL 1
287#define PRFN 2
288
289/*
290 * Gocnt records the total number of goto's and
291 * cnts records the current counter for generating
292 * COUNT operators.
293 */
294int gocnt;
295int cnts;
296
297#include <stdio.h>
298
88b1f2d9
KM
299typedef enum {FALSE, TRUE} bool;
300
5912a8dc 301#undef putchar