blob: 7bed8dea3da73fc29a34102a2d76e0b4946fd19a [file] [log] [blame]
#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);
}