Blob


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