emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/lexspaces 73363e9 09/17: Store lexspace in closures


From: Andrea Corallo
Subject: scratch/lexspaces 73363e9 09/17: Store lexspace in closures
Date: Fri, 8 May 2020 16:43:08 -0400 (EDT)

branch: scratch/lexspaces
commit 73363e96b8b59531adcfe03e57d6569e209cccfb
Author: Andrea Corallo <address@hidden>
Commit: Andrea Corallo <address@hidden>

    Store lexspace in closures
---
 src/lisp.h | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/lisp.h b/src/lisp.h
index a24e5f2..9e941cb 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;
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]