diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 29 |
1 files changed, 14 insertions, 15 deletions
@@ -214,9 +214,10 @@ int main(int argc, char **argv) value_t proc_value = value_create( VALUE_PROC_BUILTIN, (void *)&builtin_proc_descriptions[i]); - hashtable_insert(builtin_env->table, - (void *)builtin_proc_name_list[i], - (void *)proc_value, NULL, NULL); + + env_insert(builtin_env, + builtin_proc_name_list[i], + proc_value, NULL, NULL); } FILE *fp = stdin; @@ -293,9 +294,9 @@ static value_t apply_lambda(struct proc *proc, value_t *args) tctx_init_toklist(&tctx, proc->body); for(size_t i = 0; i < proc->argc; i++) { - ERR_NZ(hashtable_insert(env->table, - (void*)proc->arg_keys[i]->value.atom, - (void*)value_copy(args[i]), NULL, NULL), _r, goto exit); + ERR_NZ(env_insert(env, proc->arg_keys[i]->value.atom, + value_copy(args[i]), NULL, NULL), + _r, goto exit); } TOKEN_NEXT(&tctx); @@ -458,16 +459,16 @@ value_t evaluate_id(env_t env, struct tctx *tctx) } value_t ret = VALUE_EMPTY; - ERR_NZ(hashtable_query(env->table, (void *)TOKEN(tctx)->value.id, (void **)&ret), _r, goto fail); + ERR_NZ(env_query(env, TOKEN(tctx)->value.id, &ret), _r, goto fail); return value_copy(ret); fail: - if(env == global_env->parent) { + if(env == env_parent(global_env)) { err("Symbol %s is unbound", TOKEN(tctx)->value.id); return VALUE_EMPTY; } - return evaluate_id(env->parent, tctx); + return evaluate_id(env_parent(env), tctx); } value_t evaluate_lambda(env_t env, struct tctx *tctx) @@ -558,10 +559,9 @@ value_t evaluate_define(env_t env, struct tctx *tctx) char *prevkey = NULL; ERR_NZ( - hashtable_insert(global_env->table, (void *)key, (void *)val, - (void**)&prevkey, (void **)&prevval), + env_insert(global_env, key, val, &prevkey, &prevval), r, { - err("Couldn't insert symbol into the hashtable due to %s", strerror(r)); + err("Couldn't insert symbol into the environement due to %s", strerror(r)); value_destroy(val); // the copy goto fail; }); @@ -643,10 +643,9 @@ value_t evaluate_defmacro(env_t env, struct tctx *tctx) char *prevkey = NULL; ERR_NZ( - hashtable_insert(global_env->table, (void *)key, (void *)lambda, - (void**)&prevkey, (void **)&prevval), + env_insert(global_env, key, lambda, &prevkey, &prevval), r, { - err("Couldn't insert symbol into the hashtable due to %s", strerror(r)); + err("Couldn't insert symbol into the environement due to %s", strerror(r)); goto fail; }); |