felix@AI.SRI.COM (Francois Felix INGRAND) (02/09/90)
I am looking for a tool which given a set of lisp files would tell me which files x is using the macros defined in files y. It is more or less like a makedep (used by C programmers) except that with makedep, the #include declaration is used instead of the symbols. In the lisp case, you have first to extract the macros symbols, then look in which file it is used. It would be nice if it was detecting all the macros (even those generated by defstruct calls). One trick would be to redefined defmacro such that it remembers where the macro is defined (in file y), and at macro expansion time, it prints a statement saying that file x (the one you are currently compiling) is using file y. I am not sure how well this would deal with defstruct access function though. Thanks in advance for any pointer. -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Francois Felix INGRAND SRI International, AIC felix@AI.SRI.COM 333, Ravenswood Avenue felix%AI.SRI.COM@UUNET.UU.NET MENLO PARK, CA 94025, USA "Pourquoi tant de haine..." (Edika) "Read my Lisp... No new syntax" (nil)
felix@AI.SRI.COM (Francois Felix INGRAND) (02/12/90)
In article <1047@hunter.aaii.oz.au>, I wrote: > >One trick would be to redefined defmacro such that it remembers where >the macro is defined (in file y), and at macro expansion time, it >prints a statement saying that file x (the one you are currently >compiling) is using file y. I am not sure how well this would deal >with defstruct access function though. I came up with something like this. It does the job for the macro defined by defmacro, but not for those defined by other means. It creates a list of lists. The car of each list is a file which is using the macro(s) defined in the file(s) listed in the cdr. (defvar *macro-dep* nil) (setf (macro-function 'old-defmacro) (macro-function 'defmacro)) (setf (macro-function 'new-defmacro) (macro-function 'defmacro)) (new-defmacro defmacro (name args &rest body) (setf (get name 'filename) lcl:*source-pathname*) `(old-defmacro ,name ,args (if (member lcl:*source-pathname* *macro-dep* :key #'car) (pushnew (get ',name 'filename) (cdar (member lcl:*source-pathname* *macro-dep* :key #'car))) (pushnew (list lcl:*source-pathname* (get ',name 'filename)) *macro-dep* :test #'equal)) ,@body)) -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Francois Felix INGRAND SRI International, AIC felix@AI.SRI.COM 333, Ravenswood Avenue felix%AI.SRI.COM@UUNET.UU.NET MENLO PARK, CA 94025, USA "Pourquoi tant de haine..." (Edika) "Read my Lisp... No new syntax" (nil)