/[slime]/slime/swank-source-path-parser.lisp
ViewVC logotype

Diff of /slime/swank-source-path-parser.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by heller, Sun Jan 27 10:15:52 2008 UTC revision 1.19 by trittweiler, Mon Mar 17 11:35:26 2008 UTC
# Line 40  before and after of calling FN in the ha Line 40  before and after of calling FN in the ha
40      (let ((start (file-position stream))      (let ((start (file-position stream))
41            (values (multiple-value-list (funcall fn stream char)))            (values (multiple-value-list (funcall fn stream char)))
42            (end (file-position stream)))            (end (file-position stream)))
43        ;;(format t "[~D ~{~A~^, ~} ~D ~D]~%" start values end (char-code char))        ;(format t "[~D ~{~A~^, ~} ~D ~D ~S]~%" start values end (char-code char) char)
44        (unless (null values)        (unless (null values)
45          (push (cons start end) (gethash (car values) source-map)))          (push (cons start end) (gethash (car values) source-map)))
46        (values-list values))))        (values-list values))))
# Line 72  subexpressions of the object to stream p Line 72  subexpressions of the object to stream p
72        (push (cons start end) (gethash form source-map)))        (push (cons start end) (gethash form source-map)))
73      (values form source-map)))      (values form source-map)))
74    
75    (defun skip-toplevel-forms (n stream)
76      (let ((*read-suppress* t))
77        (dotimes (i n)
78          (read stream))))
79    
80  (defun read-source-form (n stream)  (defun read-source-form (n stream)
81    "Read the Nth toplevel form number with source location recording.    "Read the Nth toplevel form number with source location recording.
82  Return the form and the source-map."  Return the form and the source-map."
83    (let ((*read-suppress* t))    (skip-toplevel-forms n stream)
     (dotimes (i n)  
       (read stream)))  
84    (let ((*read-suppress* nil))    (let ((*read-suppress* nil))
85      (read-and-record-source-map stream)))      (read-and-record-source-map stream)))
86    
# Line 98  Return the form and the source-map." Line 101  Return the form and the source-map."
101      (source-path-stream-position path s)))      (source-path-stream-position path s)))
102    
103  (defun source-path-file-position (path filename)  (defun source-path-file-position (path filename)
104    (with-open-file (file filename)    ;; We go this long way round, and don't directly operate on the file
105      (source-path-stream-position path file)))    ;; stream because FILE-POSITION is not totally savy even on file
106      ;; character streams; on SBCL, FILE-POSITION returns the binary
107      ;; offset, and not the character offset---screwing up on Unicode.
108      (let ((toplevel-number (first path))
109            (buffer))
110        (with-open-file (file filename)
111          (skip-toplevel-forms (1+ toplevel-number) file)
112          (let ((endpos (file-position file)))
113            (setq buffer (make-array (list endpos) :element-type 'character
114                                     :initial-element #\Space))
115            (assert (file-position file 0))
116            (read-sequence buffer file :end endpos)))
117        (source-path-string-position path buffer)))
118    
119  (defun source-path-source-position (path form source-map)  (defun source-path-source-position (path form source-map)
120    "Return the start position of PATH from FORM and SOURCE-MAP.  All    "Return the start position of PATH from FORM and SOURCE-MAP.  All

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

  ViewVC Help
Powered by ViewVC 1.1.5