From: Andrea Corallo Date: Fri, 8 May 2020 07:25:22 +0000 (+0100) Subject: Store lexspace in closures X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=73363e96b8b59531adcfe03e57d6569e209cccfb;p=emacs.git Store lexspace in closures --- diff --git a/src/lisp.h b/src/lisp.h index a24e5f219be..9e941cba656 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2223,7 +2223,7 @@ SYMBOL_VAL (struct Lisp_Symbol *sym) } INLINE Lisp_Object -SYMBOL_FUNCTION (struct Lisp_Symbol *sym) +symbol_function_1 (struct Lisp_Symbol *sym) { if (NILP (sym->u.s._function)) return Qnil; @@ -2235,6 +2235,23 @@ SYMBOL_FUNCTION (struct Lisp_Symbol *sym) return binding->b[lexspace]; } +INLINE Lisp_Object +SYMBOL_FUNCTION (struct Lisp_Symbol *sym) +{ + Lisp_Object tmp = symbol_function_1 (sym); + + if (CONSP (tmp) + && CONSP (XCDR (tmp)) + && EQ (XCAR (XCDR (tmp)), Qclosure)) + { + /* Remove the lexspace number in case (n closure () ...) is + found. */ + eassert (FIXNUMP (XCAR (tmp))); + return XCDR (tmp); + } + return tmp; +} + INLINE struct Lisp_Symbol * SYMBOL_ALIAS (struct Lisp_Symbol *sym) { @@ -3446,6 +3463,9 @@ set_symbol_function (Lisp_Object sym, Lisp_Object function) struct Lisp_Symbol *s = XSYMBOL (sym); if (NILP (s->u.s._function)) s->u.s._function = make_binding (Qnil); + /* Functions must execute in the original lexspace so lets store it. */ + if (CONSP (function) && EQ (XCAR (function), Qclosure)) + function = Fcons (make_fixnum (curr_lexspace), function); XBINDING (s->u.s._function)->b[curr_lexspace] = function; }