xref: /original-bsd/usr.bin/pascal/pxp/var.c (revision e811aa08)
1 /*-
2  * Copyright (c) 1980, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)var.c	8.1 (Berkeley) 06/06/93";
10 #endif /* not lint */
11 
12 /*
13  * pxp - Pascal execution profiler
14  *
15  * Bill Joy UCB
16  * Version 1.2 January 1979
17  */
18 
19 #include "0.h"
20 #include "tree.h"
21 
22 STATIC	int varcnt = -1;
23 /*
24  * Var declaration part
25  */
26 varbeg(l, vline)
27 	int l, vline;
28 {
29 
30 	line = l;
31 	if (nodecl)
32 		printoff();
33 	puthedr();
34 	putcm();
35 	ppnl();
36 	indent();
37 	ppkw("var");
38 	ppgoin(DECL);
39 	varcnt = 0;
40 	setline(vline);
41 }
42 
43 var(vline, vidl, vtype)
44 	int vline;
45 	register int *vidl;
46 	int *vtype;
47 {
48 
49 	if (varcnt)
50 		putcm();
51 	setline(vline);
52 	ppitem();
53 	if (vidl != NIL)
54 		for (;;) {
55 			ppid(vidl[1]);
56 			vidl = vidl[2];
57 			if (vidl == NIL)
58 				break;
59 			ppsep(", ");
60 		}
61 	else
62 		ppid("{identifier list}");
63 	ppsep(":");
64 	gtype(vtype);
65 	ppsep(";");
66 	setinfo(vline);
67 	putcml();
68 	varcnt++;
69 }
70 
71 varend()
72 {
73 
74 	if (varcnt == -1)
75 		return;
76 	if (varcnt == 0)
77 		ppid("{variable decls}");
78 	ppgoout(DECL);
79 	varcnt = -1;
80 }
81