Fix bug in rco-arg and update tests
This commit is contained in:
parent
d52c9eb875
commit
febb63c240
|
|
@ -84,10 +84,12 @@
|
||||||
(values tmpname
|
(values tmpname
|
||||||
assoc-list
|
assoc-list
|
||||||
new-tmpcount))]
|
new-tmpcount))]
|
||||||
|
; this must return a simple term
|
||||||
|
; i.e.: either a symbol, a read or a number literal
|
||||||
[`(let ([,var ,rexp]) ,body)
|
[`(let ([,var ,rexp]) ,body)
|
||||||
(begin
|
(begin
|
||||||
(define-values (new-exp exp-tmpcount) (rco-exp rexp tmpcount))
|
(define-values (new-exp exp-tmpcount) (rco-exp rexp tmpcount))
|
||||||
(define-values (new-body new-tmpcount) (rco-exp body exp-tmpcount))
|
(define-values (new-body assoc-list new-tmpcount) (rco-arg body exp-tmpcount))
|
||||||
(values `(let ([,var ,new-exp]) ,new-body)
|
(values new-body
|
||||||
`()
|
(cons `(,var ,new-exp) assoc-list)
|
||||||
new-tmpcount))]))
|
new-tmpcount))]))
|
||||||
|
|
|
||||||
|
|
@ -60,19 +60,21 @@
|
||||||
(test-eq
|
(test-eq
|
||||||
(remove-complex-opera* (list-ref programs 6))
|
(remove-complex-opera* (list-ref programs 6))
|
||||||
`(program ()
|
`(program ()
|
||||||
|
(let ((x.1
|
||||||
(let ((tmp.1 (- 2)))
|
(let ((tmp.1 (- 2)))
|
||||||
(let ((x.1 (+ tmp.1 3)))
|
(+ tmp.1 3))))
|
||||||
(let ((tmp.3 (+ 2 3)))
|
(let ((tmp.2 (+ 2 3)))
|
||||||
(+ x.1 tmp.3))))))
|
(+ x.1 tmp.2)))))
|
||||||
|
|
||||||
(test-eq
|
(test-eq
|
||||||
(remove-complex-opera* (list-ref programs 7))
|
(remove-complex-opera* (list-ref programs 7))
|
||||||
`(program ()
|
`(program ()
|
||||||
|
(let ((x.1
|
||||||
(let ((tmp.1 (- 1)))
|
(let ((tmp.1 (- 1)))
|
||||||
(let ((x.1 (+ tmp.1 2)))
|
(+ tmp.1 2))))
|
||||||
(let ((tmp.3 (+ x.1 2)))
|
(let ((tmp.2 (+ x.1 2)))
|
||||||
(let ((tmp.4 (+ 4 5)))
|
(let ((tmp.3 (+ 4 5)))
|
||||||
(+ tmp.3 tmp.4)))))))
|
(+ tmp.2 tmp.3))))))
|
||||||
|
|
||||||
(test-eq
|
(test-eq
|
||||||
(remove-complex-opera* (list-ref programs 8))
|
(remove-complex-opera* (list-ref programs 8))
|
||||||
|
|
@ -88,10 +90,10 @@
|
||||||
|
|
||||||
(test-eq
|
(test-eq
|
||||||
(remove-complex-opera* (list-ref programs 11))
|
(remove-complex-opera* (list-ref programs 11))
|
||||||
`(program () (let ((x.2 1)) (let ((x.1 x.2)) (+ 2 x.1)))))
|
`(program () (let ((x.1 (let ((x.2 1)) x.2))) (+ 2 x.1))))
|
||||||
|
|
||||||
(test-eq
|
(test-eq
|
||||||
(remove-complex-opera* (list-ref programs 12))
|
(remove-complex-opera* (list-ref programs 12))
|
||||||
`(program () (let ((x.1 20)) (let ((x.2 22)) (let ((y.1 (+ x.1 x.2))) y.1)))))
|
`(program () (let ((y.1 (let ((x.1 20)) (let ((x.2 22)) (+ x.1 x.2))))) y.1)))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue