1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-21 10:37:58 +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:
Ben Dudson 2017-12-18 23:25:59 +00:00
parent ef2d054491
commit 7eb930db46

View File

@ -1732,6 +1732,7 @@ eval:
push R9
push R10
push r15 ; Env
; Set the error handler
mov rsi, rsp ; Stack pointer
@ -1749,8 +1750,10 @@ eval:
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
pop r10
@ -1766,6 +1769,11 @@ eval:
; 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)
@ -1800,7 +1808,9 @@ eval:
mov rsi, [r13 + Cons.car] ; Form to evaluate
call incref_object ; will be released
push r15
call eval
pop r15
jmp .return