acid.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. /* acid.h */
  2. enum
  3. {
  4. Eof = -1,
  5. Strsize = 4096,
  6. Hashsize = 128,
  7. Maxarg = 512,
  8. NFD = 100,
  9. Maxproc = 50,
  10. Maxval = 10,
  11. Mempergc = 1024*1024,
  12. };
  13. #pragma varargck type "L" void
  14. typedef struct Node Node;
  15. typedef struct String String;
  16. typedef struct Lsym Lsym;
  17. typedef struct List List;
  18. typedef struct Store Store;
  19. typedef struct Gc Gc;
  20. typedef struct Strc Strc;
  21. typedef struct Rplace Rplace;
  22. typedef struct Ptab Ptab;
  23. typedef struct Value Value;
  24. typedef struct Type Type;
  25. typedef struct Frtype Frtype;
  26. Extern int kernel;
  27. Extern int remote;
  28. Extern int text;
  29. Extern int silent;
  30. Extern Fhdr fhdr;
  31. Extern int line;
  32. Extern Biobuf* bout;
  33. Extern Biobuf* io[32];
  34. Extern int iop;
  35. Extern char symbol[Strsize];
  36. Extern int interactive;
  37. Extern int na;
  38. Extern int wtflag;
  39. Extern Map* cormap;
  40. Extern Map* symmap;
  41. Extern Lsym* hash[Hashsize];
  42. Extern long dogc;
  43. Extern Rplace* ret;
  44. Extern char* aout;
  45. Extern int gotint;
  46. Extern Gc* gcl;
  47. Extern int stacked;
  48. Extern jmp_buf err;
  49. Extern Node* prnt;
  50. Extern List* tracelist;
  51. Extern int initialising;
  52. Extern int quiet;
  53. extern void (*expop[])(Node*, Node*);
  54. #define expr(n, r) (r)->comt=0; (*expop[(n)->op])(n, r);
  55. extern int fmtsize(Value *v) ;
  56. enum
  57. {
  58. TINT,
  59. TFLOAT,
  60. TSTRING,
  61. TLIST,
  62. TCODE,
  63. };
  64. struct Type
  65. {
  66. Type* next;
  67. int offset;
  68. char fmt;
  69. char depth;
  70. Lsym* type;
  71. Lsym* tag;
  72. Lsym* base;
  73. };
  74. struct Frtype
  75. {
  76. Lsym* var;
  77. Type* type;
  78. Frtype* next;
  79. };
  80. struct Ptab
  81. {
  82. int pid;
  83. int ctl;
  84. };
  85. Extern Ptab ptab[Maxproc];
  86. struct Rplace
  87. {
  88. jmp_buf rlab;
  89. Node* stak;
  90. Node* val;
  91. Lsym* local;
  92. Lsym** tail;
  93. };
  94. struct Gc
  95. {
  96. char gcmark;
  97. Gc* gclink;
  98. };
  99. struct Store
  100. {
  101. char fmt;
  102. Type* comt;
  103. union {
  104. vlong ival;
  105. double fval;
  106. String* string;
  107. List* l;
  108. Node* cc;
  109. };
  110. };
  111. struct List
  112. {
  113. Gc;
  114. List* next;
  115. char type;
  116. Store;
  117. };
  118. struct Value
  119. {
  120. char set;
  121. char type;
  122. Store;
  123. Value* pop;
  124. Lsym* scope;
  125. Rplace* ret;
  126. };
  127. struct Lsym
  128. {
  129. char* name;
  130. int lexval;
  131. Lsym* hash;
  132. Value* v;
  133. Type* lt;
  134. Node* proc;
  135. Frtype* local;
  136. void (*builtin)(Node*, Node*);
  137. };
  138. struct Node
  139. {
  140. Gc;
  141. char op;
  142. char type;
  143. Node* left;
  144. Node* right;
  145. Lsym* sym;
  146. int builtin;
  147. Store;
  148. };
  149. #define ZN (Node*)0
  150. struct String
  151. {
  152. Gc;
  153. char *string;
  154. int len;
  155. };
  156. List* addlist(List*, List*);
  157. List* al(int);
  158. Node* an(int, Node*, Node*);
  159. void append(Node*, Node*, Node*);
  160. int bool(Node*);
  161. void build(Node*);
  162. void call(char*, Node*, Node*, Node*, Node*);
  163. void catcher(void*, char*);
  164. void checkqid(int, int);
  165. void cmd(void);
  166. Node* con(vlong);
  167. List* construct(Node*);
  168. void ctrace(int);
  169. void decl(Node*);
  170. void defcomplex(Node*, Node*);
  171. void deinstall(int);
  172. void delete(List*, int n, Node*);
  173. void dostop(int);
  174. Lsym* enter(char*, int);
  175. void error(char*, ...);
  176. void execute(Node*);
  177. void fatal(char*, ...);
  178. void flatten(Node**, Node*);
  179. void gc(void);
  180. char* getstatus(int);
  181. void* gmalloc(long);
  182. void indir(Map*, uvlong, char, Node*);
  183. void installbuiltin(void);
  184. void kinit(void);
  185. int Lfmt(Fmt*);
  186. int listcmp(List*, List*);
  187. int listlen(List*);
  188. List* listvar(char*, vlong);
  189. void loadmodule(char*);
  190. void loadvars(void);
  191. Lsym* look(char*);
  192. void ltag(char*);
  193. void marklist(List*);
  194. Lsym* mkvar(char*);
  195. void msg(int, char*);
  196. void notes(int);
  197. int nproc(char**);
  198. void nthelem(List*, int, Node*);
  199. int numsym(char);
  200. void odot(Node*, Node*);
  201. void pcode(Node*, int);
  202. void pexpr(Node*);
  203. int popio(void);
  204. void pstr(String*);
  205. void pushfile(char*);
  206. void pushstr(Node*);
  207. void readtext(char*);
  208. void restartio(void);
  209. uvlong rget(Map*, char*);
  210. String *runenode(Rune*);
  211. int scmp(String*, String*);
  212. void sproc(int);
  213. String* stradd(String*, String*);
  214. String* straddrune(String*, Rune);
  215. String* strnode(char*);
  216. String* strnodlen(char*, int);
  217. char* system(void);
  218. void trlist(Map*, uvlong, uvlong, Symbol*);
  219. void unwind(void);
  220. void userinit(void);
  221. void varreg(void);
  222. void varsym(void);
  223. Waitmsg* waitfor(int);
  224. void whatis(Lsym*);
  225. void windir(Map*, Node*, Node*, Node*);
  226. void yyerror(char*, ...);
  227. int yylex(void);
  228. int yyparse(void);
  229. enum
  230. {
  231. ONAME,
  232. OCONST,
  233. OMUL,
  234. ODIV,
  235. OMOD,
  236. OADD,
  237. OSUB,
  238. ORSH,
  239. OLSH,
  240. OLT,
  241. OGT,
  242. OLEQ,
  243. OGEQ,
  244. OEQ,
  245. ONEQ,
  246. OLAND,
  247. OXOR,
  248. OLOR,
  249. OCAND,
  250. OCOR,
  251. OASGN,
  252. OINDM,
  253. OEDEC,
  254. OEINC,
  255. OPINC,
  256. OPDEC,
  257. ONOT,
  258. OIF,
  259. ODO,
  260. OLIST,
  261. OCALL,
  262. OCTRUCT,
  263. OWHILE,
  264. OELSE,
  265. OHEAD,
  266. OTAIL,
  267. OAPPEND,
  268. ORET,
  269. OINDEX,
  270. OINDC,
  271. ODOT,
  272. OLOCAL,
  273. OFRAME,
  274. OCOMPLEX,
  275. ODELETE,
  276. OCAST,
  277. OFMT,
  278. OEVAL,
  279. OWHAT,
  280. };