a.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 name;
  71. double dval;
  72. char sval[8];
  73. };
  74. struct Hist
  75. {
  76. Hist* link;
  77. char* name;
  78. long line;
  79. long offset;
  80. };
  81. #define H ((Hist*)0)
  82. enum
  83. {
  84. CLAST,
  85. CMACARG,
  86. CMACRO,
  87. CPREPROC,
  88. };
  89. char debug[256];
  90. Sym* hash[NHASH];
  91. char* Dlist[30];
  92. int nDlist;
  93. Hist* ehist;
  94. int newflag;
  95. Hist* hist;
  96. char* hunk;
  97. char* include[NINCLUDE];
  98. Io* iofree;
  99. Io* ionext;
  100. Io* iostack;
  101. long lineno;
  102. int nerrors;
  103. long nhunk;
  104. int nosched;
  105. int ninclude;
  106. Gen nullgen;
  107. char* outfile;
  108. int pass;
  109. char* pathname;
  110. long pc;
  111. int peekc;
  112. int sym;
  113. char symb[NSYMB];
  114. int thechar;
  115. char* thestring;
  116. long thunk;
  117. Biobuf obuf;
  118. void errorexit(void);
  119. void pushio(void);
  120. void newio(void);
  121. void newfile(char*, int);
  122. Sym* slookup(char*);
  123. Sym* lookup(void);
  124. void syminit(Sym*);
  125. long yylex(void);
  126. int getc(void);
  127. int getnsc(void);
  128. void unget(int);
  129. int escchar(int);
  130. void cinit(void);
  131. void pinit(char*);
  132. void cclean(void);
  133. int isreg(Gen*);
  134. void outcode(int, Gen*, int, Gen*);
  135. void zname(char*, int, int);
  136. void zaddr(Gen*, int);
  137. void ieeedtod(Ieee*, double);
  138. int filbuf(void);
  139. Sym* getsym(void);
  140. void domacro(void);
  141. void macund(void);
  142. void macdef(void);
  143. void macexpand(Sym*, char*);
  144. void macinc(void);
  145. void maclin(void);
  146. void macprag(void);
  147. void macif(int);
  148. void macend(void);
  149. void outhist(void);
  150. void dodefine(char*);
  151. void prfile(long);
  152. void linehist(char*, int);
  153. void gethunk(void);
  154. void yyerror(char*, ...);
  155. int yyparse(void);
  156. void setinclude(char*);
  157. int assemble(char*);
  158. /*
  159. * system-dependent stuff from ../cc/compat.c
  160. */
  161. enum /* keep in synch with ../cc/cc.h */
  162. {
  163. Plan9 = 1<<0,
  164. Unix = 1<<1,
  165. Windows = 1<<2,
  166. };
  167. int mywait(int*);
  168. int mycreat(char*, int);
  169. int systemtype(int);
  170. int pathchar(void);
  171. char* mygetwd(char*, int);
  172. int myexec(char*, char*[]);
  173. int mydup(int, int);
  174. int myfork(void);
  175. int mypipe(int*);
  176. void* mysbrk(ulong);