aboutsummaryrefslogtreecommitdiffstats
path: root/csc/codegen-test.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-07-24 19:08:49 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-07-24 19:08:49 -0700
commit745d6b8e16c7f276f479c18d97200e44d16aafc9 (patch)
tree715c8dc403d9779c2f6a4fc153221401dff144cc /csc/codegen-test.csc
parentImprove the match syntax for constants. (diff)
downloadchromatopelma-745d6b8e16c7f276f479c18d97200e44d16aafc9.tar.zst
Start codegen.
Diffstat (limited to 'csc/codegen-test.csc')
-rw-r--r--csc/codegen-test.csc38
1 files changed, 38 insertions, 0 deletions
diff --git a/csc/codegen-test.csc b/csc/codegen-test.csc
new file mode 100644
index 0000000..9c47661
--- /dev/null
+++ b/csc/codegen-test.csc
@@ -0,0 +1,38 @@
+(import (scheme base)
+ (only (csc gensym)
+ gensym)
+ (only (csc ir2)
+ *globals*
+ make-apply
+ make-constant
+ make-fix
+ make-primitive
+ make-variable)
+ (only (csc match)
+ match)
+ (only (csc testing)
+ assert-equal)
+ (csc codegen))
+
+
+(define transform-bytecode
+ (list
+ (cons (lambda (expr)
+ (match expr
+ (('label _) #t)
+ (_ #f)))
+ (lambda (expr) 'label))))
+
+
+(define (test-var)
+ (make-variable (gensym)))
+
+
+(test codegen-apply
+ (assert-equal
+ 'something
+ (ir2->ir3
+ (make-fix '()
+ (make-primitive 'peek (list *globals* (make-constant 5)) (list (test-var))
+ (make-apply (test-var) (list (make-constant 10))))))
+ transform-bytecode))