aboutsummaryrefslogtreecommitdiffstats
path: root/csc/codegen-test.csc
diff options
context:
space:
mode:
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))