aboutsummaryrefslogtreecommitdiffstats
path: root/csc/cps-test.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@google.com>2022-07-12 22:55:48 -0700
committerRose Hogenson <rhogenson@google.com>2022-07-12 22:55:48 -0700
commitd18813441649665f42b524443c65d0b6bb4ac59a (patch)
tree434659955a2f1a0d18c4c02e6bbf5d31d980ae27 /csc/cps-test.csc
parentSlightly improve diff formatting. (diff)
downloadchromatopelma-d18813441649665f42b524443c65d0b6bb4ac59a.tar.zst
Add builtin operations to IR1.
Diffstat (limited to 'csc/cps-test.csc')
-rw-r--r--csc/cps-test.csc33
1 files changed, 33 insertions, 0 deletions
diff --git a/csc/cps-test.csc b/csc/cps-test.csc
index 9881a2d..4259586 100644
--- a/csc/cps-test.csc
+++ b/csc/cps-test.csc
@@ -10,6 +10,7 @@
lexical-ref?
library-ref?
make-call
+ make-call-builtin
make-constant
make-define-syntax
make-if
@@ -141,6 +142,38 @@
transform-ir2))
+(test call-builtin-alloc
+ (assert-equal
+ (make-primitive 'alloc (list (make-constant 10)) (list (test-ref 'generated-symbol))
+ (make-apply (test-ref 'tail) (list (test-ref 'generated-symbol))))
+ (ir1->ir2 (make-call-builtin 'alloc (list (make-constant 10))) tail)
+ transform-ir2))
+
+
+(test call-builtin-peek
+ (assert-equal
+ (make-primitive 'alloc (list (make-constant 1)) (list (test-ref 'generated-symbol))
+ (make-primitive 'peek (list (test-ref 'generated-symbol) (make-constant 0)) (list (test-ref 'generated-symbol))
+ (make-apply (test-ref 'tail) (list (test-ref 'generated-symbol)))))
+ (ir1->ir2
+ (make-call-builtin 'peek (list (make-call-builtin 'alloc (list (make-constant 1))) (make-constant 0)))
+ tail)
+ transform-ir2))
+
+
+(test call-builtin-poke
+ (assert-equal
+ (make-primitive 'alloc (list (make-constant 1)) (list (test-ref 'generated-symbol))
+ (make-primitive 'poke (list (make-constant 10) (test-ref 'generated-symbol) (make-constant 0)) '()
+ (make-apply (test-ref 'tail) (list (make-constant #f)))))
+ (ir1->ir2
+ (make-call-builtin 'poke (list (make-constant 10)
+ (make-call-builtin 'alloc (list (make-constant 1)))
+ (make-constant 0)))
+ tail)
+ transform-ir2))
+
+
(test sequence
(assert-equal
(make-primitive 'poke (list (make-constant 5) (test-ref 'a) (make-constant 0)) '()