| #include "std.h" |
| #include <stdlib.h> |
| |
| value_t l_plus (value_t a, value_t b) |
| { |
| if ( !integerp (a) || !integerp (b) ) |
| return nil; |
| |
| return (((a >> 2) + (b >> 2)) << 2) | INT_TAG; |
| } |
| |
| void add_function (struct environment *env, char *name, void *func, int nargs) |
| { |
| struct function *last, |
| *new = malloc (sizeof (struct function)); |
| |
| last = env->first; |
| new->prev = last; |
| new->name = name; |
| new->nargs = nargs; |
| new->code_ptr = func; |
| |
| env->first = new; |
| } |
| |
| void load_std (struct environment *env) |
| { |
| add_function (env, "+", l_plus, 2); |
| } |