mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-14 05:12:38 -08:00
C::GET-PROCLAIMED-NARG understands complex function types with &optional, &rest and the like.
This commit is contained in:
parent
2bb0c1b443
commit
dbdd5a80e7
1 changed files with 23 additions and 15 deletions
|
|
@ -129,36 +129,44 @@
|
|||
(defun get-arg-types (fname)
|
||||
(let ((x (assoc fname *function-declarations*)))
|
||||
(if x
|
||||
(second x)
|
||||
(values (second x) t)
|
||||
(get-sysprop fname 'PROCLAIMED-ARG-TYPES))))
|
||||
|
||||
(defun get-return-type (fname)
|
||||
(let ((x (assoc fname *function-declarations*)))
|
||||
(if x
|
||||
(third x)
|
||||
(values (third x) t)
|
||||
(get-sysprop fname 'PROCLAIMED-RETURN-TYPE))))
|
||||
|
||||
(defun get-local-arg-types (fun &aux x)
|
||||
(if (setq x (assoc fun *function-declarations*))
|
||||
(second x)
|
||||
nil))
|
||||
(values (second x) t)
|
||||
(values nil nil)))
|
||||
|
||||
(defun get-local-return-type (fun &aux x)
|
||||
(if (setq x (assoc fun *function-declarations*))
|
||||
(caddr x)
|
||||
nil))
|
||||
(values (caddr x) t)
|
||||
(values nil nil)))
|
||||
|
||||
(defun get-proclaimed-narg (fun)
|
||||
(multiple-value-bind (x found)
|
||||
(get-sysprop fun 'PROCLAIMED-ARG-TYPES)
|
||||
(multiple-value-bind (arg-list found)
|
||||
(get-arg-types fun)
|
||||
(if found
|
||||
(let* ((minarg (length x))
|
||||
(maxarg call-arguments-limit))
|
||||
(if (eq (first (last x)) '*)
|
||||
(setf minarg (1- minarg))
|
||||
(setf maxarg minarg))
|
||||
(values minarg maxarg))
|
||||
(values 0 call-arguments-limit))))
|
||||
(loop for type in arg-list
|
||||
with minarg = 0
|
||||
and maxarg = 0
|
||||
and in-optionals = nil
|
||||
do (cond ((member type '(* &rest &key &allow-other-keys))
|
||||
(return (values minarg call-arguments-limit)))
|
||||
((eq type '&optional)
|
||||
(setf in-optionals t maxarg minarg))
|
||||
(in-optionals
|
||||
(incf maxarg))
|
||||
(t
|
||||
(incf minarg)
|
||||
(incf maxarg)))
|
||||
finally (return (values minarg maxarg)))
|
||||
(values 0 call-arguments-limit))))
|
||||
|
||||
;;; Proclamation and declaration handling.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue