Skip to content

Commit

Permalink
crook
Browse files Browse the repository at this point in the history
  • Loading branch information
dvanhorn committed Dec 13, 2024
1 parent 1b39899 commit d4bdebc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 27 deletions.
19 changes: 7 additions & 12 deletions iniquity-plus/compile-ops.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,13 @@
(Add rbx 8))]
['unbox
(seq (assert-box rax)
(Xor rax type-box)
(Mov rax (Offset rax 0)))]
(Mov rax (Offset rax (- type-box))))]
['car
(seq (assert-cons rax)
(Xor rax type-cons)
(Mov rax (Offset rax 8)))]
(Mov rax (Offset rax (- 8 type-cons))))]
['cdr
(seq (assert-cons rax)
(Xor rax type-cons)
(Mov rax (Offset rax 0)))]
(Mov rax (Offset rax (- type-cons))))]

['empty? (seq (Cmp rax (value->bits '())) if-equal)]
['cons? (type-pred ptr-mask type-cons)]
Expand All @@ -85,10 +82,9 @@
(let ((zero (gensym))
(done (gensym)))
(seq (assert-vector rax)
(Xor rax type-vect)
(Cmp rax 0)
(Cmp rax type-vect)
(Je zero)
(Mov rax (Offset rax 0))
(Mov rax (Offset rax (- type-vect)))
(Sal rax int-shift)
(Jmp done)
(Label zero)
Expand All @@ -98,10 +94,9 @@
(let ((zero (gensym))
(done (gensym)))
(seq (assert-string rax)
(Xor rax type-str)
(Cmp rax 0)
(Cmp rax type-str)
(Je zero)
(Mov rax (Offset rax 0))
(Mov rax (Offset rax (- type-str)))
(Sal rax int-shift)
(Jmp done)
(Label zero)
Expand Down
19 changes: 7 additions & 12 deletions knock-plus/compile-ops.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,13 @@
(Add rbx 8))]
['unbox
(seq (assert-box rax)
(Xor rax type-box)
(Mov rax (Offset rax 0)))]
(Mov rax (Offset rax (- type-box))))]
['car
(seq (assert-cons rax)
(Xor rax type-cons)
(Mov rax (Offset rax 8)))]
(Mov rax (Offset rax (- 8 type-cons))))]
['cdr
(seq (assert-cons rax)
(Xor rax type-cons)
(Mov rax (Offset rax 0)))]
(Mov rax (Offset rax (- type-cons))))]

['empty? (seq (Cmp rax (value->bits '())) if-equal)]
['cons? (type-pred ptr-mask type-cons)]
Expand All @@ -85,10 +82,9 @@
(let ((zero (gensym))
(done (gensym)))
(seq (assert-vector rax)
(Xor rax type-vect)
(Cmp rax 0)
(Cmp rax type-vect)
(Je zero)
(Mov rax (Offset rax 0))
(Mov rax (Offset rax (- type-vect)))
(Sal rax int-shift)
(Jmp done)
(Label zero)
Expand All @@ -98,10 +94,9 @@
(let ((zero (gensym))
(done (gensym)))
(seq (assert-string rax)
(Xor rax type-str)
(Cmp rax 0)
(Cmp rax type-str)
(Je zero)
(Mov rax (Offset rax 0))
(Mov rax (Offset rax (- type-str)))
(Sal rax int-shift)
(Jmp done)
(Label zero)
Expand Down
6 changes: 3 additions & 3 deletions knock-plus/compile.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
compile-e
compile-es
compile-define
compile-match)
compile-match
compile-match-clause)

(require "ast.rkt")
(require "compile-ops.rkt")
Expand Down Expand Up @@ -275,8 +276,7 @@
(Add rsp (* 8 (length cm))) ; haven't pushed anything yet
(Jmp next)
(Label ok)
(Xor rax type-box)
(Mov rax (Offset rax 0))
(Mov rax (Offset rax (- type-box)))
i1)
cm1))])]
[(Cons p1 p2)
Expand Down

0 comments on commit d4bdebc

Please sign in to comment.