diff options
author | Andy Wingo <wingo@pobox.com> | 2010-10-01 18:15:23 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-10-01 18:15:23 +0200 |
commit | e867d563a56a86533f998441dc8c48dfef38d017 (patch) | |
tree | f20942408b8c8b647bae13d36996cb6a651ec145 | |
parent | c005daf9239b6c2b5574d88a0ee46195ac1cb1ec (diff) | |
download | guile-e867d563a56a86533f998441dc8c48dfef38d017.tar.gz |
add source:line-for-user, returning a 1-indexed line number
* module/system/vm/program.scm (source:line-for-user): New exported
procedure, returns a 1-indexed line, suitable for presentation to a
user.
(write-program): Use source:line-for-user when making fallback names.
* module/system/vm/coverage.scm (coverage-data->lcov):
* module/language/assembly/disassemble.scm (source->string):
* module/system/repl/debug.scm (print-frame): Use source:line-for-user.
-rw-r--r-- | module/language/assembly/disassemble.scm | 2 | ||||
-rw-r--r-- | module/system/repl/debug.scm | 2 | ||||
-rw-r--r-- | module/system/vm/coverage.scm | 6 | ||||
-rw-r--r-- | module/system/vm/program.scm | 9 |
4 files changed, 13 insertions, 6 deletions
diff --git a/module/language/assembly/disassemble.scm b/module/language/assembly/disassemble.scm index bd1f6a18e..88ea0d7d6 100644 --- a/module/language/assembly/disassemble.scm +++ b/module/language/assembly/disassemble.scm @@ -113,7 +113,7 @@ (define (source->string src) (format #f "~a:~a:~a" (or (source:file src) "(unknown file)") - (source:line src) (source:column src))) + (source:line-for-user src) (source:column src))) (define (make-int16 byte1 byte2) (+ (* byte1 256) byte2)) diff --git a/module/system/repl/debug.scm b/module/system/repl/debug.scm index 28e7e3060..0e491b5db 100644 --- a/module/system/repl/debug.scm +++ b/module/system/repl/debug.scm @@ -109,7 +109,7 @@ "unknown file")) (let* ((source (frame-source frame)) (file (source:pretty-file source)) - (line (and=> source source:line)) + (line (and=> source source:line-for-user)) (col (and=> source source:column))) (if (and file (not (equal? file (source:pretty-file last-source)))) (format port "~&In ~a:~&" file)) diff --git a/module/system/vm/coverage.scm b/module/system/vm/coverage.scm index 755463181..268d2112a 100644 --- a/module/system/vm/coverage.scm +++ b/module/system/vm/coverage.scm @@ -332,10 +332,10 @@ gathered, even if their code was not executed." (and (program? proc) (let ((sources (program-sources* data proc))) (and (pair? sources) - (let* ((line (source:line (car sources))) + (let* ((line (source:line-for-user (car sources))) (name (or (procedure-name proc) - (format #f "anonymous-l~a" (+ 1 line))))) - (format port "FN:~A,~A~%" (+ 1 line) name) + (format #f "anonymous-l~a" line)))) + (format port "FN:~A,~A~%" line name) (and=> (procedure-execution-count data proc) (lambda (count) (format port "FNDA:~A,~A~%" count name)))))))) diff --git a/module/system/vm/program.scm b/module/system/vm/program.scm index 30f8c7ecd..a1e3ea4f0 100644 --- a/module/system/vm/program.scm +++ b/module/system/vm/program.scm @@ -28,6 +28,7 @@ binding:start binding:end source:addr source:line source:column source:file + source:line-for-user program-sources program-source program-bindings program-bindings-by-index program-bindings-for-ip @@ -64,6 +65,12 @@ (define (source:column source) (cdddr source)) +;; Lines are zero-indexed inside Guile, but users expect them to be +;; one-indexed. Columns, on the other hand, are zero-indexed to both. Go +;; figure. +(define (source:line-for-user source) + (1+ (source:line source))) + (define (collapse-locals locs) (let lp ((ret '()) (locs locs)) (if (null? locs) @@ -209,7 +216,7 @@ (number->string (object-address prog) 16) (or (source:file s) (if s "<current input>" "<unknown port>")) - (source:line s) (source:column s)))) + (source:line-for-user s) (source:column s)))) (number->string (object-address prog) 16)) (let ((arities (program-arities prog))) (if (or (not arities) (null? arities)) |