warn when a closure is applied
This commit is contained in:
parent
b60e4df3d9
commit
19abedf746
|
@ -17,4 +17,6 @@ struct pic_proc {
|
||||||
|
|
||||||
#define pic_proc_ptr(o) ((struct pic_proc *)o.u.data)
|
#define pic_proc_ptr(o) ((struct pic_proc *)o.u.data)
|
||||||
|
|
||||||
|
#define pic_proc_cfunc_p(o) (pic_proc_ptr(o)->cfunc_p)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
20
src/vm.c
20
src/vm.c
|
@ -322,13 +322,14 @@ pic_value
|
||||||
pic_run(pic_state *pic, struct pic_proc *proc, pic_value args)
|
pic_run(pic_state *pic, struct pic_proc *proc, pic_value args)
|
||||||
{
|
{
|
||||||
struct pic_code *pc;
|
struct pic_code *pc;
|
||||||
|
pic_callinfo *ci;
|
||||||
int ai = pic_gc_arena_preserve(pic);
|
int ai = pic_gc_arena_preserve(pic);
|
||||||
|
|
||||||
pc = proc->u.irep->code;
|
pc = proc->u.irep->code;
|
||||||
|
|
||||||
PUSHCI();
|
ci = PUSHCI();
|
||||||
pic->ci->proc = proc;
|
ci->proc = proc;
|
||||||
pic->ci->argc = 0;
|
ci->argc = 0;
|
||||||
|
|
||||||
VM_LOOP {
|
VM_LOOP {
|
||||||
CASE(OP_PUSHNIL) {
|
CASE(OP_PUSHNIL) {
|
||||||
|
@ -354,16 +355,21 @@ pic_run(pic_state *pic, struct pic_proc *proc, pic_value args)
|
||||||
CASE(OP_CALL) {
|
CASE(OP_CALL) {
|
||||||
pic_value c;
|
pic_value c;
|
||||||
struct pic_proc *proc;
|
struct pic_proc *proc;
|
||||||
pic_callinfo *ci;
|
|
||||||
|
|
||||||
pic_gc_protect(pic, c = POP());
|
pic_gc_protect(pic, c = POP());
|
||||||
proc = pic_proc_ptr(c);
|
proc = pic_proc_ptr(c);
|
||||||
ci = PUSHCI();
|
ci = PUSHCI();
|
||||||
ci->proc = proc;
|
ci->proc = proc;
|
||||||
ci->argc = pc->u.i;
|
ci->argc = pc->u.i;
|
||||||
PUSH(proc->u.cfunc(pic));
|
if (pic_proc_cfunc_p(c)) {
|
||||||
pic->sp -= ci->argc;
|
PUSH(proc->u.cfunc(pic));
|
||||||
POPCI();
|
pic->sp -= ci->argc;
|
||||||
|
POPCI();
|
||||||
|
ci = pic->ci - 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pic_raise(pic, "closure call not suppoted");
|
||||||
|
}
|
||||||
pic_gc_arena_restore(pic, ai);
|
pic_gc_arena_restore(pic, ai);
|
||||||
NEXT;
|
NEXT;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue