Some reformatting and reorganization, no functionality changes.
This commit is contained in:
parent
f3c695e3df
commit
8fb4e55d72
|
@ -1,7 +1,6 @@
|
|||
#lang racket/base
|
||||
|
||||
(require syntax/modcode
|
||||
(for-syntax racket/base))
|
||||
(require syntax/modcode racket/list (for-syntax racket/base))
|
||||
|
||||
(provide enter!)
|
||||
|
||||
|
@ -12,14 +11,9 @@
|
|||
(module-path? (syntax->datum #'mod)))
|
||||
#'(do-enter! 'mod)
|
||||
(raise-syntax-error
|
||||
#f
|
||||
"not a valid module path, and not #f"
|
||||
stx
|
||||
#'mod))]
|
||||
#f "not a valid module path, and not #f" stx #'mod))]
|
||||
[_ (raise-syntax-error
|
||||
#f
|
||||
"bad syntax; should be `(enter! <module-path-or-#f>)'"
|
||||
stx)]))
|
||||
#f "bad syntax; should be `(enter! <module-path-or-#f>)'" stx)]))
|
||||
|
||||
(define orig-namespace (current-namespace))
|
||||
|
||||
|
@ -49,65 +43,58 @@
|
|||
|
||||
(define ((enter-load/use-compiled orig re?) path name)
|
||||
(if name
|
||||
;; Module load:
|
||||
(let ([code (get-module-code path
|
||||
"compiled"
|
||||
(lambda (e)
|
||||
(parameterize ([compile-enforce-module-constants #f])
|
||||
(compile e)))
|
||||
(lambda (ext loader?)
|
||||
(load-extension ext)
|
||||
#f)
|
||||
#:notify (lambda (chosen)
|
||||
(notify re? chosen)))]
|
||||
[path (normal-case-path
|
||||
(simplify-path
|
||||
(path->complete-path path
|
||||
(or (current-load-relative-directory)
|
||||
(current-directory)))))])
|
||||
;; Record module timestamp and dependencies:
|
||||
(let ([a-mod (mod name
|
||||
(get-timestamp path)
|
||||
(if code
|
||||
(apply append
|
||||
(map cdr (module-compiled-imports code)))
|
||||
null))])
|
||||
(hash-set! loaded path a-mod))
|
||||
;; Evaluate the module:
|
||||
(eval code))
|
||||
;; Not a module:
|
||||
(begin
|
||||
(notify re? path)
|
||||
(orig path name))))
|
||||
;; Module load:
|
||||
(let* ([code (get-module-code
|
||||
path "compiled"
|
||||
(lambda (e)
|
||||
(parameterize ([compile-enforce-module-constants #f])
|
||||
(compile e)))
|
||||
(lambda (ext loader?)
|
||||
(load-extension ext)
|
||||
#f)
|
||||
#:notify (lambda (chosen) (notify re? chosen)))]
|
||||
[dir (or (current-load-relative-directory) (current-directory))]
|
||||
[path (path->complete-path path dir)]
|
||||
[path (normal-case-path (simplify-path path))])
|
||||
;; Record module timestamp and dependencies:
|
||||
(let ([a-mod (mod name
|
||||
(get-timestamp path)
|
||||
(if code
|
||||
(append-map cdr (module-compiled-imports code))
|
||||
null))])
|
||||
(hash-set! loaded path a-mod))
|
||||
;; Evaluate the module:
|
||||
(eval code))
|
||||
;; Not a module:
|
||||
(begin
|
||||
(notify re? path)
|
||||
(orig path name))))
|
||||
|
||||
(define (get-timestamp path)
|
||||
(let ([v (file-or-directory-modify-seconds path #f (lambda () -inf.0))])
|
||||
(if (and (equal? v -inf.0)
|
||||
(regexp-match? #rx#"[.]rkt$" (path->bytes path)))
|
||||
(file-or-directory-modify-seconds (path-replace-suffix path #".ss")
|
||||
#f
|
||||
(lambda () -inf.0))
|
||||
v)))
|
||||
(file-or-directory-modify-seconds path #f
|
||||
(lambda ()
|
||||
(if (regexp-match? #rx#"[.]rkt$" (path->bytes path))
|
||||
(file-or-directory-modify-seconds
|
||||
(path-replace-suffix path #".ss") #f (lambda () -inf.0))
|
||||
-inf.0))))
|
||||
|
||||
(define (check-latest mod)
|
||||
(let ([mpi (module-path-index-join mod #f)]
|
||||
[done (make-hash)])
|
||||
(let loop ([mpi mpi])
|
||||
(let* ([rpath (module-path-index-resolve mpi)]
|
||||
[path (resolved-module-path-name rpath)])
|
||||
(when (path? path)
|
||||
(let ([path (normal-case-path path)])
|
||||
(unless (hash-ref done path #f)
|
||||
(hash-set! done path #t)
|
||||
(let ([mod (hash-ref loaded path #f)])
|
||||
(when mod
|
||||
(for-each loop (mod-depends mod))
|
||||
(let ([ts (get-timestamp path)])
|
||||
(when (ts . > . (mod-timestamp mod))
|
||||
(let ([orig (current-load/use-compiled)])
|
||||
(parameterize ([current-load/use-compiled
|
||||
(enter-load/use-compiled orig #f)]
|
||||
[current-module-declare-name rpath])
|
||||
((enter-load/use-compiled orig #t)
|
||||
path
|
||||
(mod-name mod)))))))))))))))
|
||||
(define mpi (module-path-index-join mod #f))
|
||||
(define done (make-hash))
|
||||
(let loop ([mpi mpi])
|
||||
(define rpath (module-path-index-resolve mpi))
|
||||
(define path (resolved-module-path-name rpath))
|
||||
(when (path? path)
|
||||
(define npath (normal-case-path path))
|
||||
(unless (hash-ref done npath #f)
|
||||
(hash-set! done npath #t)
|
||||
(define mod (hash-ref loaded npath #f))
|
||||
(when mod
|
||||
(for-each loop (mod-depends mod))
|
||||
(define ts (get-timestamp npath))
|
||||
(when (ts . > . (mod-timestamp mod))
|
||||
(define orig (current-load/use-compiled))
|
||||
(parameterize ([current-load/use-compiled
|
||||
(enter-load/use-compiled orig #f)]
|
||||
[current-module-declare-name rpath])
|
||||
((enter-load/use-compiled orig #t) npath (mod-name mod)))))))))
|
||||
|
|
Loading…
Reference in New Issue
Block a user