a.h 3.0 KB

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