mirror of
https://github.com/kanaka/mal.git
synced 2024-09-21 02:27:10 +03:00
Fix bugs in try*/catch*
Wasn't pushing Env, so wasn't releasing correctly. Resulted in errors when in nested expressions. Catch was also not popping the exception handler, so repeated exceptions would not be handled correctly.
This commit is contained in:
parent
ef2d054491
commit
7eb930db46
@ -1732,7 +1732,8 @@ eval:
|
||||
|
||||
push R9
|
||||
push R10
|
||||
|
||||
push r15 ; Env
|
||||
|
||||
; Set the error handler
|
||||
mov rsi, rsp ; Stack pointer
|
||||
mov rdi, .catch ; Address to jump to
|
||||
@ -1747,12 +1748,14 @@ eval:
|
||||
mov rsi, r8 ; The form to evaluate (A)
|
||||
|
||||
call incref_object ; AST released by eval
|
||||
|
||||
|
||||
call eval
|
||||
|
||||
mov r8, rax ; Result in R8
|
||||
|
||||
pop r15 ; Environment
|
||||
; Discard B and C
|
||||
;add rsi, 8 ; pop R10 and R9
|
||||
;add rsi, 8 ; pop R10 and R9
|
||||
pop r10
|
||||
pop r9
|
||||
|
||||
@ -1765,7 +1768,12 @@ eval:
|
||||
; Jumps here on error
|
||||
; Value thrown in RSI
|
||||
;
|
||||
|
||||
|
||||
push rsi
|
||||
call error_handler_pop
|
||||
pop rsi
|
||||
|
||||
pop r15 ; Env
|
||||
pop r12 ; B (symbol to bind)
|
||||
pop r13 ; C (form to evaluate)
|
||||
|
||||
@ -1799,9 +1807,11 @@ eval:
|
||||
mov rdi, rsi ; Env in RDI (will be released)
|
||||
mov rsi, [r13 + Cons.car] ; Form to evaluate
|
||||
call incref_object ; will be released
|
||||
|
||||
call eval
|
||||
|
||||
push r15
|
||||
call eval
|
||||
pop r15
|
||||
|
||||
jmp .return
|
||||
|
||||
.try_missing_catch:
|
||||
|
Loading…
Reference in New Issue
Block a user