Add store into abstract machine struct

This commit is contained in:
2025-08-10 15:21:24 +01:00
parent b20a6749f7
commit d8e51b0aa0
18 changed files with 129 additions and 141 deletions

View File

@@ -11,7 +11,7 @@ typedef struct {
prim_proc_t prim_proc;
} prim_table_entry_t;
static void add(am_t *am, store_t *store)
static void add(am_t *am)
{
assert(am->argl);
@@ -21,10 +21,10 @@ static void add(am_t *am, store_t *store)
assert(list->pair.car->atom.type == ATOM_TYPE_INTEGER);
total += list->pair.car->atom.integer;
}
am->val = expr_integer(store, total);
am->val = expr_integer(am, total);
}
static void mul(am_t *am, store_t *store)
static void mul(am_t *am)
{
assert(am->argl);
@@ -34,10 +34,10 @@ static void mul(am_t *am, store_t *store)
assert(list->pair.car->atom.type == ATOM_TYPE_INTEGER);
total *= list->pair.car->atom.integer;
}
am->val = expr_integer(store, total);
am->val = expr_integer(am, total);
}
static void sub(am_t *am, store_t *store)
static void sub(am_t *am)
{
assert(am->argl);
assert(!am->argl->is_atom);
@@ -55,7 +55,7 @@ static void sub(am_t *am, store_t *store)
total -= list->pair.car->atom.integer;
}
}
am->val = expr_integer(store, total);
am->val = expr_integer(am, total);
}
static const prim_table_entry_t prim_table[] = {
@@ -64,11 +64,11 @@ static const prim_table_entry_t prim_table[] = {
{ "-", sub },
};
void prim_load(am_t *am, store_t *store)
void prim_load(am_t *am)
{
for (unsigned i = 0; i < NELEMS(prim_table); ++i) {
am->expr = expr_str_symbol(store, prim_table[i].name);
am->val = expr_prim_proc(store, prim_table[i].prim_proc);
env_set(am, store);
am->expr = expr_str_symbol(am, prim_table[i].name);
am->val = expr_prim_proc(am, prim_table[i].prim_proc);
env_set(am);
}
}