1N/A/* cop.h
1N/A *
1N/A * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
1N/A * 2000, 2001, 2002, 2003, 2004, by Larry Wall and others
1N/A *
1N/A * You may distribute under the terms of either the GNU General Public
1N/A * License or the Artistic License, as specified in the README file.
1N/A *
1N/A * Control ops (cops) are one of the three ops OP_NEXTSTATE, OP_DBSTATE,
1N/A * and OP_SETSTATE that (loosely speaking) are separate statements.
1N/A * They hold information important for lexical state and error reporting.
1N/A * At run time, PL_curcop is set to point to the most recently executed cop,
1N/A * and thus can be used to determine our current state.
1N/A */
1N/A
1N/Astruct cop {
1N/A BASEOP
1N/A char * cop_label; /* label for this construct */
1N/A#ifdef USE_ITHREADS
1N/A char * cop_stashpv; /* package line was compiled in */
1N/A char * cop_file; /* file name the following line # is from */
1N/A#else
1N/A HV * cop_stash; /* package line was compiled in */
1N/A GV * cop_filegv; /* file the following line # is from */
1N/A#endif
1N/A U32 cop_seq; /* parse sequence number */
1N/A I32 cop_arybase; /* array base this line was compiled with */
1N/A line_t cop_line; /* line # of this command */
1N/A SV * cop_warnings; /* lexical warnings bitmask */
1N/A SV * cop_io; /* lexical IO defaults */
1N/A};
1N/A
1N/A#define Nullcop Null(COP*)
1N/A
1N/A#ifdef USE_ITHREADS
1N/A# define CopFILE(c) ((c)->cop_file)
1N/A# define CopFILEGV(c) (CopFILE(c) \
1N/A ? gv_fetchfile(CopFILE(c)) : Nullgv)
1N/A
1N/A# ifdef NETWARE
1N/A# define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv))
1N/A# else
1N/A# define CopFILE_set(c,pv) ((c)->cop_file = savesharedpv(pv))
1N/A# endif
1N/A
1N/A# define CopFILESV(c) (CopFILE(c) \
1N/A ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv)
1N/A# define CopFILEAV(c) (CopFILE(c) \
1N/A ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav)
1N/A# define CopSTASHPV(c) ((c)->cop_stashpv)
1N/A
1N/A# ifdef NETWARE
1N/A# define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch))
1N/A# else
1N/A# define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = savesharedpv(pv))
1N/A# endif
1N/A
1N/A# define CopSTASH(c) (CopSTASHPV(c) \
1N/A ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv)
1N/A# define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch)
1N/A# define CopSTASH_eq(c,hv) ((hv) \
1N/A && (CopSTASHPV(c) == HvNAME(hv) \
1N/A || (CopSTASHPV(c) && HvNAME(hv) \
1N/A && strEQ(CopSTASHPV(c), HvNAME(hv)))))
1N/A# ifdef NETWARE
1N/A# define CopSTASH_free(c) SAVECOPSTASH_FREE(c)
1N/A# else
1N/A# define CopSTASH_free(c) PerlMemShared_free(CopSTASHPV(c))
1N/A# endif
1N/A
1N/A# ifdef NETWARE
1N/A# define CopFILE_free(c) SAVECOPFILE_FREE(c)
1N/A# else
1N/A# define CopFILE_free(c) (PerlMemShared_free(CopFILE(c)),(CopFILE(c) = Nullch))
1N/A# endif
1N/A#else
1N/A# define CopFILEGV(c) ((c)->cop_filegv)
1N/A# define CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv))
1N/A# define CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv))
1N/A# define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv)
1N/A# define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav)
1N/A# define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch)
1N/A# define CopSTASH(c) ((c)->cop_stash)
1N/A# define CopSTASH_set(c,hv) ((c)->cop_stash = (hv))
1N/A# define CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch)
1N/A /* cop_stash is not refcounted */
1N/A# define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD))
1N/A# define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv))
1N/A# define CopSTASH_free(c)
1N/A# define CopFILE_free(c) (SvREFCNT_dec(CopFILEGV(c)),(CopFILEGV(c) = Nullgv))
1N/A
1N/A#endif /* USE_ITHREADS */
1N/A
1N/A#define CopSTASH_ne(c,hv) (!CopSTASH_eq(c,hv))
1N/A#define CopLINE(c) ((c)->cop_line)
1N/A#define CopLINE_inc(c) (++CopLINE(c))
1N/A#define CopLINE_dec(c) (--CopLINE(c))
1N/A#define CopLINE_set(c,l) (CopLINE(c) = (l))
1N/A
1N/A/* OutCopFILE() is CopFILE for output (caller, die, warn, etc.) */
1N/A#ifdef MACOS_TRADITIONAL
1N/A# define OutCopFILE(c) MacPerl_MPWFileName(CopFILE(c))
1N/A#else
1N/A# define OutCopFILE(c) CopFILE(c)
1N/A#endif
1N/A
1N/A/*
1N/A * Here we have some enormously heavy (or at least ponderous) wizardry.
1N/A */
1N/A
1N/A/* subroutine context */
1N/Astruct block_sub {
1N/A CV * cv;
1N/A GV * gv;
1N/A GV * dfoutgv;
1N/A#ifndef USE_5005THREADS
1N/A AV * savearray;
1N/A#endif /* USE_5005THREADS */
1N/A AV * argarray;
1N/A long olddepth;
1N/A U8 hasargs;
1N/A U8 lval; /* XXX merge lval and hasargs? */
1N/A PAD *oldcomppad;
1N/A};
1N/A
1N/A/* base for the next two macros. Don't use directly.
1N/A * Note that the refcnt of the cv is incremented twice; The CX one is
1N/A * decremented by LEAVESUB, the other by LEAVE. */
1N/A
1N/A#define PUSHSUB_BASE(cx) \
1N/A cx->blk_sub.cv = cv; \
1N/A cx->blk_sub.olddepth = CvDEPTH(cv); \
1N/A cx->blk_sub.hasargs = hasargs; \
1N/A if (!CvDEPTH(cv)) { \
1N/A (void)SvREFCNT_inc(cv); \
1N/A (void)SvREFCNT_inc(cv); \
1N/A SAVEFREESV(cv); \
1N/A }
1N/A
1N/A
1N/A#define PUSHSUB(cx) \
1N/A PUSHSUB_BASE(cx) \
1N/A cx->blk_sub.lval = PL_op->op_private & \
1N/A (OPpLVAL_INTRO|OPpENTERSUB_INARGS);
1N/A
1N/A/* variant for use by OP_DBSTATE, where op_private holds hint bits */
1N/A#define PUSHSUB_DB(cx) \
1N/A PUSHSUB_BASE(cx) \
1N/A cx->blk_sub.lval = 0;
1N/A
1N/A
1N/A#define PUSHFORMAT(cx) \
1N/A cx->blk_sub.cv = cv; \
1N/A cx->blk_sub.gv = gv; \
1N/A cx->blk_sub.hasargs = 0; \
1N/A cx->blk_sub.dfoutgv = PL_defoutgv; \
1N/A (void)SvREFCNT_inc(cx->blk_sub.dfoutgv)
1N/A
1N/A#ifdef USE_5005THREADS
1N/A# define POP_SAVEARRAY() NOOP
1N/A#else
1N/A# define POP_SAVEARRAY() \
1N/A STMT_START { \
1N/A SvREFCNT_dec(GvAV(PL_defgv)); \
1N/A GvAV(PL_defgv) = cx->blk_sub.savearray; \
1N/A } STMT_END
1N/A#endif /* USE_5005THREADS */
1N/A
1N/A/* junk in @_ spells trouble when cloning CVs and in pp_caller(), so don't
1N/A * leave any (a fast av_clear(ary), basically) */
1N/A#define CLEAR_ARGARRAY(ary) \
1N/A STMT_START { \
1N/A AvMAX(ary) += AvARRAY(ary) - AvALLOC(ary); \
1N/A SvPVX(ary) = (char*)AvALLOC(ary); \
1N/A AvFILLp(ary) = -1; \
1N/A } STMT_END
1N/A
1N/A#define POPSUB(cx,sv) \
1N/A STMT_START { \
1N/A if (cx->blk_sub.hasargs) { \
1N/A POP_SAVEARRAY(); \
1N/A /* abandon @_ if it got reified */ \
1N/A if (AvREAL(cx->blk_sub.argarray)) { \
1N/A SSize_t fill = AvFILLp(cx->blk_sub.argarray); \
1N/A SvREFCNT_dec(cx->blk_sub.argarray); \
1N/A cx->blk_sub.argarray = newAV(); \
1N/A av_extend(cx->blk_sub.argarray, fill); \
1N/A AvFLAGS(cx->blk_sub.argarray) = AVf_REIFY; \
1N/A CX_CURPAD_SV(cx->blk_sub, 0) = (SV*)cx->blk_sub.argarray; \
1N/A } \
1N/A else { \
1N/A CLEAR_ARGARRAY(cx->blk_sub.argarray); \
1N/A } \
1N/A } \
1N/A sv = (SV*)cx->blk_sub.cv; \
1N/A if (sv && (CvDEPTH((CV*)sv) = cx->blk_sub.olddepth)) \
1N/A sv = Nullsv; \
1N/A } STMT_END
1N/A
1N/A#define LEAVESUB(sv) \
1N/A STMT_START { \
1N/A if (sv) \
1N/A SvREFCNT_dec(sv); \
1N/A } STMT_END
1N/A
1N/A#define POPFORMAT(cx) \
1N/A setdefout(cx->blk_sub.dfoutgv); \
1N/A SvREFCNT_dec(cx->blk_sub.dfoutgv);
1N/A
1N/A/* eval context */
1N/Astruct block_eval {
1N/A I32 old_in_eval;
1N/A I32 old_op_type;
1N/A SV * old_namesv;
1N/A OP * old_eval_root;
1N/A SV * cur_text;
1N/A CV * cv;
1N/A};
1N/A
1N/A#define PUSHEVAL(cx,n,fgv) \
1N/A STMT_START { \
1N/A cx->blk_eval.old_in_eval = PL_in_eval; \
1N/A cx->blk_eval.old_op_type = PL_op->op_type; \
1N/A cx->blk_eval.old_namesv = (n ? newSVpv(n,0) : Nullsv); \
1N/A cx->blk_eval.old_eval_root = PL_eval_root; \
1N/A cx->blk_eval.cur_text = PL_linestr; \
1N/A cx->blk_eval.cv = Nullcv; /* set by doeval(), as applicable */ \
1N/A } STMT_END
1N/A
1N/A#define POPEVAL(cx) \
1N/A STMT_START { \
1N/A PL_in_eval = cx->blk_eval.old_in_eval; \
1N/A optype = cx->blk_eval.old_op_type; \
1N/A PL_eval_root = cx->blk_eval.old_eval_root; \
1N/A if (cx->blk_eval.old_namesv) \
1N/A sv_2mortal(cx->blk_eval.old_namesv); \
1N/A } STMT_END
1N/A
1N/A/* loop context */
1N/Astruct block_loop {
1N/A char * label;
1N/A I32 resetsp;
1N/A OP * redo_op;
1N/A OP * next_op;
1N/A OP * last_op;
1N/A#ifdef USE_ITHREADS
1N/A void * iterdata;
1N/A PAD *oldcomppad;
1N/A#else
1N/A SV ** itervar;
1N/A#endif
1N/A SV * itersave;
1N/A SV * iterlval;
1N/A AV * iterary;
1N/A IV iterix;
1N/A IV itermax;
1N/A};
1N/A
1N/A#ifdef USE_ITHREADS
1N/A# define CxITERVAR(c) \
1N/A ((c)->blk_loop.iterdata \
1N/A ? (CxPADLOOP(cx) \
1N/A ? &CX_CURPAD_SV( (c)->blk_loop, \
1N/A INT2PTR(PADOFFSET, (c)->blk_loop.iterdata)) \
1N/A : &GvSV((GV*)(c)->blk_loop.iterdata)) \
1N/A : (SV**)NULL)
1N/A# define CX_ITERDATA_SET(cx,idata) \
1N/A CX_CURPAD_SAVE(cx->blk_loop); \
1N/A if ((cx->blk_loop.iterdata = (idata))) \
1N/A cx->blk_loop.itersave = SvREFCNT_inc(*CxITERVAR(cx)); \
1N/A else \
1N/A cx->blk_loop.itersave = Nullsv;
1N/A#else
1N/A# define CxITERVAR(c) ((c)->blk_loop.itervar)
1N/A# define CX_ITERDATA_SET(cx,ivar) \
1N/A if ((cx->blk_loop.itervar = (SV**)(ivar))) \
1N/A cx->blk_loop.itersave = SvREFCNT_inc(*CxITERVAR(cx)); \
1N/A else \
1N/A cx->blk_loop.itersave = Nullsv;
1N/A#endif
1N/A
1N/A#define PUSHLOOP(cx, dat, s) \
1N/A cx->blk_loop.label = PL_curcop->cop_label; \
1N/A cx->blk_loop.resetsp = s - PL_stack_base; \
1N/A cx->blk_loop.redo_op = cLOOP->op_redoop; \
1N/A cx->blk_loop.next_op = cLOOP->op_nextop; \
1N/A cx->blk_loop.last_op = cLOOP->op_lastop; \
1N/A cx->blk_loop.iterlval = Nullsv; \
1N/A cx->blk_loop.iterary = Nullav; \
1N/A cx->blk_loop.iterix = -1; \
1N/A CX_ITERDATA_SET(cx,dat);
1N/A
1N/A#define POPLOOP(cx) \
1N/A SvREFCNT_dec(cx->blk_loop.iterlval); \
1N/A if (CxITERVAR(cx)) { \
1N/A SV **s_v_p = CxITERVAR(cx); \
1N/A sv_2mortal(*s_v_p); \
1N/A *s_v_p = cx->blk_loop.itersave; \
1N/A } \
1N/A if (cx->blk_loop.iterary && cx->blk_loop.iterary != PL_curstack)\
1N/A SvREFCNT_dec(cx->blk_loop.iterary);
1N/A
1N/A/* context common to subroutines, evals and loops */
1N/Astruct block {
1N/A I32 blku_oldsp; /* stack pointer to copy stuff down to */
1N/A COP * blku_oldcop; /* old curcop pointer */
1N/A I32 blku_oldretsp; /* return stack index */
1N/A I32 blku_oldmarksp; /* mark stack index */
1N/A I32 blku_oldscopesp; /* scope stack index */
1N/A PMOP * blku_oldpm; /* values of pattern match vars */
1N/A U8 blku_gimme; /* is this block running in list context? */
1N/A
1N/A union {
1N/A struct block_sub blku_sub;
1N/A struct block_eval blku_eval;
1N/A struct block_loop blku_loop;
1N/A } blk_u;
1N/A};
1N/A#define blk_oldsp cx_u.cx_blk.blku_oldsp
1N/A#define blk_oldcop cx_u.cx_blk.blku_oldcop
1N/A#define blk_oldretsp cx_u.cx_blk.blku_oldretsp
1N/A#define blk_oldmarksp cx_u.cx_blk.blku_oldmarksp
1N/A#define blk_oldscopesp cx_u.cx_blk.blku_oldscopesp
1N/A#define blk_oldpm cx_u.cx_blk.blku_oldpm
1N/A#define blk_gimme cx_u.cx_blk.blku_gimme
1N/A#define blk_sub cx_u.cx_blk.blk_u.blku_sub
1N/A#define blk_eval cx_u.cx_blk.blk_u.blku_eval
1N/A#define blk_loop cx_u.cx_blk.blk_u.blku_loop
1N/A
1N/A/* Enter a block. */
1N/A#define PUSHBLOCK(cx,t,sp) CXINC, cx = &cxstack[cxstack_ix], \
1N/A cx->cx_type = t, \
1N/A cx->blk_oldsp = sp - PL_stack_base, \
1N/A cx->blk_oldcop = PL_curcop, \
1N/A cx->blk_oldmarksp = PL_markstack_ptr - PL_markstack, \
1N/A cx->blk_oldscopesp = PL_scopestack_ix, \
1N/A cx->blk_oldretsp = PL_retstack_ix, \
1N/A cx->blk_oldpm = PL_curpm, \
1N/A cx->blk_gimme = (U8)gimme; \
1N/A DEBUG_l( PerlIO_printf(Perl_debug_log, "Entering block %ld, type %s\n", \
1N/A (long)cxstack_ix, PL_block_type[CxTYPE(cx)]); )
1N/A
1N/A/* Exit a block (RETURN and LAST). */
1N/A#define POPBLOCK(cx,pm) cx = &cxstack[cxstack_ix--], \
1N/A newsp = PL_stack_base + cx->blk_oldsp, \
1N/A PL_curcop = cx->blk_oldcop, \
1N/A PL_markstack_ptr = PL_markstack + cx->blk_oldmarksp, \
1N/A PL_scopestack_ix = cx->blk_oldscopesp, \
1N/A PL_retstack_ix = cx->blk_oldretsp, \
1N/A pm = cx->blk_oldpm, \
1N/A gimme = cx->blk_gimme; \
1N/A DEBUG_SCOPE("POPBLOCK"); \
1N/A DEBUG_l( PerlIO_printf(Perl_debug_log, "Leaving block %ld, type %s\n", \
1N/A (long)cxstack_ix+1,PL_block_type[CxTYPE(cx)]); )
1N/A
1N/A/* Continue a block elsewhere (NEXT and REDO). */
1N/A#define TOPBLOCK(cx) cx = &cxstack[cxstack_ix], \
1N/A PL_stack_sp = PL_stack_base + cx->blk_oldsp, \
1N/A PL_markstack_ptr = PL_markstack + cx->blk_oldmarksp, \
1N/A PL_scopestack_ix = cx->blk_oldscopesp, \
1N/A PL_retstack_ix = cx->blk_oldretsp, \
1N/A PL_curpm = cx->blk_oldpm; \
1N/A DEBUG_SCOPE("TOPBLOCK");
1N/A
1N/A/* substitution context */
1N/Astruct subst {
1N/A I32 sbu_iters;
1N/A I32 sbu_maxiters;
1N/A I32 sbu_rflags;
1N/A I32 sbu_oldsave;
1N/A bool sbu_once;
1N/A bool sbu_rxtainted;
1N/A char * sbu_orig;
1N/A SV * sbu_dstr;
1N/A SV * sbu_targ;
1N/A char * sbu_s;
1N/A char * sbu_m;
1N/A char * sbu_strend;
1N/A void * sbu_rxres;
1N/A REGEXP * sbu_rx;
1N/A};
1N/A#define sb_iters cx_u.cx_subst.sbu_iters
1N/A#define sb_maxiters cx_u.cx_subst.sbu_maxiters
1N/A#define sb_rflags cx_u.cx_subst.sbu_rflags
1N/A#define sb_oldsave cx_u.cx_subst.sbu_oldsave
1N/A#define sb_once cx_u.cx_subst.sbu_once
1N/A#define sb_rxtainted cx_u.cx_subst.sbu_rxtainted
1N/A#define sb_orig cx_u.cx_subst.sbu_orig
1N/A#define sb_dstr cx_u.cx_subst.sbu_dstr
1N/A#define sb_targ cx_u.cx_subst.sbu_targ
1N/A#define sb_s cx_u.cx_subst.sbu_s
1N/A#define sb_m cx_u.cx_subst.sbu_m
1N/A#define sb_strend cx_u.cx_subst.sbu_strend
1N/A#define sb_rxres cx_u.cx_subst.sbu_rxres
1N/A#define sb_rx cx_u.cx_subst.sbu_rx
1N/A
1N/A#define PUSHSUBST(cx) CXINC, cx = &cxstack[cxstack_ix], \
1N/A cx->sb_iters = iters, \
1N/A cx->sb_maxiters = maxiters, \
1N/A cx->sb_rflags = r_flags, \
1N/A cx->sb_oldsave = oldsave, \
1N/A cx->sb_once = once, \
1N/A cx->sb_rxtainted = rxtainted, \
1N/A cx->sb_orig = orig, \
1N/A cx->sb_dstr = dstr, \
1N/A cx->sb_targ = targ, \
1N/A cx->sb_s = s, \
1N/A cx->sb_m = m, \
1N/A cx->sb_strend = strend, \
1N/A cx->sb_rxres = Null(void*), \
1N/A cx->sb_rx = rx, \
1N/A cx->cx_type = CXt_SUBST; \
1N/A rxres_save(&cx->sb_rxres, rx)
1N/A
1N/A#define POPSUBST(cx) cx = &cxstack[cxstack_ix--]; \
1N/A rxres_free(&cx->sb_rxres)
1N/A
1N/Astruct context {
1N/A U32 cx_type; /* what kind of context this is */
1N/A union {
1N/A struct block cx_blk;
1N/A struct subst cx_subst;
1N/A } cx_u;
1N/A};
1N/A
1N/A#define CXTYPEMASK 0xff
1N/A#define CXt_NULL 0
1N/A#define CXt_SUB 1
1N/A#define CXt_EVAL 2
1N/A#define CXt_LOOP 3
1N/A#define CXt_SUBST 4
1N/A#define CXt_BLOCK 5
1N/A#define CXt_FORMAT 6
1N/A
1N/A/* private flags for CXt_EVAL */
1N/A#define CXp_REAL 0x00000100 /* truly eval'', not a lookalike */
1N/A#define CXp_TRYBLOCK 0x00000200 /* eval{}, not eval'' or similar */
1N/A
1N/A#ifdef USE_ITHREADS
1N/A/* private flags for CXt_LOOP */
1N/A# define CXp_PADVAR 0x00000100 /* itervar lives on pad, iterdata
1N/A has pad offset; if not set,
1N/A iterdata holds GV* */
1N/A# define CxPADLOOP(c) (((c)->cx_type & (CXt_LOOP|CXp_PADVAR)) \
1N/A == (CXt_LOOP|CXp_PADVAR))
1N/A#endif
1N/A
1N/A#define CxTYPE(c) ((c)->cx_type & CXTYPEMASK)
1N/A#define CxREALEVAL(c) (((c)->cx_type & (CXt_EVAL|CXp_REAL)) \
1N/A == (CXt_EVAL|CXp_REAL))
1N/A#define CxTRYBLOCK(c) (((c)->cx_type & (CXt_EVAL|CXp_TRYBLOCK)) \
1N/A == (CXt_EVAL|CXp_TRYBLOCK))
1N/A
1N/A#define CXINC (cxstack_ix < cxstack_max ? ++cxstack_ix : (cxstack_ix = cxinc()))
1N/A
1N/A/*
1N/A=head1 "Gimme" Values
1N/A*/
1N/A
1N/A/*
1N/A=for apidoc AmU||G_SCALAR
1N/AUsed to indicate scalar context. See C<GIMME_V>, C<GIMME>, and
1N/AL<perlcall>.
1N/A
1N/A=for apidoc AmU||G_ARRAY
1N/AUsed to indicate list context. See C<GIMME_V>, C<GIMME> and
1N/AL<perlcall>.
1N/A
1N/A=for apidoc AmU||G_VOID
1N/AUsed to indicate void context. See C<GIMME_V> and L<perlcall>.
1N/A
1N/A=for apidoc AmU||G_DISCARD
1N/AIndicates that arguments returned from a callback should be discarded. See
1N/AL<perlcall>.
1N/A
1N/A=for apidoc AmU||G_EVAL
1N/A
1N/AUsed to force a Perl C<eval> wrapper around a callback. See
1N/AL<perlcall>.
1N/A
1N/A=for apidoc AmU||G_NOARGS
1N/A
1N/AIndicates that no arguments are being sent to a callback. See
1N/AL<perlcall>.
1N/A
1N/A=cut
1N/A*/
1N/A
1N/A#define G_SCALAR 0
1N/A#define G_ARRAY 1
1N/A#define G_VOID 128 /* skip this bit when adding flags below */
1N/A
1N/A/* extra flags for Perl_call_* routines */
1N/A#define G_DISCARD 2 /* Call FREETMPS. */
1N/A#define G_EVAL 4 /* Assume eval {} around subroutine call. */
1N/A#define G_NOARGS 8 /* Don't construct a @_ array. */
1N/A#define G_KEEPERR 16 /* Append errors to $@, don't overwrite it */
1N/A#define G_NODEBUG 32 /* Disable debugging at toplevel. */
1N/A#define G_METHOD 64 /* Calling method. */
1N/A
1N/A/* flag bits for PL_in_eval */
1N/A#define EVAL_NULL 0 /* not in an eval */
1N/A#define EVAL_INEVAL 1 /* some enclosing scope is an eval */
1N/A#define EVAL_WARNONLY 2 /* used by yywarn() when calling yyerror() */
1N/A#define EVAL_KEEPERR 4 /* set by Perl_call_sv if G_KEEPERR */
1N/A#define EVAL_INREQUIRE 8 /* The code is being required. */
1N/A
1N/A/* Support for switching (stack and block) contexts.
1N/A * This ensures magic doesn't invalidate local stack and cx pointers.
1N/A */
1N/A
1N/A#define PERLSI_UNKNOWN -1
1N/A#define PERLSI_UNDEF 0
1N/A#define PERLSI_MAIN 1
1N/A#define PERLSI_MAGIC 2
1N/A#define PERLSI_SORT 3
1N/A#define PERLSI_SIGNAL 4
1N/A#define PERLSI_OVERLOAD 5
1N/A#define PERLSI_DESTROY 6
1N/A#define PERLSI_WARNHOOK 7
1N/A#define PERLSI_DIEHOOK 8
1N/A#define PERLSI_REQUIRE 9
1N/A
1N/Astruct stackinfo {
1N/A AV * si_stack; /* stack for current runlevel */
1N/A PERL_CONTEXT * si_cxstack; /* context stack for runlevel */
1N/A I32 si_cxix; /* current context index */
1N/A I32 si_cxmax; /* maximum allocated index */
1N/A I32 si_type; /* type of runlevel */
1N/A struct stackinfo * si_prev;
1N/A struct stackinfo * si_next;
1N/A I32 si_markoff; /* offset where markstack begins for us.
1N/A * currently used only with DEBUGGING,
1N/A * but not #ifdef-ed for bincompat */
1N/A};
1N/A
1N/Atypedef struct stackinfo PERL_SI;
1N/A
1N/A#define cxstack (PL_curstackinfo->si_cxstack)
1N/A#define cxstack_ix (PL_curstackinfo->si_cxix)
1N/A#define cxstack_max (PL_curstackinfo->si_cxmax)
1N/A
1N/A#ifdef DEBUGGING
1N/A# define SET_MARK_OFFSET \
1N/A PL_curstackinfo->si_markoff = PL_markstack_ptr - PL_markstack
1N/A#else
1N/A# define SET_MARK_OFFSET NOOP
1N/A#endif
1N/A
1N/A#define PUSHSTACKi(type) \
1N/A STMT_START { \
1N/A PERL_SI *next = PL_curstackinfo->si_next; \
1N/A if (!next) { \
1N/A next = new_stackinfo(32, 2048/sizeof(PERL_CONTEXT) - 1); \
1N/A next->si_prev = PL_curstackinfo; \
1N/A PL_curstackinfo->si_next = next; \
1N/A } \
1N/A next->si_type = type; \
1N/A next->si_cxix = -1; \
1N/A AvFILLp(next->si_stack) = 0; \
1N/A SWITCHSTACK(PL_curstack,next->si_stack); \
1N/A PL_curstackinfo = next; \
1N/A SET_MARK_OFFSET; \
1N/A } STMT_END
1N/A
1N/A#define PUSHSTACK PUSHSTACKi(PERLSI_UNKNOWN)
1N/A
1N/A/* POPSTACK works with PL_stack_sp, so it may need to be bracketed by
1N/A * PUTBACK/SPAGAIN to flush/refresh any local SP that may be active */
1N/A#define POPSTACK \
1N/A STMT_START { \
1N/A dSP; \
1N/A PERL_SI *prev = PL_curstackinfo->si_prev; \
1N/A if (!prev) { \
1N/A PerlIO_printf(Perl_error_log, "panic: POPSTACK\n"); \
1N/A my_exit(1); \
1N/A } \
1N/A SWITCHSTACK(PL_curstack,prev->si_stack); \
1N/A /* don't free prev here, free them all at the END{} */ \
1N/A PL_curstackinfo = prev; \
1N/A } STMT_END
1N/A
1N/A#define POPSTACK_TO(s) \
1N/A STMT_START { \
1N/A while (PL_curstack != s) { \
1N/A dounwind(-1); \
1N/A POPSTACK; \
1N/A } \
1N/A } STMT_END
1N/A
1N/A#define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling)
1N/A#define IN_PERL_RUNTIME (PL_curcop != &PL_compiling)
1N/A