a.h 3.4 KB

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