#include #include #include #pragma lib "../cc/cc.a$O" typedef struct Node Node; typedef struct Sym Sym; typedef struct Type Type; typedef struct Decl Decl; typedef struct Io Io; typedef struct Hist Hist; typedef struct Ref Ref; #define CNNAME 20 #define FPCHIP 1 #define NHUNK 50000L #define BUFSIZ 8192 #define NSYMB 500 #define NTYPE 11 #define XTYPE (NTYPE+6) #define NHASH 1024 #define STRINGSZ 200 #define HISTSZ 20 #define NINCLUDE 10 #define YYMAXDEPTH 500 #define ALLOC(lhs, type)\ while(nhunk < sizeof(type))\ gethunk();\ lhs = (type*)hunk;\ nhunk -= sizeof(type);\ hunk += sizeof(type); #define ALLOCN(lhs, len, n)\ if(lhs+len != hunk || nhunk < n) {\ while(nhunk <= len)\ gethunk();\ memmove(hunk, lhs, len);\ lhs = hunk;\ hunk += len;\ nhunk -= len;\ }\ hunk += n;\ nhunk -= n; struct Node { union { struct { union { Node* left; void* label; int reg; }; union { Node* right; long offset; }; }; double ud; /* fp constant */ char* us; /* character string */ ushort* rs; /* rune string */ }; Sym* sym; Type* type; Ref* ref; /* try to put in l/r su */ long lineno; char op; char class; char etype; char complex; char addable; char scale; }; #define Z ((Node*)0) struct Ref { Ref* link; long lineno; /* usage lineno */ union { long dlineno; /* def lineno if this is usage */ Sym* sym; /* file name for CHELP */ }; char class; /* class of this ref */ }; struct Sym { Sym* link; Type* type; Type* suetag; char* macro; Ref* ref; long varlineno; long offset; Node* label; ushort lexical; char name[CNNAME]; char block; char sueblock; char class; char sym; char aused; }; #define S ((Sym*)0) struct Decl { Decl* link; Sym* sym; Type* type; long varlineno; long offset; short val; char class; char block; char aused; }; #define D ((Decl*)0) struct Type { Sym* sym; Sym* tag; Type* link; Type* down; long width; long offset; long lineno; char shift; char nbits; char etype; }; #define T ((Type*)0) #define NODECL ((void(*)(int, Type*, Sym*))0) struct { char* p; int c; } fi; struct Io { Io* link; char* p; char b[BUFSIZ]; short c; short f; }; #define I ((Io*)0) struct Hist { Hist* link; char* name; long line; long offset; }; #define H ((Hist*)0) Hist* hist; enum { DMARK, DAUTO, DSUE, DLABEL, }; enum { OXXX, OADD, OADDR, OAND, OANDAND,OARRAY, OAS, OASADD, OASAND, OASASHL,OASASHR,OASDIV, OASHL, OASHR, OASLDIV,OASLMOD,OASLMUL, OASLSHR,OASMOD, OASMUL, OASOR, OASSUB, OASXOR, OBIT, OBREAK, OCASE, OCAST, OCOMMA, OCOND, OCONST, OCONTINUE,ODIV, ODOT, ODOTDOT,ODWHILE,OENUM, OEQ, OFOR, OFUNC, OGE, OGOTO, OGT, OHI, OHS, OIF, OIND, OINDREG,OINIT, OLABEL, OLDIV, OLE, OLIST, OLMOD, OLMUL, OLO, OLS, OLSHR, OLT, OMOD, OMUL, ONAME, ONE, ONOT, OOR, OOROR, OPOSTDEC,OPOSTINC,OPREDEC,OPREINC,OPROTO,OREGISTER,ORETURN,OSET, OSIZE, OSTRING,OLSTRING,OSTRUCT,OSUB, OSWITCH,OUNION, OUSED, OWHILE, OXOR, OEND }; enum { TXXX, TCHAR, TUCHAR, TSHORT, TUSHORT,TLONG, TULONG, TVLONG, TFLOAT, TDOUBLE, TIND, TFUNC, TARRAY, TVOID, TSTRUCT,TUNION, TENUM, TFILE, TOLD, TDOT, }; enum { CXXX, CAUTO, CEXTERN,CGLOBL,CSTATIC,CLOCAL,CTYPEDEF,CPARAM, CSELEM, CLABEL, CEXREG, /* * used in ref structure */ CHELP, CMACRO, CMACARG, CLEXICAL, CPREPROC, CSUETAG, CENUM, CLAST, }; enum { BXXX = 1L<