aboutsummaryrefslogtreecommitdiffstats
path: root/csc/codegen-test.csc
blob: 9c476618fadc82b974efeb8249624a0c5e3c749a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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))