2
;; Usage: (si::proclaim-file "foo.lsp") (compile-file "foo.lsp")
6
;; You may wish to adjust the following to output the proclamations
7
;; for inclusion in a file. All fixed arg functions should be proclaimed
8
;; before their references for maximum efficiency.
10
;; CAVEAT: The following code only checks for fixed args, it does
11
;; not check for single valuedness BUT does make a proclamation
12
;; to that effect. Unfortunately it is impossible to tell about
13
;; multiple values without doing a full compiler type pass over
14
;; all files in the relevant system. However the GCL compiler should
15
;; warn if you inadvertantly proclaim foo to be single valued and then try
16
;; to use more than one value.
18
(DEFVAR *DECLARE-T-ONLY* NIL)
19
(DEFUN PROCLAIM-FILE (NAME &OPTIONAL *DECLARE-T-ONLY*)
23
(LET ((EOF (CONS NIL NIL)))
25
(LET ((FORM (READ FILE NIL EOF)))
26
(COND ((EQ EOF FORM) (RETURN NIL))
27
((MAKE-DECLARE-FORM FORM ))))))))
29
(DEFVAR *DEFUNS* '(DEFUN))
31
(DEFUN MAKE-DECLARE-FORM (FORM)
35
(COND ((MEMBER (CAR FORM) '(EVAL-WHEN ))
36
(DOLIST (V (CDDR FORM)) (MAKE-DECLARE-FORM V)))
37
((MEMBER (CAR FORM) '(PROGN ))
38
(DOLIST (V (CDR FORM)) (MAKE-DECLARE-FORM V)))
39
((MEMBER (CAR FORM) '(IN-PACKAGE DEFCONSTANT))
41
((MEMBER (CAR FORM) *DEFUNS*)
45
(NOT (MEMBER '&REST (CADDR FORM)))
46
(NOT (MEMBER '&BODY (CADDR FORM)))
47
(NOT (MEMBER '&KEY (CADDR FORM)))
48
(NOT (MEMBER '&OPTIONAL (CADDR FORM))))
49
;;could print declarations here.
50
;(print (list (cadr form)(ARG-DECLARES (THIRD FORM)(cdddr FORM))))
54
(ARG-DECLARES (THIRD FORM) (cdddr FORM))
57
(DEFUN ARG-DECLARES (ARGS DECLS &AUX ANS)
58
(COND ((STRINGP (CAR DECLS)) (SETQ DECLS (CADR DECLS)))
59
(T (SETQ DECLS (CAR DECLS))))
60
(COND ((AND (not *declare-t-only*)
61
(CONSP DECLS) (EQ (CAR DECLS ) 'DECLARE))
62
(DO ((V ARGS (CDR V)))
63
((OR (EQ (CAR V) '&AUX)
66
(PUSH (DECL-TYPE (CAR V) DECLS) ANS)))
67
(T (MAKE-LIST (- (LENGTH args)
68
(LENGTH (MEMBER '&AUX args)))
69
:INITIAL-ELEMENT T))))
71
(DEFUN DECL-TYPE (V DECLS)
72
(DOLIST (D (CDR DECLS))
74
(TYPE (IF (MEMBER V (CDDR D))
75
(RETURN-FROM DECL-TYPE (SECOND D))))
76
((FIXNUM CHARACTER FLOAT LONG-FLOAT SHORT-FLOAT )
77
(IF (MEMBER V (CDR D)) (RETURN-FROM DECL-TYPE (CAR D))))))
b'\\ No newline at end of file'