racket/collects/compiler/demodularizer/mpi.rkt
Eli Barzilay f90858601d A long overdue scan to eliminate files without terminating newlines.
(DrRacket should really do that.)

original commit: 40124a0619
2011-06-28 02:01:41 -04:00

32 lines
875 B
Racket

#lang racket
(require syntax/modresolve)
(define current-module-path (make-parameter #f))
(define (mpi->string modidx)
(cond
[(symbol? modidx) modidx]
[else
(mpi->path! modidx)]))
(define MODULE-PATHS (make-parameter #f))
(define (mpi->path! mpi)
(hash-ref!
(MODULE-PATHS) mpi
(lambda ()
(define _pth
(resolve-module-path-index mpi (current-module-path)))
(if (path? _pth)
(simplify-path _pth #t)
_pth))))
(define (mpi->path* mpi)
(hash-ref (MODULE-PATHS) mpi
(lambda ()
(error 'mpi->path* "Cannot locate cache of path for ~S" mpi))))
(provide/contract
[MODULE-PATHS (parameter/c (or/c false/c hash?))]
[current-module-path (parameter/c path-string?)]
[mpi->path! (module-path-index? . -> . (or/c symbol? path?))]
[mpi->path* (module-path-index? . -> . (or/c symbol? path?))])