fix mistakes in augment corrections; fix runtime-path handling of lib paths

svn: r11577
This commit is contained in:
Matthew Flatt 2008-09-08 19:44:32 +00:00
parent 74addc1b71
commit 1a8b6cb824
3 changed files with 39 additions and 18 deletions

View File

@ -1,22 +1,25 @@
(module runtime-path mzscheme (module runtime-path scheme/base
(require mzlib/etc (require mzlib/etc
syntax/modcollapse syntax/modcollapse
setup/dirs setup/dirs
(only "private/runtime-path-table.ss" table)) scheme/list
scheme/string
(only-in "private/runtime-path-table.ss" table)
(for-syntax scheme/base))
(provide define-runtime-path (provide define-runtime-path
define-runtime-paths define-runtime-paths
define-runtime-path-list define-runtime-path-list
runtime-paths) runtime-paths)
(define-for-syntax ext-file-table (make-hash-table)) (define-for-syntax ext-file-table (make-hasheq))
(define (lookup-in-table tag-stx p) (define (lookup-in-table tag-stx p)
;; This function is designed to cooperate with a table embedded ;; This function is designed to cooperate with a table embedded
;; in an executable by create-embedding-executable. ;; in an executable by create-embedding-executable.
(let ([mpi (syntax-source-module tag-stx)]) (let ([mpi (syntax-source-module tag-stx)])
(let ([p (hash-table-get (let ([p (hash-ref
table table
(cons (cond (cons (cond
[(module-path-index? mpi) [(module-path-index? mpi)
@ -71,10 +74,16 @@
((length p) . > . 1) ((length p) . > . 1)
(eq? 'lib (car p)) (eq? 'lib (car p))
(andmap string? (cdr p))) (andmap string? (cdr p)))
(let ([dir (if (null? (cddr p)) (let* ([strs (regexp-split #rx"/"
(collection-path "mzlib") (let ([s (cadr p)])
(apply collection-path (cddr p)))]) (if (regexp-match? #rx"[./]" s)
(build-path dir (cadr p)))] s
(string-append s "/main.ss"))))]
[dir (if (and (null? (cddr p))
(null? (cdr strs)))
(collection-path "mzlib")
(apply collection-path (append (cddr p) (drop-right strs 1))))])
(build-path dir (last strs)))]
[else (error 'runtime-path "unknown form: ~e" p)]))) [else (error 'runtime-path "unknown form: ~e" p)])))
paths))) paths)))
@ -85,8 +94,8 @@
[(symbol? mpi) mpi] [(symbol? mpi) mpi]
[else (error 'register-ext-files [else (error 'register-ext-files
"cannot determine source")])]) "cannot determine source")])])
(let ([files (hash-table-get ext-file-table modname null)]) (let ([files (hash-ref ext-file-table modname null)])
(hash-table-put! ext-file-table modname (append paths files)))))) (hash-set! ext-file-table modname (append paths files))))))
(define-syntax (-define-runtime-path stx) (define-syntax (-define-runtime-path stx)
(syntax-case stx () (syntax-case stx ()
@ -101,12 +110,12 @@
#'orig-stx #'orig-stx
id))) id)))
ids) ids)
(let ([tag (datum->syntax-object #'orig-stx 'tag #'orig-stx)]) (let ([tag (datum->syntax #'orig-stx 'tag #'orig-stx)])
#`(begin #`(begin
(define-values (id ...) (define-values (id ...)
(let-values ([(id ...) expr]) (let-values ([(id ...) expr])
(let ([get-dir (lambda () (let ([get-dir (lambda ()
#,(datum->syntax-object #,(datum->syntax
tag tag
`(,#'this-expression-source-directory) `(,#'this-expression-source-directory)
tag))]) tag))])
@ -135,10 +144,10 @@
(syntax-case stx () (syntax-case stx ()
[(_ mp) [(_ mp)
#`(quote #`(quote
#,(hash-table-get #,(hash-ref
ext-file-table ext-file-table
(module-path-index-resolve (module-path-index-join (module-path-index-resolve (module-path-index-join
(syntax-object->datum #'mp) (syntax->datum #'mp)
(syntax-source-module stx))) (syntax-source-module stx)))
null))])) null))]))

View File

@ -1837,7 +1837,7 @@
[no-method-changes? (and (null? public-names) [no-method-changes? (and (null? public-names)
(null? override-names) (null? override-names)
(null? augride-names) (null? augride-names)
(null? overment-names))] (null? final-names))]
[no-new-fields? (null? public-field-names)] [no-new-fields? (null? public-field-names)]
[xappend (lambda (a b) (if (null? b) a (append a b)))]) [xappend (lambda (a b) (if (null? b) a (append a b)))])
@ -2193,7 +2193,8 @@
(let ([v (list->vector (vector->list v))]) (let ([v (list->vector (vector->list v))])
(vector-set! v (sub1 (vector-length v)) method) (vector-set! v (sub1 (vector-length v)) method)
(vector-set! beta-methods index v)))) (vector-set! beta-methods index v))))
(vector-set! meth-flags index (not make-struct:prim))) (when (not (vector-ref meth-flags index))
(vector-set! meth-flags index (not make-struct:prim))))
(append replace-augonly-indices replace-final-indices replace-normal-indices (append replace-augonly-indices replace-final-indices replace-normal-indices
refine-augonly-indices refine-final-indices refine-normal-indices) refine-augonly-indices refine-final-indices refine-normal-indices)
(append override-methods augride-methods) (append override-methods augride-methods)
@ -2205,7 +2206,7 @@
(append overment-names pubment-names)) (append overment-names pubment-names))
(for-each (lambda (id) (for-each (lambda (id)
(vector-set! meth-flags (hash-ref method-ht id) #t)) (vector-set! meth-flags (hash-ref method-ht id) #t))
augride-names)) augride-normal-names))
;; Expand `rename-inner' vector, adding a #f to indicate that ;; Expand `rename-inner' vector, adding a #f to indicate that
;; no rename-inner function is available, so far ;; no rename-inner function is available, so far
(for-each (lambda (id) (for-each (lambda (id)

View File

@ -111,6 +111,17 @@
(define (x) 1) (define (x) 1)
(define (y) 1))) (define (y) 1)))
(define to-override3-class%
(class to-override2-class%
(oevrride x y)
(define (x) 1)
(define (y) 1)))
(define to-augment3-class%
(class to-augment2-class%
(augment x y)
(define (x) 1)
(define (y) 1)))
(define (test-method basic? public object% over? aug? super-ok? inner-ok? over-ok? aug-ok?) (define (test-method basic? public object% over? aug? super-ok? inner-ok? over-ok? aug-ok?)
(when basic? (when basic?
(teval #`(test #t class? (class #,object% (#,public)))) (teval #`(test #t class? (class #,object% (#,public))))
@ -139,7 +150,6 @@
(begin (begin
(teval #`(err/rt-test (class #,object% (#,public (x x)) (define (x) 1)) exn:fail:object?)) (teval #`(err/rt-test (class #,object% (#,public (x x)) (define (x) 1)) exn:fail:object?))
(teval #`(err/rt-test (class #,object% (#,public (x y) (y x)) (define (x) 1) (define (y) 2)) exn:fail:object?))))) (teval #`(err/rt-test (class #,object% (#,public (x y) (y x)) (define (x) 1) (define (y) 2)) exn:fail:object?)))))
;; Use of external name for super/inner is always wrong (but ;; Use of external name for super/inner is always wrong (but
;; maybe because super/inner isn't allowed): ;; maybe because super/inner isn't allowed):
@ -196,6 +206,7 @@
(test-over/aug #'to-override-class% #'to-augment-class%) (test-over/aug #'to-override-class% #'to-augment-class%)
(test-over/aug #'to-override2-class% #'to-augment2-class%) (test-over/aug #'to-override2-class% #'to-augment2-class%)
(test-over/aug #'to-override3-class% #'to-augment3-class%)
(define (test-rename rename object%) (define (test-rename rename object%)
(teval #`(test #t class? (class #,object% (#,rename)))) (teval #`(test #t class? (class #,object% (#,rename))))