continuation now can take more than 1 arguments
This commit is contained in:
+10
-5
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "picrin.h"
|
||||
#include "picrin/proc.h"
|
||||
@@ -60,7 +61,8 @@ save_cont(pic_state *pic, struct pic_cont **c)
|
||||
cont->arena_idx = pic->arena_idx;
|
||||
memcpy(cont->arena, pic->arena, sizeof(struct pic_object *) * PIC_ARENA_SIZE);
|
||||
|
||||
cont->result = pic_undef_value();
|
||||
cont->argc = 0;
|
||||
cont->argv = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -132,14 +134,16 @@ NORETURN static pic_value
|
||||
cont_call(pic_state *pic)
|
||||
{
|
||||
struct pic_proc *proc;
|
||||
pic_value v;
|
||||
size_t argc;
|
||||
pic_value *argv;
|
||||
struct pic_cont *cont;
|
||||
|
||||
proc = pic_get_proc(pic);
|
||||
pic_get_args(pic, "o", &v);
|
||||
pic_get_args(pic, "*", &argc, &argv);
|
||||
|
||||
cont = (struct pic_cont *)pic_ptr(proc->env->values[0]);
|
||||
cont->result = v;
|
||||
cont->argc = argc;
|
||||
cont->argv = argv;
|
||||
|
||||
/* execute guard handlers */
|
||||
walk_to_block(pic, pic->blk, cont->blk);
|
||||
@@ -154,7 +158,8 @@ pic_callcc(pic_state *pic, struct pic_proc *proc)
|
||||
|
||||
save_cont(pic, &cont);
|
||||
if (setjmp(cont->jmp)) {
|
||||
return cont->result;
|
||||
printf("%d\n", cont->argc);
|
||||
return pic_values_from_array(pic, cont->argc, cont->argv);
|
||||
}
|
||||
else {
|
||||
struct pic_proc *c;
|
||||
|
||||
Reference in New Issue
Block a user