Port render-test-list.scm and helpers to use new-style units.

svn: r5035
This commit is contained in:
Sam Tobin-Hochstadt 2006-12-05 22:51:47 +00:00
parent 3459c3a58f
commit 2b876b1f11
5 changed files with 1163 additions and 1166 deletions

File diff suppressed because it is too large Load Diff

View File

@ -5,123 +5,124 @@
"update-binding-counts.scm" "update-binding-counts.scm"
"render-helpers.ss" "render-helpers.ss"
"render-sigs.ss" "render-sigs.ss"
(lib "unitsig.ss")) (lib "unit.ss"))
(require-for-template mzscheme) (require-for-template mzscheme)
(define getbindings@ (define-unit getbindings@
(unit/sig getbindings^ (import render-test-list^) (import render-test-list^)
(export getbindings^)
;;!(function next-outer
;; (form (next-outer p ae sf bv let-bound kf ks syntax bool) ;;!(function next-outer
;; -> ;; (form (next-outer p ae sf bv let-bound kf ks syntax bool)
;; syntax) ;; ->
;; (contract (syntax syntax list list list (list list -> syntax) ;; syntax)
;; (list list -> syntax) syntax bool) ;; (contract (syntax syntax list list list (list list -> syntax)
;; -> ;; (list list -> syntax) syntax bool)
;; syntax)) ;; ->
;; The function next-outer is basically a throw-back to the next ;; syntax))
;; function of the original match compiler. It compiles a pattern ;; The function next-outer is basically a throw-back to the next
;; or sub-pattern of a clause and does not yield a list of ;; function of the original match compiler. It compiles a pattern
;; partially compiled test structs. This function is called ;; or sub-pattern of a clause and does not yield a list of
;; inside of test constructs that cannot be eliminated because of ;; partially compiled test structs. This function is called
;; a related presence in the test-so-far list. So, instead of ;; inside of test constructs that cannot be eliminated because of
;; partially compiling patterns this function fully compiles patterns. ;; a related presence in the test-so-far list. So, instead of
(define/opt (next-outer ;; partially compiling patterns this function fully compiles patterns.
p (define/opt (next-outer
ae ;; this is the actual expression p
sf ae ;; this is the actual expression
bv sf
let-bound bv
kf let-bound
ks kf
cert ks
[stx (syntax '())]) cert
(next-outer-helper p ae sf bv let-bound [stx (syntax '())])
(lambda (x) kf) (lambda (a b) ks) cert stx)) (next-outer-helper p ae sf bv let-bound
(lambda (x) kf) (lambda (a b) ks) cert stx))
;;!(function next-outer-helper
;; (form (next-outer p ae sf bv let-bound kf-func ks-func syntax bool) ;;!(function next-outer-helper
;; -> ;; (form (next-outer p ae sf bv let-bound kf-func ks-func syntax bool)
;; syntax) ;; ->
;; (contract (syntax syntax list list list (list list -> syntax) ;; syntax)
;; (list list -> syntax) syntax bool) ;; (contract (syntax syntax list list list (list list -> syntax)
;; -> ;; (list list -> syntax) syntax bool)
;; syntax)) ;; ->
;; The function next-outer-helper contains the meat of next-outer ;; syntax))
;; and allows the programmer to pass higher order functions ;; The function next-outer-helper contains the meat of next-outer
;; ks-func and kf-func that will be given compile time imformation ;; and allows the programmer to pass higher order functions
;; about let-bindings etc. which in turn will allow the programmer ;; ks-func and kf-func that will be given compile time imformation
;; to take advantage of this info. ;; about let-bindings etc. which in turn will allow the programmer
(define/opt (next-outer-helper ;; to take advantage of this info.
p (define/opt (next-outer-helper
ae ;; this is the actual expression p
sf ae ;; this is the actual expression
bv sf
let-bound bv
kf-func let-bound
ks-func kf-func
cert ks-func
[stx (syntax '())]) cert
;; right now this does not bind new variables [stx (syntax '())])
(let ((rendered-list (render-test-list p ae cert stx))) ;; right now this does not bind new variables
;; no need to reorder lists although I suspect that it may be (let ((rendered-list (render-test-list p ae cert stx)))
;; better to put shape tests first ;; no need to reorder lists although I suspect that it may be
(update-binding-count rendered-list) ;; better to put shape tests first
((couple-tests rendered-list ks-func kf-func let-bound) sf bv))) (update-binding-count rendered-list)
((couple-tests rendered-list ks-func kf-func let-bound) sf bv)))
;;!(function create-test-func
;; (form (create-test-func p sf let-bound bind-map last-test) ;;!(function create-test-func
;; -> ;; (form (create-test-func p sf let-bound bind-map last-test)
;; syntax) ;; ->
;; (contract (syntax list list a-list bool) -> syntax)) ;; syntax)
;; This function creates a runtime function that is used as an ;; (contract (syntax list list a-list bool) -> syntax))
;; individual test in a list of tests for the list-no-order ;; This function creates a runtime function that is used as an
;; pattern. ;; individual test in a list of tests for the list-no-order
;; <pre> ;; pattern.
;; bindmap - a-list of bindings mapped to their expressions ;; <pre>
;; last-test - a boolean value that indicates whether this function ;; bindmap - a-list of bindings mapped to their expressions
;; is collecting one value or a list of values.</pre> ;; last-test - a boolean value that indicates whether this function
(define (create-test-func p sf let-bound bind-map last-test cert) ;; is collecting one value or a list of values.</pre>
#`(lambda (exp) (define (create-test-func p sf let-bound bind-map last-test cert)
#,(next-outer-helper #`(lambda (exp)
p #'exp sf '() let-bound #,(next-outer-helper
(lambda (let-bound) p #'exp sf '() let-bound
(lambda (sf bv) (lambda (let-bound)
#'#f)) (lambda (sf bv)
(lambda (fail let-bound) #'#f))
(lambda (sf bv) (lambda (fail let-bound)
#`(begin (lambda (sf bv)
#,@(map (lambda (bind) #`(begin
(let ((binding-name (get-bind-val (car bind) bind-map)) #,@(map (lambda (bind)
(exp-to-bind (let ((binding-name (get-bind-val (car bind) bind-map))
(subst-bindings (cdr bind) let-bound))) (exp-to-bind
(if last-test (subst-bindings (cdr bind) let-bound)))
#`(set! #,binding-name (if last-test
(cons #,exp-to-bind #,binding-name)) #`(set! #,binding-name
#`(set! #,binding-name (cons #,exp-to-bind #,binding-name))
#,exp-to-bind)))) #`(set! #,binding-name
bv) #,exp-to-bind))))
#t))) bv)
cert))) #t)))
cert)))
;;!(function getbindings
;; (form (getbindings pat-syntax) -> list) ;;!(function getbindings
;; (contract syntax -> list)) ;; (form (getbindings pat-syntax) -> list)
;; This function given a pattern returns a list of pattern ;; (contract syntax -> list))
;; variable names which are found in the pattern. ;; This function given a pattern returns a list of pattern
(define (getbindings pat-syntax cert) ;; variable names which are found in the pattern.
(let/cc out (define (getbindings pat-syntax cert)
(next-outer (let/cc out
pat-syntax (next-outer
(quote-syntax dummy) pat-syntax
'() (quote-syntax dummy)
'() '()
'() '()
(lambda (sf bv) #'(dummy-symbol)) '()
(lambda (sf bv) (out (map car bv))) (lambda (sf bv) #'(dummy-symbol))
cert))) (lambda (sf bv) (out (map car bv)))
cert)))
;; end getbindings@
)) ;; end getbindings@
)
) )

View File

@ -1,5 +1,5 @@
(module render-sigs mzscheme (module render-sigs mzscheme
(require (lib "unitsig.ss")) (require (lib "unit.ss"))
(provide (all-defined)) (provide (all-defined))

File diff suppressed because it is too large Load Diff

View File

@ -7,18 +7,13 @@
"render-test-list-impl.ss" "render-test-list-impl.ss"
"getbindings.ss" "getbindings.ss"
"ddk-handlers.ss" "ddk-handlers.ss"
(lib "unitsig.ss")) (lib "unit.ss"))
(define rtl@ (define-compound-unit/infer rtl@
(compound-unit/sig (import)
(import) (export render-test-list^)
(link (RTL : render-test-list^ (render-test-list@ DDK GET)) (link render-test-list@ getbindings@ ddk-handlers@))
(GET : getbindings^ (getbindings@ RTL))
(DDK : ddk-handlers^ (ddk-handlers@ GET RTL))
)
(export (var (RTL render-test-list)))
))
(define-values/invoke-unit/sig render-test-list^ rtl@)
(define-values/invoke-unit/infer rtl@)
) )