avoid resolving module-path-index (current-directory may not be set right)

This commit is contained in:
Ryan Culpepper 2011-12-12 17:39:18 -07:00
parent 1ec2f9ca82
commit 32c5e3c9d2

View File

@ -4,6 +4,7 @@
racket/contract/base racket/contract/base
syntax/location) syntax/location)
syntax/srcloc syntax/srcloc
syntax/modcollapse
racket/syntax) racket/syntax)
(provide/contract (provide/contract
@ -71,17 +72,20 @@
(if (syntax? ctx) (if (syntax? ctx)
(get-source-expr (extract-source ctx) #f) (get-source-expr (extract-source ctx) #f)
(get-source-expr 'unknown #f))] (get-source-expr 'unknown #f))]
[else [(string? source) #`(quote #,source)]
(let ([source-string [(syntax? source) #`(quote #,(source-location->string source))]
(cond [(string? source) source]
[(syntax? source) (source-location->string source)]
[(module-path-index? source) [(module-path-index? source)
;; FIXME: share with syntax/location ?? ;; FIXME: extend collapse-module-path-index to accept #f, return rel mod path
(let ([name (resolved-module-path-name (let* ([here (current-load-relative-directory)]
(module-path-index-resolve source))]) [collapsed
(cond [(path? name) (format "(file ~s)" (path->string name))] (collapse-module-path-index source (or here (build-path 'same)))])
[(symbol? name) (format "(quote ~s)" name)]))])]) (cond [(and (path? collapsed) here)
#`(quote #,source-string))])) #`(quote #,(path->string collapsed))]
[(path? collapsed)
(let-values ([(rel base) (module-path-index-split source)])
#`(quote #,rel))]
[else
#`(quote #,(format "~s" collapsed))]))]))
(define (extract-source stx) (define (extract-source stx)
(let ([id (syntax-case stx () (let ([id (syntax-case stx ()