From a4fc91d5f155ef62d2b62f8279a4bf65a9050896 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Tue, 21 Jun 2022 17:40:16 -0700 Subject: Start CPS :) --- csc/cps.csc | 22 ++++++++++++++++++++++ csc/ir2.csc | 8 ++++++++ 2 files changed, 30 insertions(+) create mode 100644 csc/cps.csc (limited to 'csc') diff --git a/csc/cps.csc b/csc/cps.csc new file mode 100644 index 0000000..561a698 --- /dev/null +++ b/csc/cps.csc @@ -0,0 +1,22 @@ +(define-library (csc cps) + (import (only (csc ir1) + make-constant + constant? + lexical-ref? + library-ref?) + (only (csc ir2) + (make-atom)) + (scheme base)) + (begin + + + (define (to-cps expr k) + (cond + ((or (constant? expr) + (lexical-ref? expr) + (library-ref? expr)) + (make-atom expr continuation)) + (else (error "unexpected type in to-cps" expr)))) + + + (define (ir1->ir2 program) diff --git a/csc/ir2.csc b/csc/ir2.csc index 0c37d6c..46dbad1 100644 --- a/csc/ir2.csc +++ b/csc/ir2.csc @@ -69,6 +69,14 @@ ; It's CPS time bitch. + ; An atom consists of an ir1 expression and a continuation. + (define-record-type + (make-atom expression continuation) + atom? + (expression atom-expression) + (continuation atom-continuation)) + + ; (define-record-type (make-variable k var -- cgit v1.3.1