blob: 35226da10ed24f1ff967743faadaeb955f96a793 [file] [log] [blame]
swissChilib3ca4fb2021-04-20 10:33:00 -07001#include "std.h"
2
3value_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
11void 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
25void load_std (struct environment *env)
26{
27 add_function (env, "+", l_plus, 2);
28}