|
|
@ -1,29 +1,30 @@
|
|
|
|
#lang racket/base
|
|
|
|
#lang racket/base
|
|
|
|
(require racket/rerequire racket/contract)
|
|
|
|
(require racket/rerequire)
|
|
|
|
|
|
|
|
;(require racket/contract)
|
|
|
|
(require "debug.rkt" sugar/coerce)
|
|
|
|
(require "debug.rkt" sugar/coerce)
|
|
|
|
|
|
|
|
|
|
|
|
(provide current-cache make-cache cached-require get-cache-hash)
|
|
|
|
(provide current-cache make-cache cached-require get-cache-hash)
|
|
|
|
|
|
|
|
|
|
|
|
(define current-cache (make-parameter #f))
|
|
|
|
(define current-cache (make-parameter #f))
|
|
|
|
|
|
|
|
|
|
|
|
(define/contract (path-string->path path-string)
|
|
|
|
(define (path-string->path path-string)
|
|
|
|
(path-string? . -> . complete-path?)
|
|
|
|
; (path-string? . -> . complete-path?)
|
|
|
|
(->complete-path (if (string? path-string) (string->path path-string) path-string)))
|
|
|
|
(->complete-path (if (string? path-string) (string->path path-string) path-string)))
|
|
|
|
|
|
|
|
|
|
|
|
(define/contract (make-cache)
|
|
|
|
(define (make-cache)
|
|
|
|
( -> hash?)
|
|
|
|
; ( -> hash?)
|
|
|
|
(make-hash))
|
|
|
|
(make-hash))
|
|
|
|
|
|
|
|
|
|
|
|
(define/contract (get-cache-hash path-string)
|
|
|
|
(define (get-cache-hash path-string)
|
|
|
|
(path-string? . -> . hash?)
|
|
|
|
; (path-string? . -> . hash?)
|
|
|
|
(hash-ref (current-cache) (path-string->path path-string)))
|
|
|
|
(hash-ref (current-cache) (path-string->path path-string)))
|
|
|
|
|
|
|
|
|
|
|
|
(define/contract (cache-ref path sym)
|
|
|
|
(define (cache-ref path sym)
|
|
|
|
(path? symbol? . -> . any/c)
|
|
|
|
; (path? symbol? . -> . any/c)
|
|
|
|
(hash-ref (get-cache-hash path) sym))
|
|
|
|
(hash-ref (get-cache-hash path) sym))
|
|
|
|
|
|
|
|
|
|
|
|
(define/contract (cached-require path-string sym)
|
|
|
|
(define (cached-require path-string sym)
|
|
|
|
(path-string? symbol? . -> . any/c)
|
|
|
|
; (path-string? symbol? . -> . any/c)
|
|
|
|
(when (not (current-cache)) (error "cached-require: No cache set up."))
|
|
|
|
(when (not (current-cache)) (error "cached-require: No cache set up."))
|
|
|
|
|
|
|
|
|
|
|
|
(define path (path-string->path path-string))
|
|
|
|
(define path (path-string->path path-string))
|
|
|
|