X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=cop.h;h=44305da95a72313f83fd79f3598e973323a87fb4;hb=15a5279aa74a37f0ad0b3fa3f9e566cb2d7a9d9a;hp=0732a040efe23e1722d48c16b0836c3ce699f2db;hpb=b8f55b69fbd0df7045f7d14d66b22d94744f42c5;p=p5sagit%2Fp5-mst-13.2.git diff --git a/cop.h b/cop.h index 0732a04..44305da 100644 --- a/cop.h +++ b/cop.h @@ -1,10 +1,16 @@ /* cop.h * - * Copyright (c) 1991-2002, Larry Wall + * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, + * 2000, 2001, 2002, 2003, by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. * + * Control ops (cops) are one of the three ops OP_NEXTSTATE, OP_DBSTATE, + * and OP_SETSTATE that (loosely speaking) are separate statements. + * They hold information important for lexical state and error reporting. + * At run time, PL_curcop is set to point to the most recently executed cop, + * and thus can be used to determine our current state. */ struct cop { @@ -107,23 +113,31 @@ struct block_sub { CV * cv; GV * gv; GV * dfoutgv; -#ifndef USE_5005THREADS AV * savearray; -#endif /* USE_5005THREADS */ AV * argarray; long olddepth; U8 hasargs; U8 lval; /* XXX merge lval and hasargs? */ - SV ** oldcurpad; + PAD *oldcomppad; }; -#define PUSHSUB(cx) \ +/* base for the next two macros. Don't use directly */ +#define PUSHSUB_BASE(cx) \ cx->blk_sub.cv = cv; \ cx->blk_sub.olddepth = CvDEPTH(cv); \ - cx->blk_sub.hasargs = hasargs; \ + cx->blk_sub.hasargs = hasargs; + +#define PUSHSUB(cx) \ + PUSHSUB_BASE(cx) \ cx->blk_sub.lval = PL_op->op_private & \ (OPpLVAL_INTRO|OPpENTERSUB_INARGS); +/* variant for use by OP_DBSTATE, where op_private holds hint bits */ +#define PUSHSUB_DB(cx) \ + PUSHSUB_BASE(cx) \ + cx->blk_sub.lval = 0; + + #define PUSHFORMAT(cx) \ cx->blk_sub.cv = cv; \ cx->blk_sub.gv = gv; \ @@ -131,15 +145,11 @@ struct block_sub { cx->blk_sub.dfoutgv = PL_defoutgv; \ (void)SvREFCNT_inc(cx->blk_sub.dfoutgv) -#ifdef USE_5005THREADS -# define POP_SAVEARRAY() NOOP -#else -# define POP_SAVEARRAY() \ +#define POP_SAVEARRAY() \ STMT_START { \ SvREFCNT_dec(GvAV(PL_defgv)); \ GvAV(PL_defgv) = cx->blk_sub.savearray; \ } STMT_END -#endif /* USE_5005THREADS */ /* junk in @_ spells trouble when cloning CVs and in pp_caller(), so don't * leave any (a fast av_clear(ary), basically) */ @@ -161,7 +171,7 @@ struct block_sub { cx->blk_sub.argarray = newAV(); \ av_extend(cx->blk_sub.argarray, fill); \ AvFLAGS(cx->blk_sub.argarray) = AVf_REIFY; \ - cx->blk_sub.oldcurpad[0] = (SV*)cx->blk_sub.argarray; \ + CX_CURPAD_SV(cx->blk_sub, 0) = (SV*)cx->blk_sub.argarray; \ } \ else { \ CLEAR_ARGARRAY(cx->blk_sub.argarray); \ @@ -220,7 +230,7 @@ struct block_loop { OP * last_op; #ifdef USE_ITHREADS void * iterdata; - SV ** oldcurpad; + PAD *oldcomppad; #else SV ** itervar; #endif @@ -235,11 +245,12 @@ struct block_loop { # define CxITERVAR(c) \ ((c)->blk_loop.iterdata \ ? (CxPADLOOP(cx) \ - ? &((c)->blk_loop.oldcurpad)[INT2PTR(PADOFFSET, (c)->blk_loop.iterdata)] \ + ? &CX_CURPAD_SV( (c)->blk_loop, \ + INT2PTR(PADOFFSET, (c)->blk_loop.iterdata)) \ : &GvSV((GV*)(c)->blk_loop.iterdata)) \ : (SV**)NULL) # define CX_ITERDATA_SET(cx,idata) \ - cx->blk_loop.oldcurpad = PL_curpad; \ + CX_CURPAD_SAVE(cx->blk_loop); \ if ((cx->blk_loop.iterdata = (idata))) \ cx->blk_loop.itersave = SvREFCNT_inc(*CxITERVAR(cx)); \ else \