Skip to content

Commit 8cb765d

Browse files
committed
Use errortrace/marks-to-context.
Follow recent change in DrRacket to provide source-code location provided by DrRacket. Fixes #253.
1 parent b9780af commit 8cb765d

3 files changed

Lines changed: 32 additions & 37 deletions

File tree

htdp-lib/lang/htdp-langs.rkt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
;; and the user's namespace in the teaching languages
2323
"private/set-result.rkt"
2424
"private/rewrite-error-message.rkt"
25+
errortrace/marks-to-context
2526

26-
"private/continuation-mark-key.rkt"
2727
"private/create-htdp-executable.rkt"
2828
"private/tp-dialog.rkt"
2929

@@ -49,7 +49,9 @@
4949

5050
(define o (current-output-port))
5151
(define (oprintf . args) (apply fprintf o args))
52-
52+
53+
(define htdp-continuation-mark-key (gensym 'htdp-continuation-mark-key))
54+
5355
(define tool@
5456
(unit
5557
(import drscheme:tool^)
@@ -196,7 +198,13 @@
196198
(htdp-lang-settings-true/false/empty-as-ids? settings)
197199
(get-abbreviate-cons-as-list)
198200
(get-use-function-output-syntax?)
199-
(get-output-function-instead-of-lambda?)))))))
201+
(get-output-function-instead-of-lambda?)))
202+
203+
(errortrace-continuation-mark-set->context
204+
(lambda (cms)
205+
(map
206+
(lambda (list) (apply make-srcloc list))
207+
(continuation-mark-set->list cms htdp-continuation-mark-key))))))))
200208

201209
(define/private (teaching-languages-error-value->string settings v len)
202210
(let ([sp (open-output-string)])
@@ -887,7 +895,7 @@
887895
(symbol? ppath))]))
888896

889897
[define cms (exn-continuation-marks exn)]
890-
[define lcm (continuation-mark-set->list cms teaching-languages-continuation-mark-key)]
898+
[define lcm (continuation-mark-set->list cms htdp-continuation-mark-key)]
891899

892900
(cond
893901
[(not lcm) '()] ;; MF: I don't understand how this could possibly hold
@@ -903,7 +911,7 @@
903911
;; with-mark : syntax syntax exact-nonnegative-integer -> syntax
904912
;; a member of stacktrace-imports^
905913
;; guarantees that the continuation marks associated with
906-
;; teaching-languages-continuation-mark-key are members of the debug-source type
914+
;; htdp-continuation-mark-key are members of the debug-source type
907915
(define (with-mark source-stx expr phase)
908916
[define source (syntax-source source-stx)]
909917
[define line (syntax-line source-stx)]
@@ -914,7 +922,7 @@
914922
(if (and (or (symbol? source) (path? source)) (number? alpha) (number? span))
915923
(with-syntax ([expr expr]
916924
[mark (list source line col alpha span)]
917-
[tlcmk teaching-languages-continuation-mark-key]
925+
[tlcmk htdp-continuation-mark-key]
918926
[wcm (syntax-shift-phase-level #'with-continuation-mark delta)]
919927
[quot (syntax-shift-phase-level #'quote delta)])
920928
#`(wcm (quot tlcmk) (quot mark) expr))

htdp-lib/lang/private/continuation-mark-key.rkt

Lines changed: 0 additions & 9 deletions
This file was deleted.

htdp-lib/test-engine/srcloc.rkt

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#lang racket/base
33
(provide exn-srcloc continuation-marks-srcloc)
44

5-
(require lang/private/continuation-mark-key
6-
setup/collects)
5+
(require setup/collects
6+
errortrace/marks-to-context)
77

88
; return srcloc associated with exception, in user program, or #f
99
(define (exn-srcloc exn)
@@ -12,24 +12,20 @@
1212
(and (pair? srclocs)
1313
(car srclocs)))
1414
(continuation-marks-srcloc (exn-continuation-marks exn))))
15-
15+
1616
(define (continuation-marks-srcloc marks)
17-
(let ([cms (continuation-mark-set->list marks teaching-languages-continuation-mark-key)])
18-
(cond
19-
[(not cms) '()]
20-
[(findf (lambda (mark)
21-
(and mark
22-
(let ([ppath (car mark)])
23-
(or (and (path? ppath)
24-
(not (let ([rel (path->collects-relative ppath)])
25-
(and (pair? rel)
26-
(eq? 'collects (car rel))
27-
(or (equal? #"lang" (cadr rel))
28-
(equal? #"deinprogramm" (cadr rel)))))))
29-
(symbol? ppath)))))
30-
cms)
31-
=> (lambda (mark)
32-
(apply (lambda (source line col pos span)
33-
(make-srcloc source line col pos span))
34-
mark))]
35-
(else #f))))
17+
(cond
18+
(((errortrace-continuation-mark-set->context) marks)
19+
=> (lambda (cms)
20+
(findf (lambda (mark)
21+
(and (srcloc? mark)
22+
(let ([ppath (srcloc-source mark)])
23+
(or (and (path? ppath)
24+
(not (let ([rel (path->collects-relative ppath)])
25+
(and (pair? rel)
26+
(eq? 'collects (car rel))
27+
(or (equal? #"lang" (cadr rel))
28+
(equal? #"deinprogramm" (cadr rel)))))))
29+
(symbol? ppath)))))
30+
cms)))
31+
(else #f)))

0 commit comments

Comments
 (0)