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