Skip to content

Commit

Permalink
Fix bug in match.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvanhorn committed Oct 25, 2024
1 parent 856c8e0 commit 8a4fb9c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion knock/compile.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@
(list (seq (Push rax)) (cons x cm))]
[(Lit l)
(let ((ok (gensym)))
(list (seq (Cmp rax (value->bits l))
(list (seq (Mov r8 rax)
(compile-value l)
(Cmp rax r8)
(Je ok)
(Add rsp (* 8 (length cm)))
(Jmp next)
Expand Down
4 changes: 3 additions & 1 deletion knock/test/test-runner.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@
(check-equal? (run '(match (box 1) [(box 2) 0] [_ 1]))
1)
(check-equal? (run '(match (box 1) [(box x) x] [_ 2]))
1)))
1)
(check-equal? (run '(match 1 [8589934592 1] [_ 2])) 2)
(check-equal? (run '(match 8589934592 [8589934592 1] [_ 2])) 1)))

(define (test/io run)
(begin ;; Evildoer
Expand Down
4 changes: 3 additions & 1 deletion loot/compile.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@
(list (seq (Push rax)) (cons x cm))]
[(Lit l)
(let ((ok (gensym)))
(list (seq (Cmp rax (value->bits l))
(list (seq (Mov r8 rax)
(compile-value l)
(Cmp rax r8)
(Je ok)
(Add rsp (* 8 (length cm)))
(Jmp next)
Expand Down
4 changes: 3 additions & 1 deletion loot/test/test-runner.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@
(check-equal? (run '(match (box 1) [(box 2) 0] [_ 1]))
1)
(check-equal? (run '(match (box 1) [(box x) x] [_ 2]))
1)))
1)
(check-equal? (run '(match 1 [8589934592 1] [_ 2])) 2)
(check-equal? (run '(match 8589934592 [8589934592 1] [_ 2])) 1)))

(define (test/io run)
(begin ;; Evildoer
Expand Down

0 comments on commit 8a4fb9c

Please sign in to comment.