Beispiel #1
0
static pic_value
cont_call(pic_state *pic)
{
  struct pic_proc *self = pic_get_proc(pic);
  int argc;
  pic_value *argv;
  int id;
  struct pic_cont *cc, *cont;

  pic_get_args(pic, "*", &argc, &argv);

  id = pic_int(pic_proc_env_ref(pic, self, "id"));

  /* check if continuation is alive */
  for (cc = pic->cc; cc != NULL; cc = cc->prev) {
    if (cc->id == id) {
      break;
    }
  }
  if (cc == NULL) {
    pic_errorf(pic, "calling dead escape continuation");
  }

  cont = pic_data_ptr(pic_proc_env_ref(pic, self, "escape"))->data;
  cont->results = pic_list_by_array(pic, argc, argv);

  pic_load_point(pic, cont);

  PIC_LONGJMP(pic, cont->jmp, 1);

  PIC_UNREACHABLE();
}
Beispiel #2
0
static pic_value
cont_call(pic_state *pic)
{
  size_t argc;
  pic_value *argv;
  struct pic_data *e;

  pic_get_args(pic, "*", &argc, &argv);

  e = pic_data_ptr(pic_proc_env_ref(pic, pic_get_proc(pic), "escape"));
  ((struct pic_cont *)e->data)->results = pic_list_by_array(pic, argc, argv);

  pic_load_point(pic, e->data);

  PIC_LONGJMP(pic, ((struct pic_cont *)e->data)->jmp.buf, 1);

  PIC_UNREACHABLE();
}