Add store into abstract machine struct
This commit is contained in:
12
lib/env.c
12
lib/env.c
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user