aboutsummaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authorOskari Timperi <oskari.timperi@iki.fi>2014-05-16 00:03:51 +0300
committerOskari Timperi <oskari.timperi@iki.fi>2014-05-16 00:03:51 +0300
commit85cff208efd20e85e9aa644d65a0cbea5e156755 (patch)
tree5592d416a66357ebe892cf33e3af78379bb36b64 /eval.c
parent8cb320351cfd95acbca06a4f59e79adc70ed52bf (diff)
downloadlispish-85cff208efd20e85e9aa644d65a0cbea5e156755.tar.gz
lispish-85cff208efd20e85e9aa644d65a0cbea5e156755.zip
fix: use eval_env() when evaluating stuff\!
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/eval.c b/eval.c
index f4624cf..d71ebc6 100644
--- a/eval.c
+++ b/eval.c
@@ -139,8 +139,8 @@ struct list *eval_env(struct list *expr, struct list *env)
return list_append(NULL, &nil_atom);
}
- a = eval(a);
- b = eval(b);
+ a = eval_env(a, env);
+ b = eval_env(b, env);
if (atom_cmp(a, b))
return list_append(NULL, &true_atom);
@@ -159,8 +159,8 @@ struct list *eval_env(struct list *expr, struct list *env)
if (!a || !b)
return list_append(NULL, &nil_atom);
- a = eval(a);
- b = eval(b);
+ a = eval_env(a, env);
+ b = eval_env(b, env);
if (!(ATOM_TYPE(a) == ATOM_TYPE(b) && ATOM_TYPE(a) == ATOM_INT))
return list_append(NULL, &nil_atom);
@@ -198,8 +198,8 @@ struct list *eval_env(struct list *expr, struct list *env)
if (!a || !b)
return list_append(NULL, &nil_atom);
- a = eval(a);
- b = eval(b);
+ a = eval_env(a, env);
+ b = eval_env(b, env);
if (!(ATOM_TYPE(a) == ATOM_TYPE(b) && ATOM_TYPE(a) == ATOM_INT))
return list_append(NULL, &nil_atom);
@@ -221,12 +221,12 @@ struct list *eval_env(struct list *expr, struct list *env)
if (!predicate || !true_case || !false_case)
return list_append(NULL, &nil_atom);
- predicate = eval(predicate);
+ predicate = eval_env(predicate, env);
if (IS_TRUE(predicate))
- return eval(true_case);
+ return eval_env(true_case, env);
else
- return eval(false_case);
+ return eval_env(false_case, env);
}
else if (strcmp(sym, "mod") == 0)
{
@@ -239,6 +239,9 @@ struct list *eval_env(struct list *expr, struct list *env)
return list_append(NULL, &nil_atom);
}
+ a = eval_env(a, env);
+ b = eval_env(b, env);
+
if (!IS_INT(a) || !IS_INT(b))
{
printf("error: mod arguments must be integers\n");