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

@@ -49,10 +49,10 @@ static expr_t **lookup(am_t *am, bool *found)
return &prev->pair.cdr;
}
void env_init(am_t *am, store_t *store)
void env_init(am_t *am)
{
am->env = expr_empty_list(store);
prim_load(am, store);
am->env = expr_empty_list(am);
prim_load(am);
}
void env_fetch(am_t *am)
@@ -62,7 +62,7 @@ void env_fetch(am_t *am)
am->val = found ? val : NULL;
}
void env_set(am_t *am, store_t *store)
void env_set(am_t *am)
{
bool found;
expr_t **loc = lookup(am, &found);
@@ -70,7 +70,7 @@ void env_set(am_t *am, store_t *store)
*loc = am->val;
} else {
(*loc)->is_atom = false;
(*loc)->pair.cdr = expr_empty_list(store);
(*loc)->pair.car = expr_pair(store, am->expr, am->val);
(*loc)->pair.cdr = expr_empty_list(am);
(*loc)->pair.car = expr_pair(am, am->expr, am->val);
}
}