Add store into abstract machine struct
This commit is contained in:
27
lib/expr.c
27
lib/expr.c
@@ -1,53 +1,54 @@
|
||||
#include "expr.h"
|
||||
#include "store.h"
|
||||
|
||||
#include "am.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
expr_t *expr_integer(store_t *store, int64_t value)
|
||||
expr_t *expr_integer(am_t *am, int64_t value)
|
||||
{
|
||||
expr_t *expr = store_alloc(store);
|
||||
expr_t *expr = store_alloc(am);
|
||||
expr->is_atom = true;
|
||||
expr->atom.type = ATOM_TYPE_INTEGER;
|
||||
expr->atom.integer = value;
|
||||
return expr;
|
||||
}
|
||||
|
||||
expr_t *expr_symbol(store_t *store, const symbol_t *symbol)
|
||||
expr_t *expr_symbol(am_t *am, const symbol_t *symbol)
|
||||
{
|
||||
expr_t *expr = store_alloc(store);
|
||||
expr_t *expr = store_alloc(am);
|
||||
expr->is_atom = true;
|
||||
expr->atom.type = ATOM_TYPE_SYMBOL;
|
||||
memcpy(&expr->atom.symbol, symbol, sizeof(symbol_t));
|
||||
return expr;
|
||||
}
|
||||
|
||||
expr_t *expr_str_symbol(store_t *store, const char *str)
|
||||
expr_t *expr_str_symbol(am_t *am, const char *str)
|
||||
{
|
||||
symbol_t symbol = { .len = strlen(str) };
|
||||
memcpy(symbol.buf, str, symbol.len);
|
||||
return expr_symbol(store, &symbol);
|
||||
return expr_symbol(am, &symbol);
|
||||
}
|
||||
|
||||
expr_t *expr_empty_list(store_t *store)
|
||||
expr_t *expr_empty_list(am_t *am)
|
||||
{
|
||||
expr_t *expr = store_alloc(store);
|
||||
expr_t *expr = store_alloc(am);
|
||||
expr->is_atom = true;
|
||||
expr->atom.type = ATOM_TYPE_EMPTY_LIST;
|
||||
return expr;
|
||||
}
|
||||
|
||||
expr_t *expr_pair(store_t *store, expr_t *car, expr_t *cdr)
|
||||
expr_t *expr_pair(am_t *am, expr_t *car, expr_t *cdr)
|
||||
{
|
||||
expr_t *expr = store_alloc(store);
|
||||
expr_t *expr = store_alloc(am);
|
||||
expr->is_atom = false;
|
||||
expr->pair.car = car;
|
||||
expr->pair.cdr = cdr;
|
||||
return expr;
|
||||
}
|
||||
|
||||
expr_t *expr_prim_proc(store_t *store, prim_proc_t prim_proc)
|
||||
expr_t *expr_prim_proc(am_t *am, prim_proc_t prim_proc)
|
||||
{
|
||||
expr_t *expr = store_alloc(store);
|
||||
expr_t *expr = store_alloc(am);
|
||||
expr->is_atom = true;
|
||||
expr->atom.type = ATOM_TYPE_PRIM_PROC;
|
||||
expr->atom.prim_proc = prim_proc;
|
||||
|
||||
Reference in New Issue
Block a user