Changeset 6617


Ignore:
Timestamp:
May 28, 2007, 12:43:25 AM (18 years ago)
Author:
Gary Byers
Message:

ARG-NAMES-FROM-MAP.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ide-1.0/ccl/lib/arglist.lisp

    r4782 r6617  
    5656              (ignore-errors (values (read stream nil eof))))
    5757            (when errorp
    58               #+help-file ; %HEL temporarily avoiding reference to help file
    59               (if use-help-file
    60                 (return-from %arglist
    61                   (%arglist sym include-bindings temp-cons-p nil)))
    6258              (push '&rest res)
    6359              (push ':unparseable res)
     
    171167            (values (nreverse res) t))
    172168          (values nil (zerop ncells)))))))
     169
     170(defun arg-names-from-map (lfun)
     171  (multiple-value-bind (nreq nopt restp nkeys allow-other-keys
     172                             optinit lexprp
     173                             ncells nclosed)
     174      (function-args lfun)
     175    (declare (ignore optinit ncells allow-other-keys))
     176    (collect ((req)
     177              (opt)
     178              (keys))
     179      (let* ((rest nil)
     180             (map (car (function-symbol-map lfun))))
     181        (if map
     182          (let ((total (+ nreq nopt (if (or restp lexprp) 1 0) (or nkeys 0)))
     183                (idx (- (length map) nclosed)))
     184            (unless (zerop total)
     185              (progn
     186                (dotimes (x nreq)
     187                  (declare (fixnum x))
     188                  (req (if (> idx 0) (elt map (decf idx)) (make-arg "ARG" x))))
     189                (when (neq nopt 0)
     190                  (dotimes (x (the fixnum nopt))
     191                    (opt (if (> idx 0) (elt map (decf idx)) (make-arg "OPT" x)))))
     192                (when nkeys
     193                  (dotimes (i (the fixnum nkeys))
     194                    (keys (if (> idx 0) (elt map (decf idx)) (make-arg "KEY" i)))))
     195                (when (or restp lexprp)
     196                  (setq rest (if (> idx 0) (elt map (decf idx)) 'the-rest)))))))
     197        (values (not (null map)) (req) (opt) rest (keys))))))
     198             
     199             
     200
    173201
    174202(defvar *req-arg-names*
Note: See TracChangeset for help on using the changeset viewer.