Sfoglia il codice sorgente

Implement integer? and boolean? predicates

Lucas Stadler 8 anni fa
parent
commit
c9bc3c40e3
1 ha cambiato i file con 16 aggiunte e 1 eliminazioni
  1. 16 1
      scm/inc/compiler.scm

+ 16 - 1
scm/inc/compiler.scm

@ -56,6 +56,21 @@
56 56
        (emit "sete %al")                      ; set low byte of %eax to 1 if cmp succeeded
57 57
        (emit "sall $~a,  %eax" boolean-shift) ; construct correctly tagged boolean value
58 58
        (emit "xorl $31, %eax"))
59
       ((integer?)
60
        (emit-expr (primcall-operand1 x))
61
        (emit "andl $~a, %eax" #b11)
62
        (emit "movl $0,  %eax")
63
        (emit "sete %al")
64
        (emit "sall $~a,  %eax" boolean-shift)
65
        (emit "xorl $31, %eax"))
66
       ((boolean?)
67
        (emit-expr (primcall-operand1 x))
68
        (emit "andl $~a, %eax" #b0011111)
69
        (emit "cmpl $~a,  %eax" #b0011111)
70
        (emit "movl $0,  %eax")
71
        (emit "sete %al")
72
        (emit "sall $~a,  %eax" boolean-shift)
73
        (emit "xorl $31, %eax"))
59 74
       ))))
60 75
61 76
(define (compile-program x)
@ -65,4 +80,4 @@
65 80
  (emit-expr x)
66 81
  (emit "ret"))
67 82
68
(compile-program '(zero? -1))
83
(compile-program '(boolean? #f))