a.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. typedef struct Sym Sym;
  2. typedef struct Gen Gen;
  3. typedef struct Io Io;
  4. typedef struct Hist Hist;
  5. #define MAXALIGN 7
  6. #define FPCHIP 1
  7. #define NSYMB 8192
  8. #define BUFSIZ 8192
  9. #define HISTSZ 20
  10. #define NINCLUDE 10
  11. #define NHUNK 10000
  12. #define EOF (-1)
  13. #define IGN (-2)
  14. #define GETC() ((--fi.c < 0)? filbuf(): *fi.p++ & 0xff)
  15. #define NHASH 503
  16. #define STRINGSZ 200
  17. #define NMACRO 10
  18. #define ALLOC(lhs, type)\
  19. while(nhunk < sizeof(type))\
  20. gethunk();\
  21. lhs = (type*)hunk;\
  22. nhunk -= sizeof(type);\
  23. hunk += sizeof(type);
  24. #define ALLOCN(lhs, len, n)\
  25. if(lhs+len != hunk || nhunk < n) {\
  26. while(nhunk <= len)\
  27. gethunk();\
  28. memmove(hunk, lhs, len);\
  29. lhs = hunk;\
  30. hunk += len;\
  31. nhunk -= len;\
  32. }\
  33. hunk += n;\
  34. nhunk -= n;
  35. struct Sym
  36. {
  37. Sym* link;
  38. char* macro;
  39. long value;
  40. ushort type;
  41. char *name;
  42. char sym;
  43. };
  44. #define S ((Sym*)0)
  45. struct
  46. {
  47. char* p;
  48. int c;
  49. } fi;
  50. struct Io
  51. {
  52. Io* link;
  53. char b[BUFSIZ];
  54. char* p;
  55. short c;
  56. short f;
  57. };
  58. #define I ((Io*)0)
  59. struct
  60. {
  61. Sym* sym;
  62. short type;
  63. } h[NSYM];
  64. struct Gen
  65. {
  66. Sym* sym;
  67. long offset;
  68. short type;
  69. short reg;
  70. short xreg;
  71. short name;
  72. ushort mask;
  73. double dval;
  74. char sval[8];
  75. };
  76. struct Hist
  77. {
  78. Hist* link;
  79. char* name;
  80. long line;
  81. long offset;
  82. };
  83. #define H ((Hist*)0)
  84. enum
  85. {
  86. CLAST,
  87. CMACARG,
  88. CMACRO,
  89. CPREPROC,
  90. };
  91. char debug[256];
  92. Sym* hash[NHASH];
  93. char* Dlist[30];
  94. int nDlist;
  95. Hist* ehist;
  96. int newflag;
  97. Hist* hist;
  98. char* hunk;
  99. char* include[NINCLUDE];
  100. Io* iofree;
  101. Io* ionext;
  102. Io* iostack;
  103. long lineno;
  104. int nerrors;
  105. long nhunk;
  106. int nosched;
  107. int ninclude;
  108. Gen nullgen;
  109. char* outfile;
  110. int pass;
  111. char* pathname;
  112. long pc;
  113. int peekc;
  114. int sym;
  115. char symb[NSYMB];
  116. int thechar;
  117. char* thestring;
  118. long thunk;
  119. Biobuf obuf;
  120. void errorexit(void);
  121. void pushio(void);
  122. void newio(void);
  123. void newfile(char*, int);
  124. Sym* slookup(char*);
  125. Sym* lookup(void);
  126. void syminit(Sym*);
  127. long yylex(void);
  128. int getc(void);
  129. int getnsc(void);
  130. void unget(int);
  131. int escchar(int);
  132. void cinit(void);
  133. void pinit(char*);
  134. void cclean(void);
  135. void outcode(int, Gen*, int, Gen*);
  136. void outgcode(int, Gen*, int, Gen*, Gen*);
  137. void zname(char*, int, int);
  138. void zaddr(Gen*, int);
  139. void ieeedtod(Ieee*, double);
  140. int filbuf(void);
  141. Sym* getsym(void);
  142. void domacro(void);
  143. void macund(void);
  144. void macdef(void);
  145. void macexpand(Sym*, char*);
  146. void macinc(void);
  147. void macprag(void);
  148. void maclin(void);
  149. void macif(int);
  150. void macend(void);
  151. void dodefine(char*);
  152. void prfile(long);
  153. void outhist(void);
  154. void linehist(char*, int);
  155. void gethunk(void);
  156. void yyerror(char*, ...);
  157. int yyparse(void);
  158. void setinclude(char*);
  159. int assemble(char*);
  160. /*
  161. * system-dependent stuff from ../cc/compat.c
  162. */
  163. enum /* keep in synch with ../cc/cc.h */
  164. {
  165. Plan9 = 1<<0,
  166. Unix = 1<<1,
  167. Windows = 1<<2,
  168. };
  169. int mywait(int*);
  170. int mycreat(char*, int);
  171. int systemtype(int);
  172. int pathchar(void);
  173. char* mygetwd(char*, int);
  174. int myexec(char*, char*[]);
  175. int mydup(int, int);
  176. int myfork(void);
  177. int mypipe(int*);
  178. void* mysbrk(ulong);