aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-06-21 17:40:16 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-06-21 17:40:16 -0700
commita4fc91d5f155ef62d2b62f8279a4bf65a9050896 (patch)
tree721b5a1dadfc862b61cd5a49fdd1b375ac457455
parent3788d0a175b9372b3f39bc10e5462f567000c987 (diff)
downloadchromatopelma-a4fc91d5f155ef62d2b62f8279a4bf65a9050896.tar.zst
Start CPS :)
-rw-r--r--csc/cps.csc22
-rw-r--r--csc/ir2.csc8
2 files changed, 30 insertions, 0 deletions
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 <atom>
+ (make-atom expression continuation)
+ atom?
+ (expression atom-expression)
+ (continuation atom-continuation))
+
+
; <variable>
(define-record-type <variable>
(make-variable k var