swissChili | b3ca4fb | 2021-04-20 10:33:00 -0700 | [diff] [blame^] | 1 | #include "std.h" |
| 2 | |
| 3 | value_t l_plus (value_t a, value_t b) |
| 4 | { |
| 5 | if ( !integerp (a) || !integerp (b) ) |
| 6 | return nil; |
| 7 | |
| 8 | return (((a >> 2) + (b >> 2)) << 2) | INT_TAG; |
| 9 | } |
| 10 | |
| 11 | void add_function (struct environment *env, char *name, void *func, int nargs) |
| 12 | { |
| 13 | struct function *last, |
| 14 | *new = malloc (sizeof (struct function)); |
| 15 | |
| 16 | last = env->first; |
| 17 | new->prev = last; |
| 18 | new->name = name; |
| 19 | new->nargs = nargs; |
| 20 | new->code_ptr = func; |
| 21 | |
| 22 | env->prev = new; |
| 23 | } |
| 24 | |
| 25 | void load_std (struct environment *env) |
| 26 | { |
| 27 | add_function (env, "+", l_plus, 2); |
| 28 | } |