refactor native_stack_length

This commit is contained in:
Yuichi Nishiwaki 2014-03-30 14:45:24 +09:00
parent a1101296aa
commit c3b737037a
2 changed files with 5 additions and 4 deletions

View File

@ -16,7 +16,7 @@ struct pic_cont {
pic_block *blk;
char *stk_pos, *stk_ptr;
size_t stk_len;
ptrdiff_t stk_len;
pic_value *st_ptr;
size_t sp_offset, st_len;

View File

@ -77,7 +77,7 @@ pic_receive(pic_state *pic, size_t n, pic_value *argv)
static void save_cont(pic_state *, struct pic_cont **);
static void restore_cont(pic_state *, struct pic_cont *);
static size_t
static ptrdiff_t
native_stack_length(pic_state *pic, char **pos)
{
char t;
@ -87,8 +87,8 @@ native_stack_length(pic_state *pic, char **pos)
: pic->native_stack_start;
return (pic->native_stack_start > &t)
? (size_t)(pic->native_stack_start - &t)
: (size_t)(&t - pic->native_stack_start + 1);
? pic->native_stack_start - &t
: &t - pic->native_stack_start;
}
static void
@ -106,6 +106,7 @@ save_cont(pic_state *pic, struct pic_cont **c)
cont->stk_pos = pos;
cont->stk_ptr = pic_alloc(pic, sizeof(pic_value) * cont->stk_len);
memcpy(cont->stk_ptr, cont->stk_pos, sizeof(pic_value) * cont->stk_len);
assert(cont->stk_len > 0);
cont->sp_offset = pic->sp - pic->stbase;
cont->st_len = pic->stend - pic->stbase;