ソースを参照

Implement car, cdr, cddr and cddar as primitives

Lucas Stadler 8 年 前
コミット
5835ed4cfd
共有1 個のファイルを変更した15 個の追加0 個の削除を含む
  1. 15 0
      scm/inc/compiler.scm

+ 15 - 0
scm/inc/compiler.scm

167
     (emit "movq %rsi, %rax") ; rax = rsi | 1  (cons cell/pair tag)
167
     (emit "movq %rsi, %rax") ; rax = rsi | 1  (cons cell/pair tag)
168
     (emit "orq  $~a, %rax" #b001)
168
     (emit "orq  $~a, %rax" #b001)
169
     (emit "addq $8,  %rsi")) ; bump rsi
169
     (emit "addq $8,  %rsi")) ; bump rsi
170
    ((car)
171
     (emit-expr (primcall-operand1 x) si env)
172
     (emit "movl -1(%rax), %eax"))
173
    ((cdr)
174
     (emit-expr (primcall-operand1 x) si env)
175
     (emit "movl 3(%rax), %eax"))
176
    ((cddr)
177
     (emit-expr (primcall-operand1 x) si env)
178
     (emit "movl 3(%rax), %eax")
179
     (emit "movl 3(%rax), %eax"))
180
    ((cddar)
181
     (emit-expr (primcall-operand1 x) si env)
182
     (emit "movl 3(%rax), %eax")
183
     (emit "movl 3(%rax), %eax")
184
     (emit "movl -1(%rax), %eax"))
170
    ))
185
    ))
171
186
172
(define (compile-program x)
187
(define (compile-program x)