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.
89 TAILQ_HEAD(bindings, binding);
93 TAILQ_ENTRY(binding) entry;
96 TAILQ_HEAD(envs, env);
98 TAILQ_ENTRY(env) entry;
99 struct bindings bindings;
102 TAILQ_HEAD(opstacks, opstack);
104 TAILQ_ENTRY(opstack) entry;
110 TAILQ_HEAD(procs, proc);
112 TAILQ_ENTRY(proc) entry;
116 char *args[MAXWELEM];
118 int (*nativefn)(int);
121 TAILQ_HEAD(tests, test);
123 TAILQ_ENTRY(test) entry;
135 int global_set(char *, struct op *);
137 struct op *newop(int);
138 void free_op(struct op *);
139 struct op *op_assign(char *, struct op *);
140 struct op *op_assert(struct op *);
141 struct op *op_var(char *);
142 struct op *op_lit_str(char *);
143 struct op *op_lit_num(uint64_t);
144 struct op *op_cmp_eq(struct op *, struct op *);
145 struct op *op_cast(struct op *, int);
147 void ppf_val(FILE *, struct value *);
148 void pp_val(struct value *);
149 int val_trueish(struct value *);
150 int val_eq(struct value *, struct value *);
151 int val_cast(struct value *, int);
152 void pp_op(struct op *);
153 void pp_block(struct op *);
154 int eval(struct op *);
157 void prepare_funcall(void);
158 void push_arg(struct op *);
159 struct op *op_funcall(struct proc *);
162 void add_builtin_proc(const char *name, int (*)(int), int);
163 void prepare_proc(void);
164 /* push_arg works on procs too */
165 int proc_setup_body(void);
166 void proc_done(char *name);
167 void block_push(struct op *);
168 struct proc *proc_by_name(const char *);
171 void prepare_test(void);
172 void test_done(char *, char *);
175 void loadfile(const char *);