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