3 * Copyright (c) 1991-1994, Larry Wall
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
12 char * cop_label; /* label for this construct */
13 HV * cop_stash; /* package line was compiled in */
14 GV * cop_filegv; /* file the following line # is from */
15 U32 cop_seq; /* parse sequence number */
16 I32 cop_arybase; /* array base this line was compiled with */
17 line_t cop_line; /* line # of this command */
20 #define Nullcop Null(COP*)
23 * Here we have some enormously heavy (or at least ponderous) wizardry.
26 /* subroutine context */
38 cx->blk_sub.cv = cv; \
39 cx->blk_sub.olddepth = CvDEPTH(cv); \
40 cx->blk_sub.hasargs = hasargs;
42 #define PUSHFORMAT(cx) \
43 cx->blk_sub.cv = cv; \
44 cx->blk_sub.gv = gv; \
45 cx->blk_sub.hasargs = 0; \
46 cx->blk_sub.dfoutgv = defoutgv; \
47 (void)SvREFCNT_inc(cx->blk_sub.dfoutgv)
49 /* We muck with cxstack_ix since _dec may call a DESTROY, overwriting cx. */
52 if (cx->blk_sub.hasargs) { /* put back old @_ */ \
53 GvAV(defgv) = cx->blk_sub.savearray; \
55 if (cx->blk_sub.cv) { \
56 if (!(CvDEPTH(cx->blk_sub.cv) = cx->blk_sub.olddepth)) { \
57 if (cx->blk_sub.hasargs) { \
58 SvREFCNT_inc((SV*)cx->blk_sub.argarray); \
61 SvREFCNT_dec((SV*)cx->blk_sub.cv); \
66 #define POPFORMAT(cx) \
67 setdefout(cx->blk_sub.dfoutgv); \
68 SvREFCNT_dec(cx->blk_sub.dfoutgv);
79 #define PUSHEVAL(cx,n,fgv) \
80 cx->blk_eval.old_in_eval = in_eval; \
81 cx->blk_eval.old_op_type = op->op_type; \
82 cx->blk_eval.old_name = n; \
83 cx->blk_eval.old_eval_root = eval_root; \
84 cx->blk_eval.cur_text = linestr;
87 in_eval = cx->blk_eval.old_in_eval; \
88 optype = cx->blk_eval.old_op_type; \
89 eval_root = cx->blk_eval.old_eval_root;
105 #define PUSHLOOP(cx, ivar, s) \
106 cx->blk_loop.label = curcop->cop_label; \
107 cx->blk_loop.resetsp = s - stack_base; \
108 cx->blk_loop.redo_op = cLOOP->op_redoop; \
109 cx->blk_loop.next_op = cLOOP->op_nextop; \
110 cx->blk_loop.last_op = cLOOP->op_lastop; \
111 cx->blk_loop.iterlval = Nullsv; \
112 if (cx->blk_loop.itervar = (ivar)) \
113 cx->blk_loop.itersave = SvREFCNT_inc(*cx->blk_loop.itervar);
115 #define POPLOOP(cx) \
116 newsp = stack_base + cx->blk_loop.resetsp; \
117 SvREFCNT_dec(cx->blk_loop.iterlval); \
118 if (cx->blk_loop.itervar) { \
119 SvREFCNT_dec(*cx->blk_loop.itervar); \
120 *cx->blk_loop.itervar = cx->blk_loop.itersave; \
123 /* context common to subroutines, evals and loops */
125 I32 blku_oldsp; /* stack pointer to copy stuff down to */
126 COP * blku_oldcop; /* old curcop pointer */
127 I32 blku_oldretsp; /* return stack index */
128 I32 blku_oldmarksp; /* mark stack index */
129 I32 blku_oldscopesp; /* scope stack index */
130 PMOP * blku_oldpm; /* values of pattern match vars */
131 U8 blku_gimme; /* is this block running in list context? */
134 struct block_sub blku_sub;
135 struct block_eval blku_eval;
136 struct block_loop blku_loop;
139 #define blk_oldsp cx_u.cx_blk.blku_oldsp
140 #define blk_oldcop cx_u.cx_blk.blku_oldcop
141 #define blk_oldretsp cx_u.cx_blk.blku_oldretsp
142 #define blk_oldmarksp cx_u.cx_blk.blku_oldmarksp
143 #define blk_oldscopesp cx_u.cx_blk.blku_oldscopesp
144 #define blk_oldpm cx_u.cx_blk.blku_oldpm
145 #define blk_gimme cx_u.cx_blk.blku_gimme
146 #define blk_sub cx_u.cx_blk.blk_u.blku_sub
147 #define blk_eval cx_u.cx_blk.blk_u.blku_eval
148 #define blk_loop cx_u.cx_blk.blk_u.blku_loop
151 #define PUSHBLOCK(cx,t,sp) CXINC, cx = &cxstack[cxstack_ix], \
153 cx->blk_oldsp = sp - stack_base, \
154 cx->blk_oldcop = curcop, \
155 cx->blk_oldmarksp = markstack_ptr - markstack, \
156 cx->blk_oldscopesp = scopestack_ix, \
157 cx->blk_oldretsp = retstack_ix, \
158 cx->blk_oldpm = curpm, \
159 cx->blk_gimme = gimme; \
160 DEBUG_l( PerlIO_printf(PerlIO_stderr(), "Entering block %ld, type %s\n", \
161 (long)cxstack_ix, block_type[t]); )
163 /* Exit a block (RETURN and LAST). */
164 #define POPBLOCK(cx,pm) cx = &cxstack[cxstack_ix--], \
165 newsp = stack_base + cx->blk_oldsp, \
166 curcop = cx->blk_oldcop, \
167 markstack_ptr = markstack + cx->blk_oldmarksp, \
168 scopestack_ix = cx->blk_oldscopesp, \
169 retstack_ix = cx->blk_oldretsp, \
170 pm = cx->blk_oldpm, \
171 gimme = cx->blk_gimme; \
172 DEBUG_l( PerlIO_printf(PerlIO_stderr(), "Leaving block %ld, type %s\n", \
173 (long)cxstack_ix+1,block_type[cx->cx_type]); )
175 /* Continue a block elsewhere (NEXT and REDO). */
176 #define TOPBLOCK(cx) cx = &cxstack[cxstack_ix], \
177 stack_sp = stack_base + cx->blk_oldsp, \
178 markstack_ptr = markstack + cx->blk_oldmarksp, \
179 scopestack_ix = cx->blk_oldscopesp, \
180 retstack_ix = cx->blk_oldretsp
182 /* substitution context */
199 #define sb_iters cx_u.cx_subst.sbu_iters
200 #define sb_maxiters cx_u.cx_subst.sbu_maxiters
201 #define sb_safebase cx_u.cx_subst.sbu_safebase
202 #define sb_oldsave cx_u.cx_subst.sbu_oldsave
203 #define sb_once cx_u.cx_subst.sbu_once
204 #define sb_rxtainted cx_u.cx_subst.sbu_rxtainted
205 #define sb_orig cx_u.cx_subst.sbu_orig
206 #define sb_dstr cx_u.cx_subst.sbu_dstr
207 #define sb_targ cx_u.cx_subst.sbu_targ
208 #define sb_s cx_u.cx_subst.sbu_s
209 #define sb_m cx_u.cx_subst.sbu_m
210 #define sb_strend cx_u.cx_subst.sbu_strend
211 #define sb_subbase cx_u.cx_subst.sbu_subbase
212 #define sb_rx cx_u.cx_subst.sbu_rx
214 #define PUSHSUBST(cx) CXINC, cx = &cxstack[cxstack_ix], \
215 cx->sb_iters = iters, \
216 cx->sb_maxiters = maxiters, \
217 cx->sb_safebase = safebase, \
218 cx->sb_oldsave = oldsave, \
219 cx->sb_once = once, \
220 cx->sb_rxtainted = rxtainted, \
221 cx->sb_orig = orig, \
222 cx->sb_dstr = dstr, \
223 cx->sb_targ = targ, \
226 cx->sb_strend = strend, \
228 cx->cx_type = CXt_SUBST
230 #define POPSUBST(cx) cxstack_ix--
233 I32 cx_type; /* what kind of context this is */
236 struct subst cx_subst;
246 #define CXINC (cxstack_ix < cxstack_max ? ++cxstack_ix : (cxstack_ix = cxinc()))
252 /* extra flags for perl_call_* routines */
253 #define G_DISCARD 2 /* Call FREETMPS. */
254 #define G_EVAL 4 /* Assume eval {} around subroutine call. */
255 #define G_NOARGS 8 /* Don't construct a @_ array. */
256 #define G_KEEPERR 16 /* Append errors to $@ rather than overwriting it */