From 9c986748e183341ad07d27aece1b9d3f479be24d Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Wed, 19 Oct 2016 07:22:15 +0200 Subject: [PATCH] Refactor primitives lookup. * mes.c (lookup_primitive_): Rename from internal_lookup_primitive, use scm-compatible signature. (lookup): Update caller. (eval_env): Check for builtins first. --- mes.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mes.c b/mes.c index 862390a5..c4f73403 100644 --- a/mes.c +++ b/mes.c @@ -349,6 +349,7 @@ apply_env (scm *fn, scm *x, scm *a) scm * eval_env (scm *e, scm *a) { + if (BUILTIN_P (e) != &scm_f) return e; if (internal_symbol_p (e) == &scm_t) return e; e = expand_macro_env (e, a); @@ -638,10 +639,10 @@ make_string (char const *s) scm *primitives = 0; scm * -internal_lookup_primitive (char const *s) +lookup_primitive_ (scm *e) { scm *x = primitives; - while (x && strcmp (s, x->car->name)) x = x->cdr; + while (x && strcmp (e->name, x->car->name)) x = x->cdr; if (x) x = x->car; return x; } @@ -850,8 +851,10 @@ lookup (char const *s, scm *a) return make_number (atoi (s)); scm *x; + scm p = {SYMBOL}; + p.name = s; #if STATIC_PRIMITIVES - x = internal_lookup_primitive (s); + x = lookup_primitive_ (&p); if (x) return x; #endif // STATIC_PRIMITIVES x = internal_lookup_symbol (s);