trying to add a hook into the maker to deal with js-implemented modules.
This commit is contained in:
parent
433ec3f044
commit
f3a28e26ef
|
@ -48,12 +48,12 @@
|
||||||
should-follow?
|
should-follow?
|
||||||
|
|
||||||
;; on
|
;; on
|
||||||
(lambda (ast stmts)
|
(lambda (src ast stmts)
|
||||||
(assemble/write-invoke stmts op)
|
(assemble/write-invoke stmts op)
|
||||||
(fprintf op "(MACHINE, function() { "))
|
(fprintf op "(MACHINE, function() { "))
|
||||||
|
|
||||||
;; after
|
;; after
|
||||||
(lambda (ast stmts)
|
(lambda (src ast stmts)
|
||||||
(fprintf op " }, FAIL, PARAMS);"))
|
(fprintf op " }, FAIL, PARAMS);"))
|
||||||
|
|
||||||
;; last
|
;; last
|
||||||
|
@ -96,7 +96,7 @@ EOF
|
||||||
(define (get-code source-code)
|
(define (get-code source-code)
|
||||||
(let ([buffer (open-output-string)])
|
(let ([buffer (open-output-string)])
|
||||||
(package source-code
|
(package source-code
|
||||||
#:should-follow? (lambda (p) #t)
|
#:should-follow? (lambda (src p) #t)
|
||||||
#:output-port buffer)
|
#:output-port buffer)
|
||||||
(get-output-string buffer)))
|
(get-output-string buffer)))
|
||||||
|
|
||||||
|
|
|
@ -34,11 +34,13 @@
|
||||||
|
|
||||||
|
|
||||||
(define-struct: Configuration
|
(define-struct: Configuration
|
||||||
([should-follow? : (Path -> Boolean)]
|
([should-follow? : (Source Path -> Boolean)]
|
||||||
[on-module-statements : ((U Expression #f)
|
[on-module-statements : (Source
|
||||||
|
(U Expression #f)
|
||||||
(Listof Statement)
|
(Listof Statement)
|
||||||
-> Void)]
|
-> Void)]
|
||||||
[after-module-statements : ((U Expression #f)
|
[after-module-statements : (Source
|
||||||
|
(U Expression #f)
|
||||||
(Listof Statement)
|
(Listof Statement)
|
||||||
-> Void)]
|
-> Void)]
|
||||||
[after-last : (-> Void)])
|
[after-last : (-> Void)])
|
||||||
|
@ -46,12 +48,12 @@
|
||||||
|
|
||||||
(define debug-configuration
|
(define debug-configuration
|
||||||
(make-Configuration
|
(make-Configuration
|
||||||
(lambda (p) #t)
|
(lambda (src p) #t)
|
||||||
(lambda (ast stmt)
|
(lambda (src ast stmt)
|
||||||
(when (and ast (expression-module-path ast))
|
(when (and ast (expression-module-path ast))
|
||||||
(printf "debug build configuration: visiting ~s\n"
|
(printf "debug build configuration: visiting ~s\n"
|
||||||
(expression-module-path ast))))
|
(expression-module-path ast))))
|
||||||
(lambda (ast stmt)
|
(lambda (src ast stmt)
|
||||||
(void))
|
(void))
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(void))))
|
(void))))
|
||||||
|
|
33
make.rkt
33
make.rkt
|
@ -22,9 +22,18 @@
|
||||||
|
|
||||||
|
|
||||||
(provide make
|
(provide make
|
||||||
|
current-module-source-compiling-hook
|
||||||
get-ast-and-statements)
|
get-ast-and-statements)
|
||||||
|
|
||||||
|
|
||||||
|
(: current-module-source-compiling-hook
|
||||||
|
(Parameterof (Source -> Source)))
|
||||||
|
(define current-module-source-compiling-hook
|
||||||
|
(make-parameter (lambda: ([s : Source]) s)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(: get-ast-and-statements (Source -> (values (U False Expression)
|
(: get-ast-and-statements (Source -> (values (U False Expression)
|
||||||
(Listof Statement))))
|
(Listof Statement))))
|
||||||
|
@ -100,11 +109,11 @@
|
||||||
(define visited ((inst make-hash Any Boolean)))
|
(define visited ((inst make-hash Any Boolean)))
|
||||||
|
|
||||||
(: collect-new-dependencies
|
(: collect-new-dependencies
|
||||||
((U False Expression) (Listof Source) -> (Listof Source)))
|
(Source (U False Expression) -> (Listof Source)))
|
||||||
(define (collect-new-dependencies ast sources)
|
(define (collect-new-dependencies this-source ast)
|
||||||
(cond
|
(cond
|
||||||
[(eq? ast #f)
|
[(eq? ast #f)
|
||||||
sources]
|
empty]
|
||||||
[else
|
[else
|
||||||
(let* ([dependent-module-names (get-dependencies ast)]
|
(let* ([dependent-module-names (get-dependencies ast)]
|
||||||
[paths
|
[paths
|
||||||
|
@ -116,14 +125,14 @@
|
||||||
mp)
|
mp)
|
||||||
acc]
|
acc]
|
||||||
[(and (path? rp)
|
[(and (path? rp)
|
||||||
(should-follow? rp)
|
(should-follow? this-source rp)
|
||||||
(cons (make-ModuleSource rp)
|
(cons (make-ModuleSource rp)
|
||||||
acc))]
|
acc))]
|
||||||
[else
|
[else
|
||||||
acc])))
|
acc])))
|
||||||
'()
|
'()
|
||||||
dependent-module-names)])
|
dependent-module-names)])
|
||||||
(append paths sources))]))
|
paths)]))
|
||||||
|
|
||||||
(let: loop : Void ([sources : (Listof Source) sources])
|
(let: loop : Void ([sources : (Listof Source) sources])
|
||||||
(cond
|
(cond
|
||||||
|
@ -133,11 +142,15 @@
|
||||||
(loop (rest sources))]
|
(loop (rest sources))]
|
||||||
[else
|
[else
|
||||||
(hash-set! visited (first sources) #t)
|
(hash-set! visited (first sources) #t)
|
||||||
(let-values ([(ast stmts)
|
(let*-values ([(this-source)
|
||||||
(get-ast-and-statements (first sources))])
|
((current-module-source-compiling-hook)
|
||||||
(on-module-statements ast stmts)
|
(first sources))]
|
||||||
(loop (collect-new-dependencies ast (rest sources)))
|
[(ast stmts)
|
||||||
(after-module-statements ast stmts))])))
|
(get-ast-and-statements this-source)])
|
||||||
|
(on-module-statements this-source ast stmts)
|
||||||
|
(loop (append (collect-new-dependencies this-source ast)
|
||||||
|
(rest sources)))
|
||||||
|
(after-module-statements this-source ast stmts))])))
|
||||||
|
|
||||||
(follow-dependencies sources)])))
|
(follow-dependencies sources)])))
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,9 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;; Do not touch the following parameters: they're used internally by package
|
;;; Do not touch the following parameters: they're used internally by package
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user