fix check-requires for submodules

original commit: 0b8b0c36ef80c79f0f9e7762ce1c5383917fd19e
This commit is contained in:
Ryan Culpepper 2012-04-23 16:55:53 -06:00
parent 982cd95c6b
commit 12e710ab30
7 changed files with 58 additions and 21 deletions

View File

@ -32,10 +32,11 @@
(cond [(symbol? name) 'no-bypass] (cond [(symbol? name) 'no-bypass]
[(hash-ref module-db name #f) [(hash-ref module-db name #f)
=> values] => values]
[else [(path? name)
(let ([str (path->relative-string/library name)]) (let ([str (path->relative-string/library name)])
(for/or ([rx (in-list no-bypass-rxs)]) (for/or ([rx (in-list no-bypass-rxs)])
(and (regexp-match? rx str) 'no-bypass)))]))) (and (regexp-match? rx str) 'no-bypass)))]
[else #f])))
;; module-db : ModuleDB ;; module-db : ModuleDB
(define module-db (define module-db

View File

@ -48,12 +48,17 @@
mpi-list->module-path) mpi-list->module-path)
;; get-module-derivation : module-path -> (values compiled Deriv) ;; get-module-derivation : module-path -> (values compiled Deriv)
(define (get-module-code/trace path) (define (get-module-code/trace modpath)
(get-module-code (resolve-module-path path #f) (let-values ([(path subs)
#:choose (lambda _ 'src) (match (resolve-module-path modpath #f)
#:compile (lambda (stx) [`(submod ,path . ,subs) (values path subs)]
(let-values ([(stx deriv) (trace/result stx expand)]) [path (values path null)])])
(values (compile stx) deriv))))) (get-module-code path
#:submodule-path subs
#:choose (lambda _ 'src)
#:compile (lambda (stx)
(let-values ([(stx deriv) (trace/result stx expand)])
(values (compile stx) deriv))))))
;; here-mpi? : any -> boolean ;; here-mpi? : any -> boolean
(define (here-mpi? x) (define (here-mpi? x)
@ -96,19 +101,22 @@
(collapse-module-path mod (lambda () (loop base)))] (collapse-module-path mod (lambda () (loop base)))]
[else (build-path 'same)]))] [else (build-path 'same)]))]
[else (build-path 'same)]))]) [else (build-path 'same)]))])
(match collapsed (let simplify ([collapsed collapsed])
[(list 'lib str) (match collapsed
(cond [(regexp-match? #rx"\\.rkt$" str) [(list* 'submod base subs)
(let* ([no-suffix (path->string (path-replace-suffix str ""))] (list* 'submod (simplify base) subs)]
[no-main [(list 'lib str)
(cond [(regexp-match #rx"^([^/]+)/main$" no-suffix) (cond [(regexp-match? #rx"\\.rkt$" str)
=> cadr] (let* ([no-suffix (path->string (path-replace-suffix str ""))]
[else no-suffix])]) [no-main
(string->symbol no-main))] (cond [(regexp-match #rx"^([^/]+)/main$" no-suffix)
[else collapsed])] => cadr]
[(? path?) [else no-suffix])])
(path->string (simplify-path collapsed #f))] ;; to get rid of "./" at beginning (string->symbol no-main))]
[_ collapsed]))) [else collapsed])]
[(? path?)
(path->string (simplify-path collapsed #f))] ;; to get rid of "./" at beginning
[_ collapsed]))))
;; -------- ;; --------

View File

@ -0,0 +1,3 @@
#lang racket/base
(define a 1)
(provide a)

View File

@ -0,0 +1,3 @@
#lang racket/base
(define b 2)
(provide b)

View File

@ -0,0 +1,8 @@
#lang racket/base
(module s racket/base
(define cs 30)
(provide cs))
(define c 3)
(provide c)

View File

@ -0,0 +1,7 @@
#lang racket/base
(require "src-a.rkt"
"src-b.rkt"
"src-c.rkt"
(submod "src-c.rkt" s))
(void a)

View File

@ -0,0 +1,7 @@
#lang racket/base
(require "src-a.rkt"
"src-b.rkt"
"src-c.rkt"
(submod "src-c.rkt" s))
(void cs)