print-pass

main
Matthew Butterick 2 years ago
parent 2cc67cd3bf
commit b5f794014e

@ -53,7 +53,6 @@
(for/fold ([posn0 ($point 0 0)] (for/fold ([posn0 ($point 0 0)]
#:result qs) #:result qs)
([q (in-list qs)]) ([q (in-list qs)])
#RRR q
(define first-posn-on-next-line ($point 0 (add1 ($point-y posn0)))) (define first-posn-on-next-line ($point 0 (add1 ($point-y posn0))))
(define other-possible-posns (list first-posn-on-next-line)) (define other-possible-posns (list first-posn-on-next-line))
(define posn1 (for/first ([posn (in-list (cons posn0 other-possible-posns))] (define posn1 (for/first ([posn (in-list (cons posn0 other-possible-posns))]

@ -15,7 +15,7 @@
racket/file) racket/file)
(define quad-compile (define quad-compile
(make-pipeline (list (make-pipeline
;; each pass in the pipeline is at least ;; each pass in the pipeline is at least
;; (list-of quad?) -> (list-of quad?) ;; (list-of quad?) -> (list-of quad?)
@ -45,7 +45,7 @@
;; has been absorbed into the attrs ;; has been absorbed into the attrs
;; (e.g., cascading font sizes) ;; (e.g., cascading font sizes)
;; because once we linearize, that information is gone. ;; because once we linearize, that information is gone.
linearize (print-pass linearize)
;; post-linearization resolutions & parsings ============= ;; post-linearization resolutions & parsings =============
resolve-font-paths resolve-font-paths
@ -60,7 +60,7 @@
insert-fallback-font insert-fallback-font
layout layout
make-drawing-insts make-drawing-insts
stackify))) stackify))
(module+ main (module+ main
(require "render.rkt") (require "render.rkt")

@ -6,7 +6,6 @@
(provide (all-defined-out)) (provide (all-defined-out))
(struct pipeline (passes) (struct pipeline (passes)
#:constructor-name make-pipeline
#:guard (λ (procs name) #:guard (λ (procs name)
(unless ((list-of procedure?) procs) (unless ((list-of procedure?) procs)
(raise-argument-error 'bad-input-to-compiler-constructor "list of procedures" procs)) (raise-argument-error 'bad-input-to-compiler-constructor "list of procedures" procs))
@ -22,6 +21,12 @@
(time (displayln pass) (thunk)) (time (displayln pass) (thunk))
(thunk)))))) (thunk))))))
(define (make-pipeline . passes)
(pipeline passes))
(define (print-pass . passes)
(apply make-pipeline (append passes (list pass-printer))))
(define (compiler-append c passes) (define (compiler-append c passes)
(make-pipeline (append (pipeline-passes c) passes))) (make-pipeline (append (pipeline-passes c) passes)))
@ -33,7 +38,6 @@
EXPRS ...) EXPRS ...)
#`(define PASS-NAME #`(define PASS-NAME
(make-pipeline (make-pipeline
(list
(procedure-rename (procedure-rename
#,(syntax/loc stx #,(syntax/loc stx
(λ (ARG) (λ (ARG)
@ -51,4 +55,9 @@
(when (current-use-postconditions?) (when (current-use-postconditions?)
(unless (POSTCOND-PROC res) (unless (POSTCOND-PROC res)
(raise-argument-error 'PASS-NAME (format "~a (as postcondition)" 'POSTCOND-PROC) res)))))) (raise-argument-error 'PASS-NAME (format "~a (as postcondition)" 'POSTCOND-PROC) res))))))
'PASS-NAME))))])) 'PASS-NAME)))]))
(define-pass (pass-printer qs)
#:pre values
#:post values
(for-each println qs))
Loading…
Cancel
Save