Fixed quoting levels.

This doesn't fix the implementation but at least gets the code parsing
and running. Pushed the quoting up to inc/dec/jnz/etc because they're
the entry points. Doesn't terminate on input file (and hits a point
where it doesn't seem to be doing anything but spinning in the loop).
pull/3/head
Ryan Davis 8 years ago
parent c666411e3a
commit 43585dbd0a

@ -42,41 +42,41 @@
(define-macro (tgl X)
#'(λ(regs)
((if (toggled?)
(make-inc-base X)
(make-tgl-base X)) regs)))
(make-inc-base 'X)
(make-tgl-base 'X)) regs)))
(define-macro (make-cpy-base X Y)
#'(λ(regs)
(define val (if (number? 'X) 'X (hash-ref regs 'X)))
(hash-set! regs 'Y val)))
(define val (if (number? X) X (hash-ref regs X)))
(hash-set! regs Y val)))
(define-macro (cpy X Y)
#'(λ(regs)
((if (toggled?)
(make-jnz-base X Y)
(make-cpy-base X Y)) regs)))
(make-jnz-base 'X 'Y)
(make-cpy-base 'X 'Y)) regs)))
(define-macro (make-dec-base X) #'(λ(regs) (hash-update! regs 'X sub1)))
(define-macro (make-inc-base X) #'(λ(regs) (hash-update! regs 'X add1)))
(define-macro (make-dec-base X) #'(λ(regs) (hash-update! regs X sub1)))
(define-macro (make-inc-base X) #'(λ(regs) (hash-update! regs X add1)))
(define-macro (inc X) #'(λ(regs)
((if (toggled?)
(make-dec-base X)
(make-inc-base X)) regs)))
(make-dec-base 'X)
(make-inc-base 'X)) regs)))
(define-macro (dec X) #'(λ(regs)
((if (toggled?)
(make-inc-base X)
(make-dec-base X)) regs)))
(make-inc-base 'X)
(make-dec-base 'X)) regs)))
(define-macro (make-jnz-base X Y)
#'(λ(regs)
(when (not (zero? (if (number? 'X) 'X (hash-ref regs 'X))))
(when (not (zero? (if (number? X) X (hash-ref regs X))))
Y)))
(define-macro (jnz X Y)
#'(λ(regs)
((if (toggled?)
(make-copy-base X Y)
(make-jnz-base X Y)) regs)))
(make-cpy-base 'X 'Y)
(make-jnz-base 'X 'Y)) regs)))