(define-library (csc ir2) (export atom-continuation atom-expression atom? ir2=? make-atom make-tail tail? ; Re-exports from IR1. constant-expression constant? make-constant) (import (scheme base) (only (csc ir1) constant? ir1=? make-constant)) (begin ; This library defines the intermediate representation IR2. ; It's CPS time bitch. ; CPS expressions. ; An atom consists of an ir1 expression and a continuation. (define-record-type (make-atom expression continuation) atom? (expression atom-expression) (continuation atom-continuation)) ; CPS continuations. ; tail is the tail continuation. (define-record-type (make-tail) tail?) (define (ir2=?-sametype x y) (cond ((and (atom? x) (atom? y)) (and (ir1=? (atom-expression x) (atom-expression y)) (ir2=? (atom-continuation x) (atom-continuation y)))) ((and (tail? x) (tail? y)) #t) (else #f))) (define (ir2=? x y) (cond ((ir2=?-sametype x y) #t) ((and (ir2=?-sametype x x) (ir2=?-sametype y y)) #f) (else (error "One or more arguments has a type unknown to ir2=?" x y))))))