Skip to content

Commit

Permalink
Add catchless try to step 9 and step A
Browse files Browse the repository at this point in the history
(try* A) evaluates A without setting an error handler.
  • Loading branch information
bendudson committed Mar 2, 2019
1 parent bb1e6df commit e005219
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
19 changes: 18 additions & 1 deletion nasm/step9_try.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,10 @@ eval:
; Check second arg B

mov al, BYTE [rsi + Cons.typecdr]
; If nil (catchless try)
cmp al, content_nil
je .catchless_try
cmp al, content_pointer
jne .try_missing_catch

Expand Down Expand Up @@ -1575,7 +1579,7 @@ eval:
; Now have extracted from (try* A (catch* B C))
; A in R8
; B in R10
; C in T9
; C in R9
push R9
push R10
Expand Down Expand Up @@ -1610,7 +1614,20 @@ eval:
call error_handler_pop
mov rax, r8
jmp .return

.catchless_try:
; Evaluate the form in R8
mov rsi, r15
call incref_object ; Env released by eval
mov rdi, r15 ; Env in RDI

mov rsi, r8 ; The form to evaluate (A)
call incref_object ; AST released by eval
call eval ; Result in RAX
jmp .return
.catch:
; Jumps here on error
; Value thrown in RSI
Expand Down
19 changes: 18 additions & 1 deletion nasm/stepA_mal.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,10 @@ eval:
; Check second arg B

mov al, BYTE [rsi + Cons.typecdr]
; If nil (catchless try)
cmp al, content_nil
je .catchless_try
cmp al, content_pointer
jne .try_missing_catch

Expand Down Expand Up @@ -1590,7 +1594,7 @@ eval:
; Now have extracted from (try* A (catch* B C))
; A in R8
; B in R10
; C in T9
; C in R9
push R9
push R10
Expand Down Expand Up @@ -1625,7 +1629,20 @@ eval:
call error_handler_pop
mov rax, r8
jmp .return

.catchless_try:
; Evaluate the form in R8
mov rsi, r15
call incref_object ; Env released by eval
mov rdi, r15 ; Env in RDI

mov rsi, r8 ; The form to evaluate (A)
call incref_object ; AST released by eval
call eval ; Result in RAX
jmp .return
.catch:
; Jumps here on error
; Value thrown in RSI
Expand Down

0 comments on commit e005219

Please sign in to comment.