fix compile-zos for modules

svn: r12347
This commit is contained in:
Matthew Flatt 2008-11-07 23:21:02 +00:00
parent 7479f59e13
commit c1a10edaff
3 changed files with 32 additions and 15 deletions

View File

@ -98,7 +98,7 @@
(define compile-c-extensions
(make-unprefixed-compiler 'compile-c-extension))
(define (compile-to-zo src dest namespace eval?)
(define (compile-to-zo src dest namespace eval? verbose? mod?)
((if eval?
(lambda (t) (parameterize ([read-accept-reader #t])
(t)))
@ -106,13 +106,23 @@
(lambda ()
(parameterize ([current-namespace namespace])
(compile-file src dest
(if eval?
(lambda (expr)
(expand-syntax-top-level-with-compile-time-evals expr))
values)))))
(printf " [output to \"~a\"]\n" dest))
(compose
(if eval?
(lambda (expr)
(expand-syntax-top-level-with-compile-time-evals expr))
values)
(if mod?
(lambda (expr)
(check-module-form expr
(let-values ([(base name dir?) (split-path src)])
(string->symbol
(path-element->string (path-replace-suffix name #""))))
src))
values))))))
(when verbose?
(printf " [output to \"~a\"]\n" dest)))
(define (compile-zos prefix)
(define (compile-zos prefix #:verbose? [verbose? #f] #:module? [mod? #f])
(define n (if prefix (make-base-namespace) (current-namespace)))
(when prefix (eval prefix n))
(lambda (source-files destination-directory)
@ -132,7 +142,7 @@
source-files))
(for ([f source-files] [b file-bases])
(let ([zo (append-zo-suffix b)])
(compile-to-zo f zo n prefix)))))
(compile-to-zo f zo n prefix verbose? mod?)))))
(define (compile-directory dir info #:verbose [verbose? #t])
(define info* (or info (lambda (key mk-default) (mk-default))))

View File

@ -432,7 +432,7 @@
[(compile-c)
((compile-extensions-to-c prefix) source-files (dest-dir))]
[(zo)
((compile-zos prefix)
((compile-zos prefix #:verbose? (compiler:option:somewhat-verbose))
source-files
(if (auto-dest-dir) 'auto (dest-dir)))]
[(expand)

View File

@ -23,7 +23,7 @@ through a Scheme API.}
@section[#:tag "api:zo"]{Bytecode Compilation}
@defproc[((compile-zos [expr any/c])
@defproc[((compile-zos [expr any/c] [#:module? module? any/c #f] [#:verbose? verbose? any/c #f])
[scheme-files (listof path-string?)]
[dest-dir (or/c path-string? false/c (one-of/c 'auto))])
void?]{
@ -41,7 +41,7 @@ subdirectory relative to the source; the directory is created if
necessary.
If @scheme[expr] is anything other than @scheme[#f], then a namespace
is created for compiling the files that are supplied later;
is created for compiling the files that are supplied later, and
@scheme[expr] is evaluated to initialize the created namespace. For
example, @scheme[expr] might load a set of macros. In addition, the
expansion-time part of each expression later compiled is evaluated in
@ -49,13 +49,20 @@ the namespace before being compiled, so that the effects are visible
when compiling later expressions.
If @scheme[expr] is @scheme[#f], then no compilation namespace is
created, and expressions in the files are assumed to compile
independently (so there's no need to evaluate the expansion-time part
of an expression to compile).
created (the current namespace is used), and expressions in the files
are assumed to compile independently (so there's no need to evaluate
the expansion-time part of an expression to compile).
Typically, @scheme[expr] is @scheme[#f] for compiling @scheme[module]
files, and it is @scheme[(void)] for compiling files with top-level
definitions and expressions.}
definitions and expressions.
If @scheme[module?] is @scheme[#t], then the given files are read and
compiled as modules (so there is no dependency on the current
namespace's top-level environment).
If @scheme[verbose?] is @scheme[#t], the output file for each given
file is reported through the current output port.}
@defproc[(compile-collection-zos [collection string?] ...+)