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