1: /* @(#)c0.h 2.4 SCCS id keyword */
2: #
3: /*
4: * C compiler-- first pass header
5: */
6:
7: #include <stdio.h>
8: #include <whoami.h>
9:
10: /*
11: * parameters
12: */
13:
14: #define LTYPE long /* change to int if no long consts */
15: #define MAXINT 077777 /* Largest positive short integer */
16: #define MAXUINT 0177777 /* largest unsigned integer */
17: #define NCPS 8 /* # chars per symbol */
18: #ifdef FORTY
19: #define HSHSIZ 600 /* Smaller but be sure vi compiles */
20: #else
21: #define HSHSIZ 800 /* # entries in hash table for names */
22: #endif FORTY
23: #define CMSIZ 40 /* size of expression stack */
24: #define SSIZE 20 /* size of other expression stack */
25: #define SWSIZ 230 /* size of switch table */
26: #define NMEMS 128 /* Number of members in a structure */
27: #define NBPW 16 /* bits per word, object machine */
28: #define NBPC 8 /* bits per character, object machine */
29: #define NCPW 2 /* chars per word, object machine */
30: #define LNCPW 2 /* chars per word, compiler's machine */
31: int STAUTO; /* offset of first auto variable */
32: #define STARG 4 /* offset of first argument */
33:
34:
35: /*
36: * # bytes in primitive types
37: */
38: #define SZCHAR 1
39: #define SZINT 2
40: #define SZPTR 2
41: #define SZFLOAT 4
42: #define SZLONG 4
43: #define SZDOUB 8
44:
45: /*
46: * format of a structure description
47: */
48: struct str {
49: int ssize; /* structure size */
50: struct hshtab **memlist; /* member list */
51: };
52:
53: /*
54: * For fields, strp points here instead.
55: */
56: struct field {
57: int flen; /* field width in bits */
58: int bitoffs; /* shift count */
59: };
60:
61: /*
62: * Structure of tree nodes for operators
63: */
64: struct tnode {
65: int op; /* operator */
66: int type; /* data type */
67: int *subsp; /* subscript list (for arrays) */
68: struct str *strp; /* structure description for structs */
69: struct tnode *tr1; /* left operand */
70: struct tnode *tr2; /* right operand */
71: };
72:
73: /*
74: * Tree node for constants
75: */
76: struct cnode {
77: int op;
78: int type;
79: int *subsp;
80: struct str *strp;
81: int value;
82: };
83:
84: /*
85: * Tree node for long constants
86: */
87: struct lnode {
88: int op;
89: int type;
90: int *subsp;
91: struct str *strp;
92: LTYPE lvalue;
93: };
94:
95: /*
96: * tree node for floating
97: * constants
98: */
99: struct fnode {
100: int op;
101: int type;
102: int *subsp;
103: struct str *strp;
104: char *cstr;
105: };
106:
107: /*
108: * Structure of namelist
109: */
110: /*
111: * Pushed-down entry for block structure
112: */
113: struct phshtab {
114: char hclass;
115: char hflag;
116: int htype;
117: int *hsubsp;
118: struct str *hstrp;
119: int hoffset;
120: struct phshtab *hpdown;
121: char hblklev;
122: };
123:
124: /*
125: * Top-level namelist
126: */
127: struct hshtab {
128: char hclass; /* storage class */
129: char hflag; /* various flags */
130: int htype; /* type */
131: int *hsubsp; /* subscript list */
132: struct str *hstrp; /* structure description */
133: int hoffset; /* post-allocation location */
134: struct phshtab *hpdown; /* Pushed-down name in outer block */
135: char hblklev; /* Block level of definition */
136: char name[NCPS]; /* ASCII name */
137: };
138:
139: /*
140: * Place used to keep dimensions
141: * during declarations
142: */
143: struct tdim {
144: int rank;
145: int dimens[5];
146: };
147:
148: /*
149: * Table for recording switches.
150: */
151: struct swtab {
152: int swlab;
153: int swval;
154: };
155:
156: char cvtab[4][4];
157: char filename[64];
158: int opdope[];
159: char ctab[];
160: char symbuf[NCPS+2];
161: int hshused;
162: struct hshtab hshtab[HSHSIZ];
163: struct tnode **cp;
164: int isn;
165: struct swtab swtab[SWSIZ];
166: struct swtab *swp;
167: int contlab;
168: int brklab;
169: int retlab;
170: int deflab;
171: unsigned autolen; /* make these int if necessary */
172: unsigned maxauto; /* ... will only cause trouble rarely */
173: int peeksym;
174: int peekc;
175: int eof;
176: int line;
177: char *funcbase;
178: char *curbase;
179: char *coremax;
180: char *maxdecl;
181: struct hshtab *defsym;
182: struct hshtab *funcsym;
183: int proflg;
184: struct hshtab *csym;
185: int cval;
186: LTYPE lcval;
187: int nchstr;
188: int nerror;
189: struct hshtab **paraml;
190: struct hshtab **parame;
191: int strflg;
192: int mosflg;
193: int initflg;
194: int inhdr;
195: char sbuf[BUFSIZ];
196: FILE *sbufp;
197: int regvar;
198: int bitoffs;
199: struct tnode funcblk;
200: char cvntab[];
201: char numbuf[64];
202: struct hshtab **memlist;
203: int nmems;
204: struct hshtab structhole;
205: int blklev;
206: int mossym;
207:
208: /*
209: operators
210: */
211: #define EOFC 0
212: #define NULLOP 218
213: #define SEMI 1
214: #define LBRACE 2
215: #define RBRACE 3
216: #define LBRACK 4
217: #define RBRACK 5
218: #define LPARN 6
219: #define RPARN 7
220: #define COLON 8
221: #define COMMA 9
222: #define FSEL 10
223: #define CAST 11
224: #define ETYPE 12
225:
226: #define KEYW 19
227: #define NAME 20
228: #define CON 21
229: #define STRING 22
230: #define FCON 23
231: #define SFCON 24
232: #define LCON 25
233: #define SLCON 26
234:
235: #define SIZEOF 91
236: #define INCBEF 30
237: #define DECBEF 31
238: #define INCAFT 32
239: #define DECAFT 33
240: #define EXCLA 34
241: #define AMPER 35
242: #define STAR 36
243: #define NEG 37
244: #define COMPL 38
245:
246: #define DOT 39
247: #define PLUS 40
248: #define MINUS 41
249: #define TIMES 42
250: #define DIVIDE 43
251: #define MOD 44
252: #define RSHIFT 45
253: #define LSHIFT 46
254: #define AND 47
255: #define OR 48
256: #define EXOR 49
257: #define ARROW 50
258: #define ITOF 51
259: #define FTOI 52
260: #define LOGAND 53
261: #define LOGOR 54
262: #define FTOL 56
263: #define LTOF 57
264: #define ITOL 58
265: #define LTOI 59
266: #define ITOP 13
267: #define PTOI 14
268: #define LTOP 15
269:
270: #define EQUAL 60
271: #define NEQUAL 61
272: #define LESSEQ 62
273: #define LESS 63
274: #define GREATEQ 64
275: #define GREAT 65
276: #define LESSEQP 66
277: #define LESSP 67
278: #define GREATQP 68
279: #define GREATP 69
280:
281: #define ASPLUS 70
282: #define ASMINUS 71
283: #define ASTIMES 72
284: #define ASDIV 73
285: #define ASMOD 74
286: #define ASRSH 75
287: #define ASLSH 76
288: #define ASSAND 77
289: #define ASOR 78
290: #define ASXOR 79
291: #define ASSIGN 80
292:
293: #define QUEST 90
294: #define MAX 93
295: #define MAXP 94
296: #define MIN 95
297: #define MINP 96
298: #define SEQNC 97
299: #define CALL 100
300: #define MCALL 101
301: #define JUMP 102
302: #define CBRANCH 103
303: #define INIT 104
304: #define SETREG 105
305: #define RFORCE 110
306: #define BRANCH 111
307: #define LABEL 112
308: #define NLABEL 113
309: #define RLABEL 114
310: #define STRASG 115
311: #define ITOC 109
312: #define SEOF 200 /* stack EOF marker in expr compilation */
313:
314: /*
315: types
316: */
317: #define INT 0
318: #define CHAR 1
319: #define FLOAT 2
320: #define DOUBLE 3
321: #define STRUCT 4
322: #define LONG 6
323: #define UNSIGN 7
324: #define UNION 8 /* adjusted later to struct */
325:
326: #define ALIGN 01
327: #define TYPE 07
328: #define BIGTYPE 060000
329: #define TYLEN 2
330: #define XTYPE (03<<3)
331: #define PTR 010
332: #define FUNC 020
333: #define ARRAY 030
334:
335: /*
336: storage classes
337: */
338: #define KEYWC 1
339: #define DEFXTRN 20
340: #define TYPEDEF 9
341: #define MOS 10
342: #define AUTO 11
343: #define EXTERN 12
344: #define STATIC 13
345: #define REG 14
346: #define STRTAG 15
347: #define ARG 16
348: #define ARG1 17
349: #define AREG 18
350: #define MOU 21
351: #define ENUMTAG 22
352: #define ENUMCON 24
353:
354: /*
355: keywords
356: */
357: #define GOTO 20
358: #define RETURN 21
359: #define IF 22
360: #define WHILE 23
361: #define ELSE 24
362: #define SWITCH 25
363: #define CASE 26
364: #define BREAK 27
365: #define CONTIN 28
366: #define DO 29
367: #define DEFAULT 30
368: #define FOR 31
369: #define ENUM 32
370:
371: /*
372: characters
373: */
374: #define BSLASH 117
375: #define SHARP 118
376: #define INSERT 119
377: #define PERIOD 120
378: #define SQUOTE 121
379: #define DQUOTE 122
380: #define LETTER 123
381: #define DIGIT 124
382: #define NEWLN 125
383: #define SPACE 126
384: #define UNKN 127
385:
386: /*
387: * Special operators in intermediate code
388: */
389: #define BDATA 200
390: #define WDATA 201
391: #define PROG 202
392: #define DATA 203
393: #define BSS 204
394: #define CSPACE 205
395: #define SSPACE 206
396: #define SYMDEF 207
397: #define SAVE 208
398: #define RETRN 209
399: #define EVEN 210
400: #define PROFIL 212
401: #define SWIT 213
402: #define EXPR 214
403: #define SNAME 215
404: #define RNAME 216
405: #define ANAME 217
406: #define SETSTK 219
407: #define SINIT 220
408:
409: /*
410: Flag bits
411: */
412:
413: #define BINARY 01
414: #define LVALUE 02
415: #define RELAT 04
416: #define ASSGOP 010
417: #define LWORD 020
418: #define RWORD 040
419: #define COMMUTE 0100
420: #define RASSOC 0200
421: #define LEAF 0400
422:
423: /*
424: * Conversion codes
425: */
426: #define ITF 1
427: #define ITL 2
428: #define LTF 3
429: #define ITP 4
430: #define PTI 5
431: #define FTI 6
432: #define LTI 7
433: #define FTL 8
434: #define LTP 9
435: #define ITC 10
436: #define XX 15
437:
438: /*
439: * symbol table flags
440: */
441:
442: #define FMOS 01
443: #define FKEYW 04
444: #define FFIELD 020
445: #define FINIT 040
446: #define FLABL 0100
447:
448: /*
449: * functions
450: */
451: char *sbrk();
452: struct tnode *tree();
453: char *copnum();
454: struct tnode *convert();
455: struct tnode *chkfun();
456: struct tnode *disarray();
457: struct tnode *block();
458: struct cnode *cblock();
459: struct fnode *fblock();
460: char *gblock();
461: struct tnode *pexpr();
462: struct str *strdec();
463: struct hshtab *xprtype();
464: struct tnode *nblock();
Defined variables
cp
defined in line
163; used 51 times
- in /usr/src/cmd/c/c00.c line
633,
646,
663-667(2),
675-679(2),
688-691(2),
705,
822,
836,
844,
880,
889
- in /usr/src/cmd/c/c01.c line
35-38(2),
45,
69,
86,
96,
102-107(2),
121-123(2),
134,
142-145(3),
160,
238-247(4),
332-335(2),
518,
626
- in /usr/src/cmd/c/c02.c line
203-207(3),
213,
667
- in /usr/src/cmd/c/c04.c line
330-332(2),
346-353(7)
csym
defined in line
184; used 13 times
ctab
defined in line
159; used 12 times
curbase
defined in line
178; used 19 times
- in /usr/src/cmd/c/c00.c line
108,
630,
881
- in /usr/src/cmd/c/c01.c line
472-473(2),
643
- in /usr/src/cmd/c/c02.c line
110,
131,
147,
236,
569,
578
- in /usr/src/cmd/c/c03.c line
167,
176,
209,
330-332(2),
393,
474
cval
defined in line
185; used 32 times
- in /usr/src/cmd/c/c00.c line
186,
236,
343,
364,
462,
468,
528-529(2),
537-538(2),
667,
679-687(3)
- in /usr/src/cmd/c/c02.c line
334,
350,
382,
390,
433
- in /usr/src/cmd/c/c03.c line
62,
68-74(4),
86-93(4),
101,
582,
589-591(2)
defsym
defined in line
181; used 15 times
- in /usr/src/cmd/c/c02.c line
38,
46,
507
- in /usr/src/cmd/c/c03.c line
188,
203,
322-323(2),
518,
538,
547,
554,
561-563(2),
583,
674
eof
defined in line
175; used 6 times
funcbase
defined in line
177; used 21 times
- in /usr/src/cmd/c/c00.c line
108,
630,
878-881(2),
887
- in /usr/src/cmd/c/c01.c line
643
- in /usr/src/cmd/c/c02.c line
76-81(2),
131,
145-147(2),
236,
568-569(2),
578
- in /usr/src/cmd/c/c03.c line
167,
176,
209,
330,
393,
474
isn
defined in line
164; used 27 times
- in /usr/src/cmd/c/c00.c line
343
- in /usr/src/cmd/c/c02.c line
105-109(3),
120,
354,
364,
388-391(2),
405-406(2),
427-429(3),
452-454(2),
460,
475,
481-482(2),
516,
563,
616
- in /usr/src/cmd/c/c03.c line
439-445(3)
- in /usr/src/cmd/c/c04.c line
268
line
defined in line
176; used 12 times
peekc
defined in line
174; used 24 times
- in /usr/src/cmd/c/c00.c line
216-218(3),
237-251(6),
277,
287,
299,
324-327(2),
339,
363,
457,
480,
566
- in /usr/src/cmd/c/c02.c line
500
- in /usr/src/cmd/c/c04.c line
285-286(2),
297,
310
peeksym
defined in line
173; used 54 times
- in /usr/src/cmd/c/c00.c line
209-211(3),
284,
704,
753,
820
- in /usr/src/cmd/c/c02.c line
22-27(2),
50-51(3),
62,
71,
89,
122,
176-177(2),
184-188(2),
195,
220,
258-262(2),
279,
327,
384-387(2),
398,
521,
544,
551-557(3),
792
- in /usr/src/cmd/c/c03.c line
105,
186,
238,
245-247(3),
259,
288-294(4),
382-384(2),
423,
545,
581,
599
- in /usr/src/cmd/c/c04.c line
260,
272
sbuf
defined in line
195; used 1 times
swp
defined in line
166; used 10 times
Defined struct's
cnode
defined in line
76; used 6 times
field
defined in line
56; used 2 times
fnode
defined in line
99; used 6 times
hshtab
defined in line
127; used 93 times
- in line 50,
162(2),
181-190(10),
202-204(4),
463(2)
- in /usr/src/cmd/c/c00.c line
126(2),
625(2),
867-872(8)
- in /usr/src/cmd/c/c01.c line
420-422(4)
- in /usr/src/cmd/c/c02.c line
17-18(4),
138(2),
246(2),
286-288(4),
643-648(4),
705-706(4),
755-757(4)
- in /usr/src/cmd/c/c03.c line
20(2),
38(2),
142-149(10),
227(2),
271-277(6),
510-515(6),
682(2)
- in /usr/src/cmd/c/c04.c line
75(2),
258(2)
lnode
defined in line
87; used 2 times
str
defined in line
48; used 20 times
tdim
defined in line
143; used 6 times
tnode
defined in line
64; used 110 times
- in line 69-70(4),
163(2),
199(2),
452-464(14)
- in /usr/src/cmd/c/c00.c line
18(2),
620(2),
627(2),
875(2)
- in /usr/src/cmd/c/c01.c line
22-23(4),
254-256(4),
277-279(4),
302-306(6),
319-324(6),
345(2),
397-403(6),
418(2),
487-489(4),
505-507(4),
636(2)
- in /usr/src/cmd/c/c02.c line
143(2),
244(2),
303(2),
539(2),
587(2),
644-649(4)
- in /usr/src/cmd/c/c04.c line
41(2),
51-53(4),
72-74(4),
169(2),
185-189(4),
247(2),
328(2),
342(2)
Defined macros
AND
defined in line
254; used 4 times
AREG
defined in line
349; used 4 times
ARG
defined in line
347; used 4 times
ARG1
defined in line
348; used 4 times
ARRAY
defined in line
333; used 17 times
- in /usr/src/cmd/c/c00.c line
688
- in /usr/src/cmd/c/c01.c line
59,
328
- in /usr/src/cmd/c/c02.c line
151,
185,
195(2),
513,
659-660(2)
- in /usr/src/cmd/c/c03.c line
306,
335,
596,
632
- in /usr/src/cmd/c/c04.c line
196,
265,
271
ASOR
defined in line
289;
never used
AUTO
defined in line
342; used 13 times
- in /usr/src/cmd/c/c00.c line
34
- in /usr/src/cmd/c/c02.c line
162,
186,
206,
227,
273,
669,
675
- in /usr/src/cmd/c/c03.c line
111,
342,
417,
424,
437
BSS
defined in line
393; used 2 times
CALL
defined in line
299; used 8 times
CASE
defined in line
363; used 1 times
CAST
defined in line
223; used 4 times
CHAR
defined in line
318; used 18 times
- in /usr/src/cmd/c/c00.c line
26,
688
- in /usr/src/cmd/c/c01.c line
61,
173,
199,
210,
228-236(3),
245,
349
- in /usr/src/cmd/c/c02.c line
185
- in /usr/src/cmd/c/c03.c line
252,
634,
647,
692
- in /usr/src/cmd/c/c04.c line
59,
350
CMSIZ
defined in line
23; used 2 times
CON
defined in line
228; used 14 times
DATA
defined in line
392; used 2 times
DIGIT
defined in line
381; used 14 times
DO
defined in line
366; used 1 times
DOT
defined in line
246; used 1 times
ELSE
defined in line
361; used 3 times
ENUM
defined in line
369; used 6 times
EOFC
defined in line
211; used 7 times
EVEN
defined in line
399; used 4 times
EXOR
defined in line
256; used 3 times
EXPR
defined in line
402; used 1 times
EXTERN
defined in line
343; used 18 times
- in /usr/src/cmd/c/c00.c line
35,
652,
658
- in /usr/src/cmd/c/c02.c line
26,
33-35(2),
45,
55,
73,
216,
716,
744
- in /usr/src/cmd/c/c03.c line
331,
343-349(4)
- in /usr/src/cmd/c/c04.c line
90
FCON
defined in line
230; used 6 times
FMOS
defined in line
442; used 4 times
FOR
defined in line
368; used 1 times
FSEL
defined in line
222; used 2 times
FTI
defined in line
431; used 1 times
FTL
defined in line
433; used 1 times
FTOI
defined in line
259; used 2 times
FTOL
defined in line
262; used 1 times
FUNC
defined in line
332; used 9 times
GOTO
defined in line
357; used 1 times
IF
defined in line
359; used 1 times
INIT
defined in line
303; used 2 times
INT
defined in line
317; used 31 times
- in /usr/src/cmd/c/c00.c line
25,
33
- in /usr/src/cmd/c/c01.c line
55,
62-63(2),
90,
137,
158,
173,
199,
207,
225-237(5),
349,
438
- in /usr/src/cmd/c/c03.c line
28,
46,
87,
109-113(2),
121,
197,
450,
640,
691-692(2)
- in /usr/src/cmd/c/c04.c line
62,
351
ITC
defined in line
435;
never used
ITF
defined in line
426; used 2 times
ITL
defined in line
427; used 3 times
ITOC
defined in line
311; used 2 times
ITOF
defined in line
258; used 2 times
ITOL
defined in line
264; used 1 times
ITOP
defined in line
266; used 1 times
ITP
defined in line
429; used 5 times
JUMP
defined in line
301; used 1 times
KEYW
defined in line
226; used 8 times
LCON
defined in line
232; used 3 times
LEAF
defined in line
421;
never used
LESS
defined in line
273; used 2 times
LNCPW
defined in line
30; used 4 times
LONG
defined in line
322; used 5 times
LTF
defined in line
428; used 2 times
LTI
defined in line
432; used 2 times
LTOF
defined in line
263; used 1 times
LTOI
defined in line
265; used 1 times
LTOP
defined in line
268; used 1 times
LTP
defined in line
434; used 4 times
LTYPE
defined in line
14; used 2 times
MAX
defined in line
294; used 3 times
MAXP
defined in line
295; used 1 times
MIN
defined in line
296; used 2 times
MINP
defined in line
297;
never used
MOD
defined in line
251; used 1 times
MOS
defined in line
341; used 10 times
MOU
defined in line
350; used 3 times
NAME
defined in line
227; used 18 times
- in /usr/src/cmd/c/c00.c line
18,
144,
165,
212,
688
- in /usr/src/cmd/c/c01.c line
106,
132,
328,
425,
494
- in /usr/src/cmd/c/c02.c line
27,
51,
644
- in /usr/src/cmd/c/c03.c line
55,
158
- in /usr/src/cmd/c/c04.c line
89,
109,
260
NBPC
defined in line
28; used 4 times
NBPW
defined in line
27; used 2 times
NCPS
defined in line
17; used 9 times
NCPW
defined in line
29; used 1 times
NEG
defined in line
243; used 1 times
NMEMS
defined in line
26; used 4 times
OR
defined in line
255; used 2 times
PLUS
defined in line
247; used 9 times
PROG
defined in line
391; used 2 times
PTI
defined in line
430; used 6 times
PTOI
defined in line
267; used 1 times
PTR
defined in line
331; used 13 times
REG
defined in line
345; used 9 times
RPARN
defined in line
219; used 12 times
SAVE
defined in line
397; used 1 times
SEMI
defined in line
213; used 15 times
SEOF
defined in line
312; used 1 times
SSIZE
defined in line
24; used 3 times
STAR
defined in line
242; used 8 times
STARG
defined in line
32; used 1 times
SWIT
defined in line
401; used 1 times
SWSIZ
defined in line
25; used 2 times
SZINT
defined in line
39; used 2 times
SZPTR
defined in line
40; used 1 times
TYPE
defined in line
327; used 12 times
UNKN
defined in line
384; used 30 times
UNSIGN
defined in line
323; used 18 times
- in /usr/src/cmd/c/c00.c line
31
- in /usr/src/cmd/c/c01.c line
44,
61,
138,
145,
173-174(3),
198-199(3),
349,
514,
527
- in /usr/src/cmd/c/c03.c line
114,
640,
692
- in /usr/src/cmd/c/c04.c line
62
XTYPE
defined in line
330; used 19 times
- in /usr/src/cmd/c/c01.c line
59(2),
94,
100,
310,
328
- in /usr/src/cmd/c/c02.c line
49,
151,
659
- in /usr/src/cmd/c/c03.c line
305-306(2),
312-317(2),
335,
341,
632,
692-693(2)
- in /usr/src/cmd/c/c04.c line
196
XX
defined in line
436; used 4 times
Usage of this include