aboutsummaryrefslogtreecommitdiffstats
path: root/csc
diff options
context:
space:
mode:
Diffstat (limited to 'csc')
-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