From 0c8ef0bd32d76f6dad11f342a75db677176251aa Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Tue, 15 Jul 2014 17:47:17 +0900 Subject: [PATCH] hold destination stack locations by offset --- include/picrin/error.h | 4 ++-- src/error.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/picrin/error.h b/include/picrin/error.h index cbaff543..bea590e2 100644 --- a/include/picrin/error.h +++ b/include/picrin/error.h @@ -12,8 +12,8 @@ extern "C" { struct pic_jmpbuf { jmp_buf here; struct pic_proc *handler; - pic_callinfo *ci; - pic_value *sp; + ptrdiff_t ci_offset; + ptrdiff_t sp_offset; pic_code *ip; jmp_buf *prev_jmp; }; diff --git a/src/error.c b/src/error.c index fb2d63f7..5987ed25 100644 --- a/src/error.c +++ b/src/error.c @@ -47,8 +47,8 @@ pic_push_try(pic_state *pic, struct pic_proc *handler) try_jmp->handler = handler; - try_jmp->ci = pic->ci; - try_jmp->sp = pic->sp; + try_jmp->ci_offset = pic->ci - pic->cibase; + try_jmp->sp_offset = pic->sp - pic->stbase; try_jmp->ip = pic->ip; try_jmp->prev_jmp = pic->jmp; @@ -64,8 +64,8 @@ pic_pop_try(pic_state *pic) assert(pic->jmp == &try_jmp->here); - pic->ci = try_jmp->ci; - pic->sp = try_jmp->sp; + pic->ci += try_jmp->ci_offset; + pic->sp += try_jmp->sp_offset; pic->ip = try_jmp->ip; pic->jmp = try_jmp->prev_jmp;