acid.h 4.6 KB

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