2 * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
114 TAILQ_HEAD(bindings, binding);
116 TAILQ_ENTRY(binding) entry;
121 * Hack to support varargs. We set a special variable named
122 * "..." that contains the list of ops that will evaluate to
128 TAILQ_HEAD(envs, env);
130 TAILQ_ENTRY(env) entry;
131 struct bindings bindings;
134 TAILQ_HEAD(opstacks, opstack);
136 TAILQ_ENTRY(opstack) entry;
142 TAILQ_HEAD(procs, proc);
144 TAILQ_ENTRY(proc) entry;
148 char *args[MAXWELEM];
150 int (*nativefn)(int);
153 TAILQ_HEAD(tests, test);
155 TAILQ_ENTRY(test) entry;
168 int global_set(char *, struct op *);
170 struct op *newop(int);
171 void free_op_rec(struct op *);
172 void free_op(struct op *);
173 struct op *op_rest(void);
174 struct op *op_assign(char *, struct op *);
175 struct op *op_assert(struct op *);
176 struct op *op_var(char *);
177 struct op *op_lit_str(char *);
178 struct op *op_lit_num(uint64_t);
179 struct op *op_cmp_eq(struct op *, struct op *);
180 struct op *op_cast(struct op *, int);
181 struct op *op_faccess(struct op *, char *);
182 struct op *op_sfail(struct op *, char *);
183 struct op *op_vargs(void);
185 void ppf_val(FILE *, struct value *);
186 void pp_val(struct value *);
187 void pp_val(struct value *);
188 const char *val_type(struct value *);
189 int val_trueish(struct value *);
190 int val_isnum(struct value *);
191 int64_t val_tonum(struct value *);
192 int val_eq(struct value *, struct value *);
193 int val_cast(struct value *, int);
194 int val_faccess(struct value *, const char *, struct value *);
195 void pp_op(struct op *);
196 void pp_block(struct op *);
197 int eval(struct op *);
200 void prepare_funcall(void);
201 void push_arg(struct op *);
202 struct op *op_funcall(struct proc *);
205 void add_builtin_proc(const char *name, int (*)(int), int, int);
206 void prepare_proc(void);
207 /* push_arg works on procs too */
208 int proc_setup_body(void);
209 void proc_done(char *name);
210 void block_push(struct op *);
211 struct proc *proc_by_name(const char *);
214 void prepare_test(void);
215 void test_done(int, char *, char *);
218 void loadfile(const char *);