diff options
| author | Joel Martin <github@martintribe.org> | 2014-12-18 20:33:49 -0600 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2015-01-09 16:16:50 -0600 |
| commit | b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c (patch) | |
| tree | f4d977ed220e9a3f665cfbf4f68770a81e4c2095 /c/step3_env.c | |
| parent | aaba249304b184e12e2445ab22d66df1f39a51a5 (diff) | |
| download | mal-b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c.tar.gz mal-b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c.zip | |
All: add keywords.
Also, fix nth and count to match cloure.
Diffstat (limited to 'c/step3_env.c')
| -rw-r--r-- | c/step3_env.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/c/step3_env.c b/c/step3_env.c index 2f41bc0..cacf9d7 100644 --- a/c/step3_env.c +++ b/c/step3_env.c @@ -32,7 +32,7 @@ MalVal *eval_ast(MalVal *ast, Env *env) { if (!ast || mal_error) return NULL; if (ast->type == MAL_SYMBOL) { //g_print("EVAL symbol: %s\n", ast->val.string); - return env_get(env, ast->val.string); + return env_get(env, ast); } else if ((ast->type == MAL_LIST) || (ast->type == MAL_VECTOR)) { //g_print("EVAL sequential: %s\n", _pr_str(ast,1)); MalVal *el = _map2((MalVal *(*)(void*, void*))EVAL, ast, env); @@ -79,7 +79,7 @@ MalVal *EVAL(MalVal *ast, Env *env) { MalVal *a1 = _nth(ast, 1), *a2 = _nth(ast, 2); MalVal *res = EVAL(a2, env); - env_set(env, a1->val.string, res); + env_set(env, a1, res); return res; } else if (strcmp("let*", a0->val.string) == 0) { //g_print("eval apply let*\n"); @@ -95,7 +95,7 @@ MalVal *EVAL(MalVal *ast, Env *env) { key = g_array_index(a1->val.array, MalVal*, i); val = g_array_index(a1->val.array, MalVal*, i+1); assert_type(key, MAL_SYMBOL, "let* bind to non-symbol"); - env_set(let_env, key->val.string, EVAL(val, let_env)); + env_set(let_env, key, EVAL(val, let_env)); } return EVAL(a2, let_env); } else { @@ -143,10 +143,10 @@ void init_repl_env() { WRAP_INTEGER_OP(multiply,*) WRAP_INTEGER_OP(divide,/) - env_set(repl_env, "+", (MalVal *)int_plus); - env_set(repl_env, "-", (MalVal *)int_minus); - env_set(repl_env, "*", (MalVal *)int_multiply); - env_set(repl_env, "/", (MalVal *)int_divide); + env_set(repl_env, malval_new_symbol("+"), (MalVal *)int_plus); + env_set(repl_env, malval_new_symbol("-"), (MalVal *)int_minus); + env_set(repl_env, malval_new_symbol("*"), (MalVal *)int_multiply); + env_set(repl_env, malval_new_symbol("/"), (MalVal *)int_divide); } int main() |
