From 8a2cb61fd7df5faa59cfe417c0d3cb80053e6d69 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 26 Feb 2006 17:45:37 +0000 Subject: [PATCH] make serialization work right when a module is dynamic-required using a (non-string) path svn: r2321 original commit: d9e3e1e2679fe7dac1972d417be44b70a177cb40 --- collects/mzlib/serialize.ss | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/collects/mzlib/serialize.ss b/collects/mzlib/serialize.ss index 22c3031..3d39d6d 100644 --- a/collects/mzlib/serialize.ss +++ b/collects/mzlib/serialize.ss @@ -423,6 +423,18 @@ (void? v) (date? v) (arity-at-least? v))) + + ;; If a module is dynamic-required through a path, + ;; then it can cause simplified module paths to be paths; + ;; keep the literal path, but marshal it to bytes. + (define (protect-path p) + (if (path? p) + (path->bytes p) + p)) + (define (unprotect-path p) + (if (bytes? p) + (bytes->path p) + p)) (define (mod-to-id info mod-map cache) (let ([deserialize-id (serialize-info-deserialize-id info)]) @@ -438,10 +450,11 @@ (and (list? b) (if (symbol? (caddr b)) (caddr b) - (collapse-module-path-index - (caddr b) - `(file ,(build-path (serialize-info-dir info) - "here.ss"))))) + (protect-path + (collapse-module-path-index + (caddr b) + (build-path (serialize-info-dir info) + "here.ss"))))) (syntax-e deserialize-id)))] [(symbol? deserialize-id) (cons #f deserialize-id)] @@ -449,10 +462,11 @@ (cons (if (symbol? (cdr deserialize-id)) (cdr deserialize-id) - (collapse-module-path-index - (cdr deserialize-id) - `(file ,(build-path (serialize-info-dir info) - "here.ss")))) + (protect-path + (collapse-module-path-index + (cdr deserialize-id) + (build-path (serialize-info-dir info) + "here.ss")))) (car deserialize-id))])]) (hash-table-get mod-map path+name @@ -818,7 +832,8 @@ (unless (null? l) (let* ([path+name (car l)] [des (if (car path+name) - (dynamic-require (car path+name) (cdr path+name)) + (dynamic-require (unprotect-path (car path+name)) + (cdr path+name)) (namespace-variable-value (cdr path+name)))]) ;; Register maker and struct type: (vector-set! mod-map n des))