ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/State.xs
(Generate patch)

Comparing Coro/Coro/State.xs (file contents):
Revision 1.18 by root, Thu Jul 26 03:46:15 2001 UTC vs.
Revision 1.19 by root, Sun Jul 29 01:11:41 2001 UTC

66 SV *defsv; 66 SV *defsv;
67 SV *errsv; 67 SV *errsv;
68 68
69 /* saved global state not related to stacks */ 69 /* saved global state not related to stacks */
70 U8 dowarn; 70 U8 dowarn;
71 I32 in_eval;
71 72
72 /* the stacks and related info (callchain etc..) */ 73 /* the stacks and related info (callchain etc..) */
73 PERL_SI *curstackinfo; 74 PERL_SI *curstackinfo;
74 AV *curstack; 75 AV *curstack;
75 AV *mainstack; 76 AV *mainstack;
93 I32 savestack_max; 94 I32 savestack_max;
94 OP **retstack; 95 OP **retstack;
95 I32 retstack_ix; 96 I32 retstack_ix;
96 I32 retstack_max; 97 I32 retstack_max;
97 COP *curcop; 98 COP *curcop;
98 JMPENV start_env;
99 JMPENV *top_env; 99 JMPENV *top_env;
100 100
101 /* data associated with this coroutine (initial args) */ 101 /* data associated with this coroutine (initial args) */
102 AV *args; 102 AV *args;
103}; 103};
288 288
289static void 289static void
290load_state(pTHX_ Coro__State c) 290load_state(pTHX_ Coro__State c)
291{ 291{
292 PL_dowarn = c->dowarn; 292 PL_dowarn = c->dowarn;
293 PL_in_eval = c->in_eval;
293 294
294 PL_curstackinfo = c->curstackinfo; 295 PL_curstackinfo = c->curstackinfo;
295 PL_curstack = c->curstack; 296 PL_curstack = c->curstack;
296 PL_mainstack = c->mainstack; 297 PL_mainstack = c->mainstack;
297 PL_stack_sp = c->stack_sp; 298 PL_stack_sp = c->stack_sp;
314 PL_savestack_max = c->savestack_max; 315 PL_savestack_max = c->savestack_max;
315 PL_retstack = c->retstack; 316 PL_retstack = c->retstack;
316 PL_retstack_ix = c->retstack_ix; 317 PL_retstack_ix = c->retstack_ix;
317 PL_retstack_max = c->retstack_max; 318 PL_retstack_max = c->retstack_max;
318 PL_curcop = c->curcop; 319 PL_curcop = c->curcop;
319 PL_start_env = c->start_env;
320 PL_top_env = c->top_env; 320 PL_top_env = c->top_env;
321 321
322 if (c->defav) REPLACE_SV (GvAV (PL_defgv), c->defav); 322 if (c->defav) REPLACE_SV (GvAV (PL_defgv), c->defav);
323 if (c->defsv) REPLACE_SV (DEFSV , c->defsv); 323 if (c->defsv) REPLACE_SV (DEFSV , c->defsv);
324 if (c->errsv) REPLACE_SV (ERRSV , c->errsv); 324 if (c->errsv) REPLACE_SV (ERRSV , c->errsv);
423 /* but if it's missing the defav contents magically get replaced sometimes */ 423 /* but if it's missing the defav contents magically get replaced sometimes */
424 if (c->defav) 424 if (c->defav)
425 av_reify (c->defav); 425 av_reify (c->defav);
426 426
427 c->dowarn = PL_dowarn; 427 c->dowarn = PL_dowarn;
428 c->in_eval = PL_in_eval;
428 429
429 c->curstackinfo = PL_curstackinfo; 430 c->curstackinfo = PL_curstackinfo;
430 c->curstack = PL_curstack; 431 c->curstack = PL_curstack;
431 c->mainstack = PL_mainstack; 432 c->mainstack = PL_mainstack;
432 c->stack_sp = PL_stack_sp; 433 c->stack_sp = PL_stack_sp;
449 c->savestack_max = PL_savestack_max; 450 c->savestack_max = PL_savestack_max;
450 c->retstack = PL_retstack; 451 c->retstack = PL_retstack;
451 c->retstack_ix = PL_retstack_ix; 452 c->retstack_ix = PL_retstack_ix;
452 c->retstack_max = PL_retstack_max; 453 c->retstack_max = PL_retstack_max;
453 c->curcop = PL_curcop; 454 c->curcop = PL_curcop;
454 c->start_env = PL_start_env;
455 c->top_env = PL_top_env; 455 c->top_env = PL_top_env;
456} 456}
457 457
458/* 458/*
459 * allocate various perl stacks. This is an exact copy 459 * allocate various perl stacks. This is an exact copy
603 dSP; 603 dSP;
604 Coro__State ctx = (Coro__State)arg; 604 Coro__State ctx = (Coro__State)arg;
605 SV *sub_init = (SV*)get_cv(SUB_INIT, FALSE); 605 SV *sub_init = (SV*)get_cv(SUB_INIT, FALSE);
606 606
607 coro_init_stacks (aTHX); 607 coro_init_stacks (aTHX);
608 JMPENV_BOOTSTRAP;
609 SPAGAIN;
610
611 /*PL_curcop = 0;*/ 608 /*PL_curcop = 0;*/
609 /*PL_in_eval = PL_in_eval;*/ /* inherit */
612 SvREFCNT_dec (GvAV (PL_defgv)); 610 SvREFCNT_dec (GvAV (PL_defgv));
613 GvAV (PL_defgv) = ctx->args; 611 GvAV (PL_defgv) = ctx->args;
614 612
613 SPAGAIN;
614
615 if (ctx->stack) 615 if (ctx->stack)
616 { 616 {
617 ctx->cursp = 0; 617 ctx->cursp = 0;
618 618
619 PUSHMARK(SP); 619 PUSHMARK(SP);
620 PUTBACK; 620 PUTBACK;
621 (void) call_sv (sub_init, G_VOID|G_NOARGS); 621 (void) call_sv (sub_init, G_VOID|G_NOARGS|G_EVAL);
622
623 if (SvTRUE (ERRSV))
624 croak (NULL);
625 else
622 croak ("FATAL: CCTXT coroutine returned!"); 626 croak ("FATAL: CCTXT coroutine returned!");
623 } 627 }
624 else 628 else
625 { 629 {
626 UNOP myop; 630 UNOP myop;
627 631
654 /* 658 /*
655 * this is a _very_ stripped down perl interpreter ;) 659 * this is a _very_ stripped down perl interpreter ;)
656 */ 660 */
657 Coro__State ctx = (Coro__State)arg; 661 Coro__State ctx = (Coro__State)arg;
658 662
663 /*FIXME*//* must set up top_env here */
659 ctx->cursp = 0; 664 ctx->cursp = 0;
660 PL_op = PL_op->op_next; 665 PL_op = PL_op->op_next;
661 CALLRUNOPS(aTHX); 666 CALLRUNOPS(aTHX);
662 /*NORETURN*/ 667
663 abort (); 668 abort ();
664} 669}
665 670
666STATIC void 671STATIC void
667transfer(pTHX_ struct coro *prev, struct coro *next, int flags) 672transfer(pTHX_ struct coro *prev, struct coro *next, int flags)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines