emacs-diffs
[Top][All Lists]
Advanced

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

master 9ed24bfb04f 3/4: * Have `comp-cstr-to-type-spec' handle comp-cstr


From: Andrea Corallo
Subject: master 9ed24bfb04f 3/4: * Have `comp-cstr-to-type-spec' handle comp-cstr-f as well
Date: Sun, 4 Jun 2023 07:08:11 -0400 (EDT)

branch: master
commit 9ed24bfb04f5a878689e09914f1c4b28105ac85e
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>

    * Have `comp-cstr-to-type-spec' handle comp-cstr-f as well
    
    * lisp/emacs-lisp/comp-cstr.el (comp--simple-cstr-to-type-spec): New
    function.
    (comp-cstr-to-type-spec): Make use of.
---
 lisp/emacs-lisp/comp-cstr.el | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el
index 416ca7f11b0..c5b96a6b629 100644
--- a/lisp/emacs-lisp/comp-cstr.el
+++ b/lisp/emacs-lisp/comp-cstr.el
@@ -1181,8 +1181,8 @@ FN non-nil indicates we are parsing a function lambda 
list."
       :ret (comp-type-spec-to-cstr ret)))
     (_ (error "Invalid type specifier"))))
 
-(defun comp-cstr-to-type-spec (cstr)
-  "Given CSTR return its type specifier."
+(defun comp--simple-cstr-to-type-spec (cstr)
+  "Given a non comp-cstr-f CSTR return its type specifier."
   (let ((valset (comp-cstr-valset cstr))
         (typeset (comp-cstr-typeset cstr))
         (range (comp-cstr-range cstr))
@@ -1236,6 +1236,20 @@ FN non-nil indicates we are parsing a function lambda 
list."
           `(not ,final)
         final))))
 
+(defun comp-cstr-to-type-spec (cstr)
+  "Given CSTR return its type specifier."
+  (cl-etypecase cstr
+    (comp-cstr-f
+     `(function
+       ,(mapcar (lambda (x)
+                  (cl-etypecase x
+                    (comp-cstr (comp-cstr-to-type-spec x))
+                    (symbol x)))
+                (comp-cstr-f-args cstr))
+       ,(comp--simple-cstr-to-type-spec (comp-cstr-f-ret cstr))))
+    (comp-cstr
+     (comp--simple-cstr-to-type-spec cstr))))
+
 (provide 'comp-cstr)
 
 ;;; comp-cstr.el ends here



reply via email to

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