From 85cff208efd20e85e9aa644d65a0cbea5e156755 Mon Sep 17 00:00:00 2001 From: Oskari Timperi Date: Fri, 16 May 2014 00:03:51 +0300 Subject: fix: use eval_env() when evaluating stuff\! --- eval.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'eval.c') 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"); -- cgit v1.2.3