blob: b85ebc3b4723779bf8a4a100e0d8355dd1cd927d (
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
39
40
41
42
43
44
45
46
47
48
49
|
(import (scheme base)
(only (csc gensym)
gensym)
(only (csc ir2)
*globals*
make-apply
make-constant
make-fix
make-primitive
make-variable)
(only (csc loop)
loop
return)
(only (csc match)
match)
(only (csc testing)
assert-equal
test)
(csc codegen))
(define transform-bytecode
(list
(cons (lambda (expr)
(match expr
(('label _) #t)
(_ #f)))
(lambda (expr) 'label))
(cons (lambda (expr)
(match expr
(('local _) #t)
(_ #f)))
(lambda (expr) 'local))))
(define (test-var)
(make-variable (gensym)))
(test codegen-apply
(assert-equal
'((peek (local #f) (local #f) (const 5))
(mov (local #f) (const 10))
(jmp (local #f)))
(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))
|