Permalink
Browse files

Make swank-ecl.lisp work with latest ECL Git HEAD.

	* swank-ecl.lisp (assert-TAGS-file): Simplified.
	(assert-source-directory): New helper.
	(c-function-p): New helper.
	(c-function): Type based on above.
	(source-location): Move bits from FIND-DEFINITIONS-FOR-TYPE to
	this function. Use CONVERTING-ERRORS-TO-ERROR-LOCATION.
	(find-definitions-for-type): Simplified by using it.
  • Loading branch information...
1 parent b80fdc0 commit 32ea92d7f59dff55a2f6999d1d93ee1d68a4460d @trittweiler trittweiler committed Feb 22, 2010
Showing with 69 additions and 52 deletions.
  1. +12 −0 ChangeLog
  2. +57 −52 swank-ecl.lisp
View
@@ -1,5 +1,17 @@
2010-02-22 Tobias C. Rittweiler <tcr@freebits.de>
+ Make swank-ecl.lisp work with latest ECL Git HEAD.
+
+ * swank-ecl.lisp (assert-TAGS-file): Simplified.
+ (assert-source-directory): New helper.
+ (c-function-p): New helper.
+ (c-function): Type based on above.
+ (source-location): Move bits from FIND-DEFINITIONS-FOR-TYPE to
+ this function. Use CONVERTING-ERRORS-TO-ERROR-LOCATION.
+ (find-definitions-for-type): Simplified by using it.
+
+2010-02-22 Tobias C. Rittweiler <tcr@freebits.de>
+
* swank-backend.lisp (converting-errors-to-error-location): Moved
here from swank-sbcl.lisp so other backends can make use of it, too.
View
@@ -557,30 +557,29 @@
;;;; Definitions
-(defconstant +TAGS+ #P"SYS:TAGS")
-
-;;; FIXME: this depends on a patch not yet merged into ECL upstream.
-;;; When it's in, remove this.
-
-(defun get-source-pathname ()
- #+#. (swank-backend::with-symbol 'get-source-pathname 'si)
- (si:get-source-pathname))
-
-(defun assert-TAGS-file (fail)
- (flet ((fail (x)
- (funcall fail x)))
- (let ((ecl-src-dir (get-source-pathname)))
- (unless ecl-src-dir
- (fail (make-error-location "Do not know where ECL's source directory ~
- is. You can set the environment variable ~
- `ECLSRCDIR' for that purpose.")))
- (unless (probe-file ecl-src-dir)
- (fail (make-error-location "ECL's source directory ~S does not ~
- seem to exist." ecl-src-dir)))
- (unless (probe-file +TAGS+)
- (fail (make-error-location "No TAGS file ~A. You can create it by ~
- the command `make TAGS'"
- (truename +TAGS+)))))))
+;;; FIXME: There ought to be a better way.
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (defun c-function-p (object)
+ (and (functionp object)
+ (let ((fn-name (function-name object)))
+ (and fn-name (si:mangle-name fn-name t) t)))))
+
+(deftype c-function ()
+ `(satisfies c-function-p))
+
+(defvar +TAGS+ (namestring (translate-logical-pathname #P"SYS:TAGS")))
+
+(defun assert-source-directory ()
+ (unless (probe-file #P"SRC:")
+ (error "ECL's source directory ~A does not exist. ~
+ You can specify a different location via the environment ~
+ variable `ECLSRCDIR'."
+ (namestring (translate-logical-pathname #P"SYS:")))))
+
+(defun assert-TAGS-file ()
+ (unless (probe-file +TAGS+)
+ (error "No TAGS file ~A found. It should have been installed with ECL."
+ +TAGS+)))
(defun classify-definition-name (name)
(let ((types '()))
@@ -600,49 +599,55 @@
(defun find-definitions-for-type (name type)
(ecase type
(:lisp-function
- (list `((defun ,name) ,(source-location (symbol-function name)))))
+ (list `((defun ,name) ,(source-location (fdefinition name)))))
(:c-function
- (assert-TAGS-file #'(lambda (x) (return-from find-definitions-for-type x)))
- (multiple-value-bind (flag c-name) (si:mangle-name name t)
- (assert flag)
- ;; In ECL's code base sometimes the mangled name is used
- ;; directly, sometimes ECL's DPP magic of @LISP:SYMBOL is used.
- ;; We cannot predict here, so we just provide two candidates.
- (let* ((candidate1 c-name)
- (candidate2 (format nil "~A::~A"
- (package-name (symbol-package name))
- (symbol-name name)))
- (loc (make-location `(:etags-file ,(namestring (truename +TAGS+)))
- `(:tag ,candidate1 ,candidate2))))
- (list `((c-function ,name) ,loc)))))
+ (list `((c-function ,name) ,(source-location (fdefinition name)))))
(:generic-function
(loop for method in (clos:generic-function-methods (fdefinition name))
for specs = (clos:method-specializers method)
for loc = (source-location method)
when loc
collect `((defmethod ,name ,specs) ,loc)))
(:macro
- (values 'defmacro (source-location (macro-function name))))
+ (list `((defmacro ,name) ,(source-location (macro-function name)))))
(:special-operator)))
(defimplementation find-definitions (name)
(mapcan #'(lambda (type) (find-definitions-for-type name type))
(classify-definition-name name)))
+
(defun source-location (object)
- (typecase object
- (function
- ;; FIXME: EXT:C-F-FILE may return "/tmp/ECL_SWANK_KMOXtm" which
- ;; are the temporary files stemming from C-c C-c.
- (multiple-value-bind (file pos) (ext:compiled-function-file object)
- (when file
- (assert (probe-file file))
- (assert (not (minusp pos)))
- (make-file-location file pos))))
- (method
- ;; FIXME: This will always return NIL at the moment; ECL does not
- ;; store debug information for methods yet.
- (source-location (clos:method-function object)))))
+ (converting-errors-to-error-location
+ (typecase object
+ (c-function
+ (assert-source-directory)
+ (assert-TAGS-file)
+ (let ((lisp-name (function-name object)))
+ (assert lisp-name)
+ (multiple-value-bind (flag c-name) (si:mangle-name lisp-name t)
+ (assert flag)
+ ;; In ECL's code base sometimes the mangled name is used
+ ;; directly, sometimes ECL's DPP magic of @LISP:SYMBOL is used.
+ ;; We cannot predict here, so we just provide two candidates.
+ (let* ((candidate1 c-name)
+ (candidate2 (format nil "~A::~A"
+ (package-name (symbol-package lisp-name))
+ (symbol-name lisp-name))))
+ (make-location `(:etags-file ,+TAGS+)
+ `(:tag ,candidate1 ,candidate2))))))
+ (function
+ ;; FIXME: EXT:C-F-FILE may return "/tmp/ECL_SWANK_KMOXtm" which
+ ;; are the temporary files stemming from C-c C-c.
+ (multiple-value-bind (file pos) (ext:compiled-function-file object)
+ (when file
+ (assert (probe-file file))
+ (assert (not (minusp pos)))
+ (make-file-location file pos))))
+ (method
+ ;; FIXME: This will always return NIL at the moment; ECL does not
+ ;; store debug information for methods yet.
+ (source-location (clos:method-function object))))))
(defimplementation find-source-location (object)
(or (source-location object)

0 comments on commit 32ea92d

Please sign in to comment.