change ways of stack operation (no longer push dummy object at first)

This commit is contained in:
Yuichi Nishiwaki 2013-10-15 22:34:20 +09:00
parent a93c3caabf
commit e42eb5acd5
2 changed files with 3 additions and 4 deletions

View File

@ -28,7 +28,6 @@ pic_open()
/* prepare VM stack */
pic->stbase = pic->sp = (pic_value *)malloc(sizeof(pic_value) * 1024);
pic->stend = pic->stbase + 1024;
*pic->sp = pic_undef_value(); /* push dummy object */
/* memory heap */
pic->heap = (struct heap_page *)malloc(sizeof(struct heap_page));

View File

@ -82,7 +82,7 @@ pic_get_args(pic_state *pic, const char *format, ...)
pic_value *p;
p = va_arg(ap, pic_value*);
*p = *pic->sp--;
*p = *--pic->sp;
i++;
}
break;
@ -305,8 +305,8 @@ pic_codegen(pic_state *pic, pic_value obj, struct pic_env *env)
#define JUMP break
#define VM_LOOP_END } }
#define PUSH(v) do { pic_value v__ = (v); *++pic->sp = v__; } while (0)
#define POP() (*pic->sp--)
#define PUSH(v) (*pic->sp++ = (v))
#define POP() (*--pic->sp)
pic_value
pic_run(pic_state *pic, struct pic_proc *proc, pic_value args)