[racket] module-path-index and self-paths
As an aside, in the demodularizer, we go out of our way to never make
any new modpaths, we just keep track of the original ones and put them
back in the new structs.
Jay
2011/5/10 Danny Yoo <dyoo at cs.wpi.edu>:
> I'm trying to trace down a bug in my code down to a user of
> module-path-index-resolve. I'm somehow getting a hold of a
> module-path-index with the following structure:
>
> (module-path-index-join "private/base.rkt"
> (module-path-index-join #f #f))
>
>
> When given this, module-path-index-resolve errors out and says:
>
> module-path-index-resolve: "self" index has no resolution:
> #<module-path-index>
>
>
> I'm trying to figure out if I'm misusing module-path-index-resolve. I
> am getting this particular module path index by zo-parsing
> collects/racket/base.rkt and looking into its phase-0 requires.
>
> Here is code to demonstrate where the value is coming from:
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> #lang racket
> (require racket/match
> compiler/zo-parse)
>
> (define (run-zo-parse path)
> (parameterize ([current-namespace (make-base-namespace)]
> [read-accept-reader #t]
> [current-directory
> (let-values ([(base file is-dir)
> (split-path path)])
> base)])
> (let ([bc (compile (read (open-input-file path)))]
> [op (open-output-bytes)])
> (write bc op)
> (zo-parse (open-input-bytes (get-output-bytes op))))))
>
>
> ;; Splits up a module path index into its components.
> (define (explode-module-path-index mpi)
> (let-values ([(x y) (module-path-index-split mpi)])
> (cond
> [(module-path-index? y)
> (cons x (explode-module-path-index y))]
> [else
> (list x y)])))
>
>
> (match (run-zo-parse (build-path (find-system-path 'collects-dir)
> "racket"
> "base.rkt"))
> [(struct compilation-top (_
> _
> (struct mod (_ _ _ _ _ requires _ _ _ _ _ _ _))))
> (for ([phase-and-paths requires])
> (when (equal? (car phase-and-paths) 0)
> (displayln (map explode-module-path-index (cdr phase-and-paths)))))])
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
>
> The second element in the list value that displays:
>
> ((racket/private/pre-base #f) (private/base.rkt #f #f))
>
> is the module-path-index that I don't quite know how to resolve into a
> nice resolved-module-path.
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users
>
--
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay
"The glory of God is Intelligence" - D&C 93