
The intent is to support phase-crossing data such as the `exn:fail:syntax'
structure type that is instantiaed by macros and recognized by contexts
that use `eval' or `expand'. Phaseless modules are highly constrained,
however, to avoid new cross-phase channels, and a module is inferred to
be phaseless when it fits syntactic constraints.
I've adjusted `racket/kernel' and improved its documentation a little
so that it can be used to implement a phaseless module (which can
import only from other phaseless modules).
This change also adds a `flags' field to the `mod' structure type
from `compiler/zo-structs'.
original commit: 899a3279c2
42 lines
1.2 KiB
Racket
42 lines
1.2 KiB
Racket
#lang racket/base
|
|
|
|
(require racket/list
|
|
racket/match
|
|
racket/contract
|
|
compiler/zo-parse
|
|
"util.rkt")
|
|
|
|
(define (->module-path-index s)
|
|
(if (module-path-index? s)
|
|
s
|
|
(module-path-index-join `(quote ,s) #f)))
|
|
|
|
(define (wrap-in-kernel-module name srcname lang-info self-modidx top)
|
|
(match top
|
|
[(struct compilation-top (max-let-depth prefix form))
|
|
(define-values (reqs new-forms)
|
|
(partition req? (splice-forms form)))
|
|
(define requires
|
|
(map (compose ->module-path-index wrapped-datum stx-encoded req-reqs) reqs))
|
|
(make-compilation-top
|
|
0
|
|
(make-prefix 0 (list #f) empty)
|
|
(make-mod name srcname
|
|
self-modidx
|
|
prefix
|
|
empty ; provides
|
|
(list (cons 0 requires))
|
|
new-forms
|
|
empty ; syntax-body
|
|
(list) ; unexported
|
|
max-let-depth
|
|
(make-toplevel 0 0 #f #f) ; dummy
|
|
lang-info
|
|
#t
|
|
empty
|
|
empty
|
|
empty))]))
|
|
|
|
(provide/contract
|
|
[wrap-in-kernel-module (symbol? symbol? lang-info/c module-path-index? compilation-top? . -> . compilation-top?)])
|