Blob


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