Consolidate expression creation functions in expr module

This commit is contained in:
2025-08-10 13:27:20 +01:00
parent fade9395fa
commit 03bd0ff597
9 changed files with 189 additions and 76 deletions

View File

@@ -49,9 +49,7 @@ static expr_t **lookup(am_t *am, bool *found)
void env_init(am_t *am, store_t *store)
{
am->env = store_alloc(store);
am->env->is_atom = true;
am->env->atom.type = ATOM_TYPE_EMPTY_LIST;
am->env = expr_empty_list(store);
}
void env_fetch(am_t *am)
@@ -69,12 +67,7 @@ void env_set(am_t *am, store_t *store)
*loc = am->val;
} else {
(*loc)->is_atom = false;
(*loc)->pair.cdr = store_alloc(store);
(*loc)->pair.cdr->is_atom = true;
(*loc)->pair.cdr->atom.type = ATOM_TYPE_EMPTY_LIST;
expr_t *entry = (*loc)->pair.car = store_alloc(store);
entry->pair.car = am->expr;
entry->pair.cdr = am->val;
(*loc)->pair.cdr = expr_empty_list(store);
(*loc)->pair.car = expr_pair(store, am->expr, am->val);
}
}