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.
11 * "You see: Mr. Drogo, he married poor Miss Primula Brandybuck. She was
12 * our Mr. Bilbo's first cousin on the mother's side (her mother being the
13 * youngest of the Old Took's daughters); and Mr. Drogo was his second
14 * cousin. So Mr. Frodo is his first *and* second cousin, once removed
15 * either way, as the saying is, if you follow me." --the Gaffer
21 #define USE_OP_MASK /* Turned on by default in 5.002beta1h */
25 * In the following definition, the ", (OP *) op" is just to make the compiler
26 * think the expression is of the right type: croak actually does a Siglongjmp.
28 #define CHECKOP(type,op) \
29 ((op_mask && op_mask[type]) \
30 ? ( op_free((OP*)op), \
31 croak("%s trapped by operation mask", op_desc[type]), \
33 : (*check[type])((OP*)op))
35 #define CHECKOP(type,op) (*check[type])(op)
36 #endif /* USE_OP_MASK */
38 static I32 list_assignment _((OP *op));
39 static OP *bad_type _((I32 n, char *t, char *name, OP *kid));
40 static OP *modkids _((OP *op, I32 type));
41 static OP *no_fh_allowed _((OP *op));
42 static OP *scalarboolean _((OP *op));
43 static OP *too_few_arguments _((OP *op, char* name));
44 static OP *too_many_arguments _((OP *op, char* name));
45 static void null _((OP* op));
46 static PADOFFSET pad_findlex _((char* name, PADOFFSET newoff, U32 seq,
47 CV* startcv, I32 cx_ix));
53 SV* tmpsv = sv_newmortal();
54 gv_efullname3(tmpsv, CvGV(cv), Nullch);
55 return SvPV(tmpsv,na);
62 sprintf(tokenbuf,"Missing comma after first argument to %s function",
63 op_desc[op->op_type]);
69 too_few_arguments(op, name)
73 sprintf(tokenbuf,"Not enough arguments for %s", name);
79 too_many_arguments(op, name)
83 sprintf(tokenbuf,"Too many arguments for %s", name);
89 bad_type(n, t, name, kid)
95 sprintf(tokenbuf, "Type of arg %d to %s must be %s (not %s)",
96 (int) n, name, t, op_desc[kid->op_type]);
105 int type = op->op_type;
106 if (type != OP_AELEM && type != OP_HELEM) {
107 sprintf(tokenbuf, "Can't use subscript on %s", op_desc[type]);
109 if (type == OP_ENTERSUB || type == OP_RV2HV || type == OP_PADHV)
110 warn("(Did you mean $ or @ instead of %c?)\n",
111 type == OP_ENTERSUB ? '&' : '%');
115 /* "register" allocation */
124 if (!(isALPHA(name[1]) || name[1] == '_' && (int)strlen(name) > 2)) {
125 if (!isPRINT(name[1]))
126 sprintf(name+1, "^%c", toCTRL(name[1])); /* XXX tokenbuf, really */
127 croak("Can't use global %s in \"my\"",name);
129 if (AvFILL(comppad_name) >= 0) {
130 SV **svp = AvARRAY(comppad_name);
131 for (off = AvFILL(comppad_name); off > comppad_name_floor; off--) {
134 && SvIVX(sv) == 999999999 /* var is in open scope */
135 && strEQ(name, SvPVX(sv)))
137 warn("\"my\" variable %s masks earlier declaration in same scope", name);
142 off = pad_alloc(OP_PADSV, SVs_PADMY);
144 sv_upgrade(sv, SVt_PVNV);
146 av_store(comppad_name, off, sv);
147 SvNVX(sv) = (double)999999999;
148 SvIVX(sv) = 0; /* Not yet introduced--see newSTATEOP */
149 if (!min_intro_pending)
150 min_intro_pending = off;
151 max_intro_pending = off;
153 av_store(comppad, off, (SV*)newAV());
154 else if (*name == '%')
155 av_store(comppad, off, (SV*)newHV());
156 SvPADMY_on(curpad[off]);
161 #ifndef CAN_PROTOTYPE
162 pad_findlex(name, newoff, seq, startcv, cx_ix)
169 pad_findlex(char *name, PADOFFSET newoff, U32 seq, CV* startcv, I32 cx_ix)
176 register CONTEXT *cx;
179 for (cv = startcv; cv; cv = CvOUTSIDE(cv)) {
180 AV* curlist = CvPADLIST(cv);
181 SV** svp = av_fetch(curlist, 0, FALSE);
183 if (!svp || *svp == &sv_undef)
186 svp = AvARRAY(curname);
187 for (off = AvFILL(curname); off > 0; off--) {
188 if ((sv = svp[off]) &&
191 seq > I_32(SvNVX(sv)) &&
192 strEQ(SvPVX(sv), name))
200 if (newoff && !CvUNIQUE(cv))
201 return 0; /* don't clone inactive sub's stack frame */
204 oldpad = (AV*)*av_fetch(curlist, depth, FALSE);
205 oldsv = *av_fetch(oldpad, off, TRUE);
206 if (!newoff) { /* Not a mere clone operation. */
207 SV *sv = NEWSV(1103,0);
208 newoff = pad_alloc(OP_PADSV, SVs_PADMY);
209 sv_upgrade(sv, SVt_PVNV);
211 av_store(comppad_name, newoff, sv);
212 SvNVX(sv) = (double)curcop->cop_seq;
213 SvIVX(sv) = 999999999; /* A ref, intro immediately */
214 SvFLAGS(sv) |= SVf_FAKE;
215 if (CvANON(compcv)) {
216 /* "It's closures all the way down." */
221 bcv && bcv != cv && !CvCLONE(bcv);
222 bcv = CvOUTSIDE(bcv)) {
227 warn("Value of %s may be unavailable",
235 if (dowarn && !CvUNIQUE(cv))
236 warn("Value of %s will not stay shared", name);
239 av_store(comppad, newoff, SvREFCNT_inc(oldsv));
245 /* Nothing in current lexical context--try eval's context, if any.
246 * This is necessary to let the perldb get at lexically scoped variables.
247 * XXX This will also probably interact badly with eval tree caching.
251 for (i = cx_ix; i >= 0; i--) {
253 switch (cx->cx_type) {
255 if (i == 0 && saweval) {
256 seq = cxstack[saweval].blk_oldcop->cop_seq;
257 return pad_findlex(name, newoff, seq, main_cv, 0);
261 if (cx->blk_eval.old_op_type != OP_ENTEREVAL &&
262 cx->blk_eval.old_op_type != OP_ENTERTRY)
263 return 0; /* require must have its own scope */
270 if (debstash && CvSTASH(cv) == debstash) { /* ignore DB'* scope */
271 saweval = i; /* so we know where we were called from */
274 seq = cxstack[saweval].blk_oldcop->cop_seq;
275 return pad_findlex(name, newoff, seq, cv, i-1);
288 SV **svp = AvARRAY(comppad_name);
289 U32 seq = cop_seqmax;
291 /* The one we're looking for is probably just before comppad_name_fill. */
292 for (off = AvFILL(comppad_name); off > 0; off--) {
293 if ((sv = svp[off]) &&
296 seq > I_32(SvNVX(sv)) &&
297 strEQ(SvPVX(sv), name))
299 return (PADOFFSET)off;
303 /* See if it's in a nested scope */
304 off = pad_findlex(name, 0, seq, CvOUTSIDE(compcv), cxstack_ix);
316 SV **svp = AvARRAY(comppad_name);
318 if (min_intro_pending && fill < min_intro_pending) {
319 for (off = max_intro_pending; off >= min_intro_pending; off--) {
320 if ((sv = svp[off]) && sv != &sv_undef)
321 warn("%s never introduced", SvPVX(sv));
324 /* "Deintroduce" my variables that are leaving with this scope. */
325 for (off = AvFILL(comppad_name); off > fill; off--) {
326 if ((sv = svp[off]) && sv != &sv_undef && SvIVX(sv) == 999999999)
327 SvIVX(sv) = cop_seqmax;
332 pad_alloc(optype,tmptype)
339 if (AvARRAY(comppad) != curpad)
340 croak("panic: pad_alloc");
341 if (pad_reset_pending)
343 if (tmptype & SVs_PADMY) {
345 sv = *av_fetch(comppad, AvFILL(comppad) + 1, TRUE);
346 } while (SvPADBUSY(sv)); /* need a fresh one */
347 retval = AvFILL(comppad);
350 SV **names = AvARRAY(comppad_name);
351 SSize_t names_fill = AvFILL(comppad_name);
354 * "foreach" index vars temporarily become aliases to non-"my"
355 * values. Thus we must skip, not just pad values that are
356 * marked as current pad values, but also those with names.
358 if (++padix <= names_fill &&
359 (sv = names[padix]) && sv != &sv_undef)
361 sv = *av_fetch(comppad, padix, TRUE);
362 if (!(SvFLAGS(sv) & (SVs_PADTMP|SVs_PADMY)))
367 SvFLAGS(sv) |= tmptype;
368 curpad = AvARRAY(comppad);
369 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad alloc %ld for %s\n", (long) retval, op_name[optype]));
370 return (PADOFFSET)retval;
374 #ifndef CAN_PROTOTYPE
379 #endif /* CAN_PROTOTYPE */
382 croak("panic: pad_sv po");
383 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad sv %d\n", po));
384 return curpad[po]; /* eventually we'll turn this into a macro */
388 #ifndef CAN_PROTOTYPE
392 pad_free(PADOFFSET po)
393 #endif /* CAN_PROTOTYPE */
397 if (AvARRAY(comppad) != curpad)
398 croak("panic: pad_free curpad");
400 croak("panic: pad_free po");
401 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad free %d\n", po));
402 if (curpad[po] && curpad[po] != &sv_undef)
403 SvPADTMP_off(curpad[po]);
409 #ifndef CAN_PROTOTYPE
413 pad_swipe(PADOFFSET po)
414 #endif /* CAN_PROTOTYPE */
416 if (AvARRAY(comppad) != curpad)
417 croak("panic: pad_swipe curpad");
419 croak("panic: pad_swipe po");
420 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad swipe %d\n", po));
421 SvPADTMP_off(curpad[po]);
422 curpad[po] = NEWSV(1107,0);
423 SvPADTMP_on(curpad[po]);
433 if (AvARRAY(comppad) != curpad)
434 croak("panic: pad_reset curpad");
435 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad reset\n"));
436 if (!tainting) { /* Can't mix tainted and non-tainted temporaries. */
437 for (po = AvMAX(comppad); po > padix_floor; po--) {
438 if (curpad[po] && curpad[po] != &sv_undef)
439 SvPADTMP_off(curpad[po]);
443 pad_reset_pending = FALSE;
452 register OP *kid, *nextkid;
454 if (!op || op->op_seq == (U16)-1)
457 if (op->op_flags & OPf_KIDS) {
458 for (kid = cUNOP->op_first; kid; kid = nextkid) {
459 nextkid = kid->op_sibling; /* Get before next freeing kid */
464 switch (op->op_type) {
466 op->op_targ = 0; /* Was holding old type, if any. */
469 op->op_targ = 0; /* Was holding hints. */
472 if (!(op->op_flags & OPf_REF) || (check[op->op_type] != ck_ftst))
478 SvREFCNT_dec(cGVOP->op_gv);
482 Safefree(cCOP->cop_label);
483 SvREFCNT_dec(cCOP->cop_filegv);
486 SvREFCNT_dec(cSVOP->op_sv);
492 if (op->op_flags & (OPf_SPECIAL|OPf_STACKED|OPf_KIDS))
496 Safefree(cPVOP->op_pv);
499 op_free(cPMOP->op_pmreplroot);
503 pregfree(cPMOP->op_pmregexp);
504 SvREFCNT_dec(cPMOP->op_pmshort);
509 pad_free(op->op_targ);
518 if (op->op_type != OP_NULL && op->op_targ > 0)
519 pad_free(op->op_targ);
520 op->op_targ = op->op_type;
521 op->op_type = OP_NULL;
522 op->op_ppaddr = ppaddr[OP_NULL];
525 /* Contextualizers */
527 #define LINKLIST(o) ((o)->op_next ? (o)->op_next : linklist((OP*)o))
538 /* establish postfix order */
539 if (cUNOP->op_first) {
540 op->op_next = LINKLIST(cUNOP->op_first);
541 for (kid = cUNOP->op_first; kid; kid = kid->op_sibling) {
543 kid->op_next = LINKLIST(kid->op_sibling);
559 if (op && op->op_flags & OPf_KIDS) {
560 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
571 op->op_type == OP_SASSIGN && cBINOP->op_first->op_type == OP_CONST) {
572 line_t oldline = curcop->cop_line;
574 if (copline != NOLINE)
575 curcop->cop_line = copline;
576 warn("Found = in conditional, should be ==");
577 curcop->cop_line = oldline;
588 /* assumes no premature commitment */
589 if (!op || (op->op_flags & OPf_KNOW) || op->op_type == OP_RETURN
593 op->op_flags &= ~OPf_LIST;
594 op->op_flags |= OPf_KNOW;
596 switch (op->op_type) {
598 if (op->op_private & OPpREPEAT_DOLIST)
599 null(((LISTOP*)cBINOP->op_first)->op_first);
600 scalar(cBINOP->op_first);
605 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
609 if ((kid = ((LISTOP*)op)->op_first) && kid->op_type == OP_PUSHRE) {
610 if (!kPMOP->op_pmreplroot)
611 deprecate("implicit split to @_");
618 if (op->op_flags & OPf_KIDS) {
619 for (kid = cUNOP->op_first; kid; kid = kid->op_sibling)
625 scalar(cLISTOP->op_first);
630 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling) {
650 if (!op || error_count)
652 if (op->op_flags & OPf_LIST)
655 op->op_flags |= OPf_KNOW;
657 switch (op->op_type) {
659 if (!(opargs[op->op_type] & OA_FOLDCONST))
663 if (op->op_flags & OPf_STACKED)
736 if (!(op->op_private & OPpLVAL_INTRO))
737 useless = op_desc[op->op_type];
744 if (!(op->op_private & OPpLVAL_INTRO) &&
745 (!op->op_sibling || op->op_sibling->op_type != OP_READLINE))
746 useless = "a variable";
751 curcop = ((COP*)op); /* for warning below */
757 useless = "a constant";
758 if (SvNIOK(sv) && (SvNV(sv) == 0.0 || SvNV(sv) == 1.0))
760 else if (SvPOK(sv)) {
761 if (strnEQ(SvPVX(sv), "di", 2) ||
762 strnEQ(SvPVX(sv), "ds", 2) ||
763 strnEQ(SvPVX(sv), "ig", 2))
767 null(op); /* don't execute a constant */
768 SvREFCNT_dec(sv); /* don't even remember it */
772 op->op_type = OP_PREINC; /* pre-increment is faster */
773 op->op_ppaddr = ppaddr[OP_PREINC];
777 op->op_type = OP_PREDEC; /* pre-decrement is faster */
778 op->op_ppaddr = ppaddr[OP_PREDEC];
784 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
788 if (op->op_targ == OP_NEXTSTATE || op->op_targ == OP_DBSTATE)
789 curcop = ((COP*)op); /* for warning below */
790 if (op->op_flags & OPf_STACKED)
795 if (!(op->op_flags & OPf_KIDS))
801 op->op_private |= OPpLEAVE_VOID;
804 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
808 if ((kid = ((LISTOP*)op)->op_first) && kid->op_type == OP_PUSHRE) {
809 if (!kPMOP->op_pmreplroot)
810 deprecate("implicit split to @_");
814 op->op_private |= OPpLEAVE_VOID;
817 if (useless && dowarn)
818 warn("Useless use of %s in void context", useless);
827 if (op && op->op_flags & OPf_KIDS) {
828 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
840 /* assumes no premature commitment */
841 if (!op || (op->op_flags & OPf_KNOW) || op->op_type == OP_RETURN
845 op->op_flags |= (OPf_KNOW | OPf_LIST);
847 switch (op->op_type) {
850 list(cBINOP->op_first);
855 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
862 if (!(op->op_flags & OPf_KIDS))
864 if (!op->op_next && cUNOP->op_first->op_type == OP_FLOP) {
865 list(cBINOP->op_first);
866 return gen_constant_list(op);
873 list(cLISTOP->op_first);
877 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling) {
896 if (op->op_type == OP_LINESEQ ||
897 op->op_type == OP_SCOPE ||
898 op->op_type == OP_LEAVE ||
899 op->op_type == OP_LEAVETRY)
901 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling) {
902 if (kid->op_sibling) {
908 op->op_flags &= ~OPf_PARENS;
909 if (hints & HINT_BLOCK_SCOPE)
910 op->op_flags |= OPf_PARENS;
913 op = newOP(OP_STUB, 0);
923 if (op && op->op_flags & OPf_KIDS) {
924 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
940 if (!op || error_count)
943 switch (op->op_type) {
945 if (!(op->op_private & (OPpCONST_ARYBASE)))
947 if (eval_start && eval_start->op_type == OP_CONST) {
948 compiling.cop_arybase = (I32)SvIV(((SVOP*)eval_start)->op_sv);
952 SAVEI32(compiling.cop_arybase);
953 compiling.cop_arybase = 0;
955 else if (type == OP_REFGEN)
958 croak("That use of $[ is unsupported");
961 if (op->op_flags & OPf_PARENS)
965 if ((type == OP_UNDEF || type == OP_REFGEN) &&
966 !(op->op_flags & OPf_STACKED)) {
967 op->op_type = OP_RV2CV; /* entersub => rv2cv */
968 op->op_ppaddr = ppaddr[OP_RV2CV];
969 assert(cUNOP->op_first->op_type == OP_NULL);
970 null(((LISTOP*)cUNOP->op_first)->op_first); /* disable pushmark */
976 /* grep, foreach, subcalls, refgen */
977 if (type == OP_GREPSTART || type == OP_ENTERSUB || type == OP_REFGEN)
979 sprintf(tokenbuf, "Can't modify %s in %s",
980 op_desc[op->op_type],
981 type ? op_desc[type] : "local");
1005 if (!(op->op_flags & OPf_STACKED))
1011 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
1017 if (type == OP_REFGEN && op->op_flags & OPf_PARENS) {
1019 return op; /* Treat \(@foo) like ordinary list. */
1023 ref(cUNOP->op_first, op->op_type);
1035 if (!type && cUNOP->op_first->op_type != OP_GV)
1036 croak("Can't localize a reference");
1037 ref(cUNOP->op_first, op->op_type);
1050 if (type == OP_REFGEN && op->op_flags & OPf_PARENS)
1051 return op; /* Treat \(@foo) like ordinary list. */
1056 croak("Can't localize lexical variable %s",
1057 SvPV(*av_fetch(comppad_name, op->op_targ, 4), na));
1064 if (type != OP_SASSIGN)
1070 pad_free(op->op_targ);
1071 op->op_targ = pad_alloc(op->op_type, SVs_PADMY);
1072 assert(SvTYPE(PAD_SV(op->op_targ)) == SVt_NULL);
1073 if (op->op_flags & OPf_KIDS)
1074 mod(cBINOP->op_first->op_sibling, type);
1079 ref(cBINOP->op_first, op->op_type);
1086 if (op->op_flags & OPf_KIDS)
1087 mod(cLISTOP->op_last, type);
1091 if (!(op->op_flags & OPf_KIDS))
1093 if (op->op_targ != OP_LIST) {
1094 mod(cBINOP->op_first, type);
1099 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
1103 op->op_flags |= OPf_MOD;
1105 if (type == OP_AASSIGN || type == OP_SASSIGN)
1106 op->op_flags |= OPf_SPECIAL|OPf_REF;
1108 op->op_private |= OPpLVAL_INTRO;
1109 op->op_flags &= ~OPf_SPECIAL;
1111 else if (type != OP_GREPSTART && type != OP_ENTERSUB)
1112 op->op_flags |= OPf_REF;
1122 if (op && op->op_flags & OPf_KIDS) {
1123 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
1136 if (!op || error_count)
1139 switch (op->op_type) {
1141 if ((type == OP_DEFINED) &&
1142 !(op->op_flags & OPf_STACKED)) {
1143 op->op_type = OP_RV2CV; /* entersub => rv2cv */
1144 op->op_ppaddr = ppaddr[OP_RV2CV];
1145 assert(cUNOP->op_first->op_type == OP_NULL);
1146 null(((LISTOP*)cUNOP->op_first)->op_first); /* disable pushmark */
1147 op->op_flags |= OPf_SPECIAL;
1152 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
1156 ref(cUNOP->op_first, op->op_type);
1159 if (type == OP_RV2SV || type == OP_RV2AV || type == OP_RV2HV) {
1160 op->op_private |= (type == OP_RV2AV ? OPpDEREF_AV
1161 : type == OP_RV2HV ? OPpDEREF_HV
1163 op->op_flags |= OPf_MOD;
1169 op->op_flags |= OPf_REF;
1172 ref(cUNOP->op_first, op->op_type);
1177 op->op_flags |= OPf_REF;
1182 if (!(op->op_flags & OPf_KIDS))
1184 ref(cBINOP->op_first, type);
1188 ref(cBINOP->op_first, op->op_type);
1189 if (type == OP_RV2SV || type == OP_RV2AV || type == OP_RV2HV) {
1190 op->op_private |= (type == OP_RV2AV ? OPpDEREF_AV
1191 : type == OP_RV2HV ? OPpDEREF_HV
1193 op->op_flags |= OPf_MOD;
1201 if (!(op->op_flags & OPf_KIDS))
1203 ref(cLISTOP->op_last, type);
1219 if (!op || error_count)
1223 if (type == OP_LIST) {
1224 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
1227 else if (type != OP_PADSV &&
1230 type != OP_PUSHMARK)
1232 sprintf(tokenbuf, "Can't declare %s in my", op_desc[op->op_type]);
1236 op->op_flags |= OPf_MOD;
1237 op->op_private |= OPpLVAL_INTRO;
1246 o->op_flags |= OPf_PARENS;
1251 bind_match(type, left, right)
1258 if (right->op_type == OP_MATCH ||
1259 right->op_type == OP_SUBST ||
1260 right->op_type == OP_TRANS) {
1261 right->op_flags |= OPf_STACKED;
1262 if (right->op_type != OP_MATCH)
1263 left = mod(left, right->op_type);
1264 if (right->op_type == OP_TRANS)
1265 op = newBINOP(OP_NULL, OPf_STACKED, scalar(left), right);
1267 op = prepend_elem(right->op_type, scalar(left), right);
1269 return newUNOP(OP_NOT, 0, scalar(op));
1273 return bind_match(type, left,
1274 pmruntime(newPMOP(OP_MATCH, 0), right, Nullop));
1283 /* XXX need to optimize away NOT NOT here? Or do we let optimizer do it? */
1284 return newUNOP(OP_NOT, OPf_SPECIAL, scalar(op));
1292 if (o->op_flags & OPf_PARENS || perldb || tainting) {
1293 o = prepend_elem(OP_LINESEQ, newOP(OP_ENTER, 0), o);
1294 o->op_type = OP_LEAVE;
1295 o->op_ppaddr = ppaddr[OP_LEAVE];
1298 if (o->op_type == OP_LINESEQ) {
1300 o->op_type = OP_SCOPE;
1301 o->op_ppaddr = ppaddr[OP_SCOPE];
1302 kid = ((LISTOP*)o)->op_first;
1303 if (kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE){
1304 SvREFCNT_dec(((COP*)kid)->cop_filegv);
1309 o = newLISTOP(OP_SCOPE, 0, o, Nullop);
1319 int retval = savestack_ix;
1320 SAVEI32(comppad_name_floor);
1322 if ((comppad_name_fill = AvFILL(comppad_name)) > 0)
1323 comppad_name_floor = comppad_name_fill;
1325 comppad_name_floor = 0;
1327 SAVEI32(min_intro_pending);
1328 SAVEI32(max_intro_pending);
1329 min_intro_pending = 0;
1330 SAVEI32(comppad_name_fill);
1331 SAVEI32(padix_floor);
1332 padix_floor = padix;
1333 pad_reset_pending = FALSE;
1335 hints &= ~HINT_BLOCK_SCOPE;
1340 block_end(floor, seq)
1344 int needblockscope = hints & HINT_BLOCK_SCOPE;
1345 OP* retval = scalarseq(seq);
1347 pad_reset_pending = FALSE;
1349 hints |= HINT_BLOCK_SCOPE; /* propagate out */
1350 pad_leavemy(comppad_name_fill);
1360 eval_root = newUNOP(OP_LEAVEEVAL, ((in_eval & 4) ? OPf_SPECIAL : 0), op);
1361 eval_start = linklist(eval_root);
1362 eval_root->op_next = 0;
1370 main_root = scope(sawparens(scalarvoid(op)));
1371 curcop = &compiling;
1372 main_start = LINKLIST(main_root);
1373 main_root->op_next = 0;
1385 if (o->op_flags & OPf_PARENS)
1389 if (dowarn && bufptr > oldbufptr && bufptr[-1] == ',') {
1391 for (s = bufptr; *s && (isALNUM(*s) || strchr("@$%, ",*s)); s++) ;
1392 if (*s == ';' || *s == '=')
1393 warn("Parens missing around \"%s\" list", lex ? "my" : "local");
1400 return mod(o, OP_NULL); /* a bit kludgey */
1407 if (o->op_type == OP_LIST) {
1408 o = convert(OP_JOIN, 0,
1409 prepend_elem(OP_LIST,
1410 newSVREF(newGVOP(OP_GV, 0, gv_fetchpv(";", TRUE, SVt_PV))),
1421 I32 type = o->op_type;
1424 if (opargs[type] & OA_RETSCALAR)
1426 if (opargs[type] & OA_TARGET)
1427 o->op_targ = pad_alloc(type, SVs_PADTMP);
1429 if ((opargs[type] & OA_OTHERINT) && (hints & HINT_INTEGER))
1430 o->op_ppaddr = ppaddr[type = ++(o->op_type)];
1432 if (!(opargs[type] & OA_FOLDCONST))
1436 goto nope; /* Don't try to run w/ errors */
1438 for (curop = LINKLIST(o); curop != o; curop = LINKLIST(curop)) {
1439 if (curop->op_type != OP_CONST &&
1440 curop->op_type != OP_LIST &&
1441 curop->op_type != OP_SCALAR &&
1442 curop->op_type != OP_NULL &&
1443 curop->op_type != OP_PUSHMARK) {
1448 curop = LINKLIST(o);
1453 if (o->op_targ && sv == PAD_SV(o->op_targ)) /* grab pad temp? */
1454 pad_swipe(o->op_targ);
1455 else if (SvTEMP(sv)) { /* grab mortal temp? */
1456 (void)SvREFCNT_inc(sv);
1460 if (type == OP_RV2GV)
1461 return newGVOP(OP_GV, 0, (GV*)sv);
1463 if ((SvFLAGS(sv) & (SVf_IOK|SVf_NOK|SVf_POK)) == SVf_NOK) {
1465 if ((double)iv == SvNV(sv)) { /* can we smush double to int */
1470 SvIOK_off(sv); /* undo SvIV() damage */
1472 return newSVOP(OP_CONST, 0, sv);
1476 if (!(opargs[type] & OA_OTHERINT))
1479 if (!(hints & HINT_INTEGER)) {
1480 if (type == OP_DIVIDE || !(o->op_flags & OPf_KIDS))
1483 for (curop = ((UNOP*)o)->op_first; curop; curop = curop->op_sibling) {
1484 if (curop->op_type == OP_CONST) {
1485 if (SvIOK(((SVOP*)curop)->op_sv))
1489 if (opargs[curop->op_type] & OA_RETINTEGER)
1493 o->op_ppaddr = ppaddr[++(o->op_type)];
1500 gen_constant_list(o)
1504 I32 oldtmps_floor = tmps_floor;
1508 return o; /* Don't attempt to run with errors */
1510 op = curop = LINKLIST(o);
1516 tmps_floor = oldtmps_floor;
1518 o->op_type = OP_RV2AV;
1519 o->op_ppaddr = ppaddr[OP_RV2AV];
1520 curop = ((UNOP*)o)->op_first;
1521 ((UNOP*)o)->op_first = newSVOP(OP_CONST, 0, SvREFCNT_inc(*stack_sp--));
1528 convert(type, flags, op)
1536 if (!op || op->op_type != OP_LIST)
1537 op = newLISTOP(OP_LIST, 0, op, Nullop);
1539 op->op_flags &= ~(OPf_KNOW|OPf_LIST);
1541 if (!(opargs[type] & OA_MARK))
1542 null(cLISTOP->op_first);
1545 op->op_ppaddr = ppaddr[type];
1546 op->op_flags |= flags;
1548 op = CHECKOP(type, op);
1549 if (op->op_type != type)
1552 if (cLISTOP->op_children < 7) {
1553 /* XXX do we really need to do this if we're done appending?? */
1554 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
1556 cLISTOP->op_last = last; /* in case check substituted last arg */
1559 return fold_constants(op);
1562 /* List constructors */
1565 append_elem(type, first, last)
1576 if (first->op_type != type || type==OP_LIST && first->op_flags & OPf_PARENS)
1577 return newLISTOP(type, 0, first, last);
1579 if (first->op_flags & OPf_KIDS)
1580 ((LISTOP*)first)->op_last->op_sibling = last;
1582 first->op_flags |= OPf_KIDS;
1583 ((LISTOP*)first)->op_first = last;
1585 ((LISTOP*)first)->op_last = last;
1586 ((LISTOP*)first)->op_children++;
1591 append_list(type, first, last)
1602 if (first->op_type != type)
1603 return prepend_elem(type, (OP*)first, (OP*)last);
1605 if (last->op_type != type)
1606 return append_elem(type, (OP*)first, (OP*)last);
1608 first->op_last->op_sibling = last->op_first;
1609 first->op_last = last->op_last;
1610 first->op_children += last->op_children;
1611 if (first->op_children)
1612 last->op_flags |= OPf_KIDS;
1619 prepend_elem(type, first, last)
1630 if (last->op_type == type) {
1631 if (type == OP_LIST) { /* already a PUSHMARK there */
1632 first->op_sibling = ((LISTOP*)last)->op_first->op_sibling;
1633 ((LISTOP*)last)->op_first->op_sibling = first;
1636 if (!(last->op_flags & OPf_KIDS)) {
1637 ((LISTOP*)last)->op_last = first;
1638 last->op_flags |= OPf_KIDS;
1640 first->op_sibling = ((LISTOP*)last)->op_first;
1641 ((LISTOP*)last)->op_first = first;
1643 ((LISTOP*)last)->op_children++;
1647 return newLISTOP(type, 0, first, last);
1655 return newOP(OP_STUB, 0);
1662 if (!op || op->op_type != OP_LIST)
1663 op = newLISTOP(OP_LIST, 0, op, Nullop);
1669 newLISTOP(type, flags, first, last)
1677 Newz(1101, listop, 1, LISTOP);
1679 listop->op_type = type;
1680 listop->op_ppaddr = ppaddr[type];
1681 listop->op_children = (first != 0) + (last != 0);
1682 listop->op_flags = flags;
1686 else if (!first && last)
1689 first->op_sibling = last;
1690 listop->op_first = first;
1691 listop->op_last = last;
1692 if (type == OP_LIST) {
1694 pushop = newOP(OP_PUSHMARK, 0);
1695 pushop->op_sibling = first;
1696 listop->op_first = pushop;
1697 listop->op_flags |= OPf_KIDS;
1699 listop->op_last = pushop;
1701 else if (listop->op_children)
1702 listop->op_flags |= OPf_KIDS;
1713 Newz(1101, op, 1, OP);
1715 op->op_ppaddr = ppaddr[type];
1716 op->op_flags = flags;
1719 op->op_private = 0 + (flags >> 8);
1720 if (opargs[type] & OA_RETSCALAR)
1722 if (opargs[type] & OA_TARGET)
1723 op->op_targ = pad_alloc(type, SVs_PADTMP);
1724 return CHECKOP(type, op);
1728 newUNOP(type, flags, first)
1736 first = newOP(OP_STUB, 0);
1737 if (opargs[type] & OA_MARK)
1738 first = force_list(first);
1740 Newz(1101, unop, 1, UNOP);
1741 unop->op_type = type;
1742 unop->op_ppaddr = ppaddr[type];
1743 unop->op_first = first;
1744 unop->op_flags = flags | OPf_KIDS;
1745 unop->op_private = 1 | (flags >> 8);
1747 unop = (UNOP*) CHECKOP(type, unop);
1751 return fold_constants((OP *) unop);
1755 newBINOP(type, flags, first, last)
1762 Newz(1101, binop, 1, BINOP);
1765 first = newOP(OP_NULL, 0);
1767 binop->op_type = type;
1768 binop->op_ppaddr = ppaddr[type];
1769 binop->op_first = first;
1770 binop->op_flags = flags | OPf_KIDS;
1773 binop->op_private = 1 | (flags >> 8);
1776 binop->op_private = 2 | (flags >> 8);
1777 first->op_sibling = last;
1780 binop = (BINOP*)CHECKOP(type, binop);
1784 binop->op_last = last = binop->op_first->op_sibling;
1786 return fold_constants((OP *)binop);
1790 pmtrans(op, expr, repl)
1795 SV *tstr = ((SVOP*)expr)->op_sv;
1796 SV *rstr = ((SVOP*)repl)->op_sv;
1799 register U8 *t = (U8*)SvPV(tstr, tlen);
1800 register U8 *r = (U8*)SvPV(rstr, rlen);
1805 register short *tbl;
1807 tbl = (short*)cPVOP->op_pv;
1808 complement = op->op_private & OPpTRANS_COMPLEMENT;
1809 delete = op->op_private & OPpTRANS_DELETE;
1810 /* squash = op->op_private & OPpTRANS_SQUASH; */
1813 Zero(tbl, 256, short);
1814 for (i = 0; i < tlen; i++)
1816 for (i = 0, j = 0; i < 256; i++) {
1832 if (!rlen && !delete) {
1835 for (i = 0; i < 256; i++)
1837 for (i = 0, j = 0; i < tlen; i++,j++) {
1840 if (tbl[t[i]] == -1)
1846 if (tbl[t[i]] == -1)
1857 newPMOP(type, flags)
1863 Newz(1101, pmop, 1, PMOP);
1864 pmop->op_type = type;
1865 pmop->op_ppaddr = ppaddr[type];
1866 pmop->op_flags = flags;
1867 pmop->op_private = 0 | (flags >> 8);
1869 if (hints & HINT_LOCALE)
1870 pmop->op_pmpermflags = (pmop->op_pmflags |= PMf_LOCALE);
1872 /* link into pm list */
1873 if (type != OP_TRANS && curstash) {
1874 pmop->op_pmnext = HvPMROOT(curstash);
1875 HvPMROOT(curstash) = pmop;
1882 pmruntime(op, expr, repl)
1890 if (op->op_type == OP_TRANS)
1891 return pmtrans(op, expr, repl);
1895 if (expr->op_type == OP_CONST) {
1897 SV *pat = ((SVOP*)expr)->op_sv;
1898 char *p = SvPV(pat, plen);
1899 if ((op->op_flags & OPf_SPECIAL) && strEQ(p, " ")) {
1900 sv_setpvn(pat, "\\s+", 3);
1901 p = SvPV(pat, plen);
1902 pm->op_pmflags |= PMf_SKIPWHITE;
1904 pm->op_pmregexp = pregcomp(p, p + plen, pm);
1905 if (strEQ("\\s+", pm->op_pmregexp->precomp))
1906 pm->op_pmflags |= PMf_WHITE;
1911 if (pm->op_pmflags & PMf_KEEP)
1912 expr = newUNOP(OP_REGCMAYBE,0,expr);
1914 Newz(1101, rcop, 1, LOGOP);
1915 rcop->op_type = OP_REGCOMP;
1916 rcop->op_ppaddr = ppaddr[OP_REGCOMP];
1917 rcop->op_first = scalar(expr);
1918 rcop->op_flags |= OPf_KIDS;
1919 rcop->op_private = 1;
1920 rcop->op_other = op;
1922 /* establish postfix order */
1923 if (pm->op_pmflags & PMf_KEEP) {
1925 rcop->op_next = expr;
1926 ((UNOP*)expr)->op_first->op_next = (OP*)rcop;
1929 rcop->op_next = LINKLIST(expr);
1930 expr->op_next = (OP*)rcop;
1933 prepend_elem(op->op_type, scalar((OP*)rcop), op);
1938 if (pm->op_pmflags & PMf_EVAL)
1940 else if (repl->op_type == OP_CONST)
1944 for (curop = LINKLIST(repl); curop!=repl; curop = LINKLIST(curop)) {
1945 if (opargs[curop->op_type] & OA_DANGEROUS) {
1946 if (curop->op_type == OP_GV) {
1947 GV *gv = ((GVOP*)curop)->op_gv;
1948 if (strchr("&`'123456789+", *GvENAME(gv)))
1951 else if (curop->op_type == OP_RV2CV)
1953 else if (curop->op_type == OP_RV2SV ||
1954 curop->op_type == OP_RV2AV ||
1955 curop->op_type == OP_RV2HV ||
1956 curop->op_type == OP_RV2GV) {
1957 if (lastop && lastop->op_type != OP_GV) /*funny deref?*/
1960 else if (curop->op_type == OP_PADSV ||
1961 curop->op_type == OP_PADAV ||
1962 curop->op_type == OP_PADHV ||
1963 curop->op_type == OP_PADANY) {
1972 if (curop == repl) {
1973 pm->op_pmflags |= PMf_CONST; /* const for long enough */
1974 pm->op_pmpermflags |= PMf_CONST; /* const for long enough */
1975 prepend_elem(op->op_type, scalar(repl), op);
1978 Newz(1101, rcop, 1, LOGOP);
1979 rcop->op_type = OP_SUBSTCONT;
1980 rcop->op_ppaddr = ppaddr[OP_SUBSTCONT];
1981 rcop->op_first = scalar(repl);
1982 rcop->op_flags |= OPf_KIDS;
1983 rcop->op_private = 1;
1984 rcop->op_other = op;
1986 /* establish postfix order */
1987 rcop->op_next = LINKLIST(repl);
1988 repl->op_next = (OP*)rcop;
1990 pm->op_pmreplroot = scalar((OP*)rcop);
1991 pm->op_pmreplstart = LINKLIST(rcop);
2000 newSVOP(type, flags, sv)
2006 Newz(1101, svop, 1, SVOP);
2007 svop->op_type = type;
2008 svop->op_ppaddr = ppaddr[type];
2010 svop->op_next = (OP*)svop;
2011 svop->op_flags = flags;
2012 if (opargs[type] & OA_RETSCALAR)
2014 if (opargs[type] & OA_TARGET)
2015 svop->op_targ = pad_alloc(type, SVs_PADTMP);
2016 return CHECKOP(type, svop);
2020 newGVOP(type, flags, gv)
2026 Newz(1101, gvop, 1, GVOP);
2027 gvop->op_type = type;
2028 gvop->op_ppaddr = ppaddr[type];
2029 gvop->op_gv = (GV*)SvREFCNT_inc(gv);
2030 gvop->op_next = (OP*)gvop;
2031 gvop->op_flags = flags;
2032 if (opargs[type] & OA_RETSCALAR)
2034 if (opargs[type] & OA_TARGET)
2035 gvop->op_targ = pad_alloc(type, SVs_PADTMP);
2036 return CHECKOP(type, gvop);
2040 newPVOP(type, flags, pv)
2046 Newz(1101, pvop, 1, PVOP);
2047 pvop->op_type = type;
2048 pvop->op_ppaddr = ppaddr[type];
2050 pvop->op_next = (OP*)pvop;
2051 pvop->op_flags = flags;
2052 if (opargs[type] & OA_RETSCALAR)
2054 if (opargs[type] & OA_TARGET)
2055 pvop->op_targ = pad_alloc(type, SVs_PADTMP);
2056 return CHECKOP(type, pvop);
2065 save_hptr(&curstash);
2066 save_item(curstname);
2071 name = SvPV(sv, len);
2072 curstash = gv_stashpvn(name,len,TRUE);
2073 sv_setpvn(curstname, name, len);
2077 sv_setpv(curstname,"<none>");
2085 utilize(aver, floor, version, id, arg)
2098 if (id->op_type != OP_CONST)
2099 croak("Module name must be constant");
2103 if(version != Nullop) {
2104 SV *vesv = ((SVOP*)version)->op_sv;
2106 if (arg == Nullop && !SvNIOK(vesv)) {
2113 if (version->op_type != OP_CONST || !SvNIOK(vesv))
2114 croak("Version number must be constant number");
2116 /* Make copy of id so we don't free it twice */
2117 pack = newSVOP(OP_CONST, 0, newSVsv(((SVOP*)id)->op_sv));
2119 /* Fake up a method call to VERSION */
2120 meth = newSVOP(OP_CONST, 0, newSVpv("VERSION", 7));
2121 veop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL,
2122 append_elem(OP_LIST,
2123 prepend_elem(OP_LIST, pack, list(version)),
2124 newUNOP(OP_METHOD, 0, meth)));
2128 /* Fake up an import/unimport */
2129 if (arg && arg->op_type == OP_STUB)
2130 imop = arg; /* no import on explicit () */
2131 else if(SvNIOK(((SVOP*)id)->op_sv)) {
2132 imop = Nullop; /* use 5.0; */
2135 /* Make copy of id so we don't free it twice */
2136 pack = newSVOP(OP_CONST, 0, newSVsv(((SVOP*)id)->op_sv));
2137 meth = newSVOP(OP_CONST, 0,
2139 ? newSVpv("import", 6)
2140 : newSVpv("unimport", 8)
2142 imop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL,
2143 append_elem(OP_LIST,
2144 prepend_elem(OP_LIST, pack, list(arg)),
2145 newUNOP(OP_METHOD, 0, meth)));
2148 /* Fake up a require */
2149 rqop = newUNOP(OP_REQUIRE, 0, id);
2151 /* Fake up the BEGIN {}, which does its thing immediately. */
2153 newSVOP(OP_CONST, 0, newSVpv("BEGIN", 5)),
2155 append_elem(OP_LINESEQ,
2156 append_elem(OP_LINESEQ,
2157 newSTATEOP(0, Nullch, rqop),
2158 newSTATEOP(0, Nullch, veop)),
2159 newSTATEOP(0, Nullch, imop) ));
2166 newSLICEOP(flags, subscript, listval)
2171 return newBINOP(OP_LSLICE, flags,
2172 list(force_list(subscript)),
2173 list(force_list(listval)) );
2183 if (op->op_type == OP_NULL && op->op_flags & OPf_KIDS)
2184 op = cUNOP->op_first;
2186 if (op->op_type == OP_COND_EXPR) {
2187 I32 t = list_assignment(cCONDOP->op_first->op_sibling);
2188 I32 f = list_assignment(cCONDOP->op_first->op_sibling->op_sibling);
2193 yyerror("Assignment to both a list and a scalar");
2197 if (op->op_type == OP_LIST || op->op_flags & OPf_PARENS ||
2198 op->op_type == OP_RV2AV || op->op_type == OP_RV2HV ||
2199 op->op_type == OP_ASLICE || op->op_type == OP_HSLICE)
2202 if (op->op_type == OP_PADAV || op->op_type == OP_PADHV)
2205 if (op->op_type == OP_RV2SV)
2212 newASSIGNOP(flags, left, optype, right)
2221 if (optype == OP_ANDASSIGN || optype == OP_ORASSIGN) {
2222 return newLOGOP(optype, 0,
2223 mod(scalar(left), optype),
2224 newUNOP(OP_SASSIGN, 0, scalar(right)));
2227 return newBINOP(optype, OPf_STACKED,
2228 mod(scalar(left), optype), scalar(right));
2232 if (list_assignment(left)) {
2234 eval_start = right; /* Grandfathering $[ assignment here. Bletch.*/
2235 left = mod(left, OP_AASSIGN);
2243 op = newBINOP(OP_AASSIGN, flags,
2244 list(force_list(right)),
2245 list(force_list(left)) );
2246 op->op_private = 0 | (flags >> 8);
2247 if (!(left->op_private & OPpLVAL_INTRO)) {
2248 static int generation = 100;
2252 for (curop = LINKLIST(op); curop != op; curop = LINKLIST(curop)) {
2253 if (opargs[curop->op_type] & OA_DANGEROUS) {
2254 if (curop->op_type == OP_GV) {
2255 GV *gv = ((GVOP*)curop)->op_gv;
2256 if (gv == defgv || SvCUR(gv) == generation)
2258 SvCUR(gv) = generation;
2260 else if (curop->op_type == OP_PADSV ||
2261 curop->op_type == OP_PADAV ||
2262 curop->op_type == OP_PADHV ||
2263 curop->op_type == OP_PADANY) {
2264 SV **svp = AvARRAY(comppad_name);
2265 SV *sv = svp[curop->op_targ];
2266 if (SvCUR(sv) == generation)
2268 SvCUR(sv) = generation; /* (SvCUR not used any more) */
2270 else if (curop->op_type == OP_RV2CV)
2272 else if (curop->op_type == OP_RV2SV ||
2273 curop->op_type == OP_RV2AV ||
2274 curop->op_type == OP_RV2HV ||
2275 curop->op_type == OP_RV2GV) {
2276 if (lastop->op_type != OP_GV) /* funny deref? */
2285 op->op_private = OPpASSIGN_COMMON;
2287 if (right && right->op_type == OP_SPLIT) {
2289 if ((tmpop = ((LISTOP*)right)->op_first) &&
2290 tmpop->op_type == OP_PUSHRE)
2292 PMOP *pm = (PMOP*)tmpop;
2293 if (left->op_type == OP_RV2AV &&
2294 !(left->op_private & OPpLVAL_INTRO) &&
2295 !(op->op_private & OPpASSIGN_COMMON) )
2297 tmpop = ((UNOP*)left)->op_first;
2298 if (tmpop->op_type == OP_GV && !pm->op_pmreplroot) {
2299 pm->op_pmreplroot = (OP*)((GVOP*)tmpop)->op_gv;
2300 pm->op_pmflags |= PMf_ONCE;
2301 tmpop = ((UNOP*)op)->op_first; /* to list (nulled) */
2302 tmpop = ((UNOP*)tmpop)->op_first; /* to pushmark */
2303 tmpop->op_sibling = Nullop; /* don't free split */
2304 right->op_next = tmpop->op_next; /* fix starting loc */
2305 op_free(op); /* blow off assign */
2306 right->op_flags &= ~(OPf_KNOW|OPf_LIST);
2307 /* "I don't know and I don't care." */
2312 if (modcount < 10000 &&
2313 ((LISTOP*)right)->op_last->op_type == OP_CONST)
2315 SV *sv = ((SVOP*)((LISTOP*)right)->op_last)->op_sv;
2317 sv_setiv(sv, modcount+1);
2325 right = newOP(OP_UNDEF, 0);
2326 if (right->op_type == OP_READLINE) {
2327 right->op_flags |= OPf_STACKED;
2328 return newBINOP(OP_NULL, flags, mod(scalar(left), OP_SASSIGN), scalar(right));
2331 eval_start = right; /* Grandfathering $[ assignment here. Bletch.*/
2332 op = newBINOP(OP_SASSIGN, flags,
2333 scalar(right), mod(scalar(left), OP_SASSIGN) );
2345 newSTATEOP(flags, label, op)
2350 U32 seq = intro_my();
2353 Newz(1101, cop, 1, COP);
2354 if (perldb && curcop->cop_line && curstash != debstash) {
2355 cop->op_type = OP_DBSTATE;
2356 cop->op_ppaddr = ppaddr[ OP_DBSTATE ];
2359 cop->op_type = OP_NEXTSTATE;
2360 cop->op_ppaddr = ppaddr[ OP_NEXTSTATE ];
2362 cop->op_flags = flags;
2363 cop->op_private = 0 | (flags >> 8);
2364 cop->op_next = (OP*)cop;
2367 cop->cop_label = label;
2368 hints |= HINT_BLOCK_SCOPE;
2371 cop->cop_arybase = curcop->cop_arybase;
2373 if (copline == NOLINE)
2374 cop->cop_line = curcop->cop_line;
2376 cop->cop_line = copline;
2379 cop->cop_filegv = GvREFCNT_inc(curcop->cop_filegv);
2380 cop->cop_stash = curstash;
2382 if (perldb && curstash != debstash) {
2383 SV **svp = av_fetch(GvAV(curcop->cop_filegv),(I32)cop->cop_line, FALSE);
2384 if (svp && *svp != &sv_undef && !SvIOK(*svp)) {
2385 (void)SvIOK_on(*svp);
2387 SvSTASH(*svp) = (HV*)cop;
2391 return prepend_elem(OP_LINESEQ, (OP*)cop, op);
2394 /* "Introduce" my variables to visible status. */
2402 if (! min_intro_pending)
2405 svp = AvARRAY(comppad_name);
2406 for (i = min_intro_pending; i <= max_intro_pending; i++) {
2407 if ((sv = svp[i]) && sv != &sv_undef && !SvIVX(sv)) {
2408 SvIVX(sv) = 999999999; /* Don't know scope end yet. */
2409 SvNVX(sv) = (double)cop_seqmax;
2412 min_intro_pending = 0;
2413 comppad_name_fill = max_intro_pending; /* Needn't search higher */
2414 return cop_seqmax++;
2418 newLOGOP(type, flags, first, other)
2427 if (type == OP_XOR) /* Not short circuit, but here by precedence. */
2428 return newBINOP(type, flags, scalar(first), scalar(other));
2430 scalarboolean(first);
2431 /* optimize "!a && b" to "a || b", and "!a || b" to "a && b" */
2432 if (first->op_type == OP_NOT && (first->op_flags & OPf_SPECIAL)) {
2433 if (type == OP_AND || type == OP_OR) {
2439 first = cUNOP->op_first;
2441 first->op_next = op->op_next;
2442 cUNOP->op_first = Nullop;
2446 if (first->op_type == OP_CONST) {
2447 if (dowarn && (first->op_private & OPpCONST_BARE))
2448 warn("Probable precedence problem on %s", op_desc[type]);
2449 if ((type == OP_AND) == (SvTRUE(((SVOP*)first)->op_sv))) {
2458 else if (first->op_type == OP_WANTARRAY) {
2464 else if (dowarn && (first->op_flags & OPf_KIDS)) {
2465 OP *k1 = ((UNOP*)first)->op_first;
2466 OP *k2 = k1->op_sibling;
2468 switch (first->op_type)
2471 if (k2 && k2->op_type == OP_READLINE
2472 && (k2->op_flags & OPf_STACKED)
2473 && (k1->op_type == OP_RV2SV || k1->op_type == OP_PADSV))
2474 warnop = k2->op_type;
2478 if (k1->op_type == OP_READDIR || k1->op_type == OP_GLOB)
2479 warnop = k1->op_type;
2483 line_t oldline = curcop->cop_line;
2484 curcop->cop_line = copline;
2485 warn("Value of %s construct can be \"0\"; test with defined()",
2487 curcop->cop_line = oldline;
2494 if (type == OP_ANDASSIGN || type == OP_ORASSIGN)
2495 other->op_private |= OPpASSIGN_BACKWARDS; /* other is an OP_SASSIGN */
2497 Newz(1101, logop, 1, LOGOP);
2499 logop->op_type = type;
2500 logop->op_ppaddr = ppaddr[type];
2501 logop->op_first = first;
2502 logop->op_flags = flags | OPf_KIDS;
2503 logop->op_other = LINKLIST(other);
2504 logop->op_private = 1 | (flags >> 8);
2506 /* establish postfix order */
2507 logop->op_next = LINKLIST(first);
2508 first->op_next = (OP*)logop;
2509 first->op_sibling = other;
2511 op = newUNOP(OP_NULL, 0, (OP*)logop);
2512 other->op_next = op;
2518 newCONDOP(flags, first, trueop, falseop)
2528 return newLOGOP(OP_AND, 0, first, trueop);
2530 return newLOGOP(OP_OR, 0, first, falseop);
2532 scalarboolean(first);
2533 if (first->op_type == OP_CONST) {
2534 if (SvTRUE(((SVOP*)first)->op_sv)) {
2545 else if (first->op_type == OP_WANTARRAY) {
2549 Newz(1101, condop, 1, CONDOP);
2551 condop->op_type = OP_COND_EXPR;
2552 condop->op_ppaddr = ppaddr[OP_COND_EXPR];
2553 condop->op_first = first;
2554 condop->op_flags = flags | OPf_KIDS;
2555 condop->op_true = LINKLIST(trueop);
2556 condop->op_false = LINKLIST(falseop);
2557 condop->op_private = 1 | (flags >> 8);
2559 /* establish postfix order */
2560 condop->op_next = LINKLIST(first);
2561 first->op_next = (OP*)condop;
2563 first->op_sibling = trueop;
2564 trueop->op_sibling = falseop;
2565 op = newUNOP(OP_NULL, 0, (OP*)condop);
2567 trueop->op_next = op;
2568 falseop->op_next = op;
2574 newRANGE(flags, left, right)
2584 Newz(1101, condop, 1, CONDOP);
2586 condop->op_type = OP_RANGE;
2587 condop->op_ppaddr = ppaddr[OP_RANGE];
2588 condop->op_first = left;
2589 condop->op_flags = OPf_KIDS;
2590 condop->op_true = LINKLIST(left);
2591 condop->op_false = LINKLIST(right);
2592 condop->op_private = 1 | (flags >> 8);
2594 left->op_sibling = right;
2596 condop->op_next = (OP*)condop;
2597 flip = newUNOP(OP_FLIP, flags, (OP*)condop);
2598 flop = newUNOP(OP_FLOP, 0, flip);
2599 op = newUNOP(OP_NULL, 0, flop);
2602 left->op_next = flip;
2603 right->op_next = flop;
2605 condop->op_targ = pad_alloc(OP_RANGE, SVs_PADMY);
2606 sv_upgrade(PAD_SV(condop->op_targ), SVt_PVNV);
2607 flip->op_targ = pad_alloc(OP_RANGE, SVs_PADMY);
2608 sv_upgrade(PAD_SV(flip->op_targ), SVt_PVNV);
2610 flip->op_private = left->op_type == OP_CONST ? OPpFLIP_LINENUM : 0;
2611 flop->op_private = right->op_type == OP_CONST ? OPpFLIP_LINENUM : 0;
2614 if (!flip->op_private || !flop->op_private)
2615 linklist(op); /* blow off optimizer unless constant */
2621 newLOOPOP(flags, debuggable, expr, block)
2629 int once = block && block->op_flags & OPf_SPECIAL &&
2630 (block->op_type == OP_ENTERSUB || block->op_type == OP_NULL);
2633 if (once && expr->op_type == OP_CONST && !SvTRUE(((SVOP*)expr)->op_sv))
2634 return block; /* do {} while 0 does once */
2635 else if (expr->op_type == OP_READLINE || expr->op_type == OP_GLOB)
2636 expr = newASSIGNOP(0, newSVREF(newGVOP(OP_GV, 0, defgv)), 0, expr);
2639 listop = append_elem(OP_LINESEQ, block, newOP(OP_UNSTACK, 0));
2640 op = newLOGOP(OP_AND, 0, expr, listop);
2642 ((LISTOP*)listop)->op_last->op_next = LINKLIST(op);
2644 if (once && op != listop)
2645 op->op_next = ((LOGOP*)cUNOP->op_first)->op_other;
2648 op = newUNOP(OP_NULL, 0, op); /* or do {} while 1 loses outer block */
2650 op->op_flags |= flags;
2652 op->op_flags |= OPf_SPECIAL; /* suppress POPBLOCK curpm restoration*/
2657 newWHILEOP(flags, debuggable, loop, expr, block, cont)
2671 if (expr && (expr->op_type == OP_READLINE || expr->op_type == OP_GLOB)) {
2672 expr = newUNOP(OP_DEFINED, 0,
2673 newASSIGNOP(0, newSVREF(newGVOP(OP_GV, 0, defgv)), 0, expr) );
2677 block = newOP(OP_NULL, 0);
2680 next = LINKLIST(cont);
2682 cont = append_elem(OP_LINESEQ, cont, newOP(OP_UNSTACK, 0));
2684 listop = append_list(OP_LINESEQ, (LISTOP*)block, (LISTOP*)cont);
2685 redo = LINKLIST(listop);
2688 op = newLOGOP(OP_AND, 0, expr, scalar(listop));
2689 if (op == expr && op->op_type == OP_CONST && !SvTRUE(cSVOP->op_sv)) {
2690 op_free(expr); /* oops, it's a while (0) */
2692 return Nullop; /* (listop already freed by newLOGOP) */
2694 ((LISTOP*)listop)->op_last->op_next = condop =
2695 (op == listop ? redo : LINKLIST(op));
2703 Newz(1101,loop,1,LOOP);
2704 loop->op_type = OP_ENTERLOOP;
2705 loop->op_ppaddr = ppaddr[OP_ENTERLOOP];
2706 loop->op_private = 0;
2707 loop->op_next = (OP*)loop;
2710 op = newBINOP(OP_LEAVELOOP, 0, (OP*)loop, op);
2712 loop->op_redoop = redo;
2713 loop->op_lastop = op;
2716 loop->op_nextop = next;
2718 loop->op_nextop = op;
2720 op->op_flags |= flags;
2721 op->op_private |= (flags >> 8);
2726 #ifndef CAN_PROTOTYPE
2727 newFOROP(flags,label,forline,sv,expr,block,cont)
2736 newFOROP(I32 flags,char *label,line_t forline,OP *sv,OP *expr,OP *block,OP *cont)
2737 #endif /* CAN_PROTOTYPE */
2745 if (sv->op_type == OP_RV2SV) { /* symbol table variable */
2746 sv->op_type = OP_RV2GV;
2747 sv->op_ppaddr = ppaddr[OP_RV2GV];
2749 else if (sv->op_type == OP_PADSV) { /* private variable */
2750 padoff = sv->op_targ;
2755 croak("Can't use %s for loop variable", op_desc[sv->op_type]);
2758 sv = newGVOP(OP_GV, 0, defgv);
2760 if (expr->op_type == OP_RV2AV || expr->op_type == OP_PADAV) {
2761 expr = scalar(ref(expr, OP_ITER));
2762 iterflags |= OPf_STACKED;
2764 loop = (LOOP*)list(convert(OP_ENTERITER, iterflags,
2765 append_elem(OP_LIST, mod(force_list(expr), OP_GREPSTART),
2767 assert(!loop->op_next);
2768 Renew(loop, 1, LOOP);
2769 loop->op_targ = padoff;
2770 return newSTATEOP(0, label, newWHILEOP(flags, 1, loop,
2771 newOP(OP_ITER, 0), block, cont));
2775 newLOOPEX(type, label)
2780 if (type != OP_GOTO || label->op_type == OP_CONST) {
2781 op = newPVOP(type, 0, savepv(
2782 label->op_type == OP_CONST
2783 ? SvPVx(((SVOP*)label)->op_sv, na)
2788 if (label->op_type == OP_ENTERSUB)
2789 label = newUNOP(OP_REFGEN, 0, mod(label, OP_REFGEN));
2790 op = newUNOP(type, OPf_STACKED, label);
2792 hints |= HINT_BLOCK_SCOPE;
2800 if (!CvXSUB(cv) && CvROOT(cv)) {
2802 croak("Can't undef active subroutine");
2809 op_free(CvROOT(cv));
2810 CvROOT(cv) = Nullop;
2813 SvREFCNT_dec(CvGV(cv));
2815 SvREFCNT_dec(CvOUTSIDE(cv));
2816 CvOUTSIDE(cv) = Nullcv;
2817 if (CvPADLIST(cv)) {
2818 /* may be during global destruction */
2819 if (SvREFCNT(CvPADLIST(cv))) {
2820 I32 i = AvFILL(CvPADLIST(cv));
2822 SV** svp = av_fetch(CvPADLIST(cv), i--, FALSE);
2826 SvREFCNT_dec((SV*)CvPADLIST(cv));
2828 CvPADLIST(cv) = Nullav;
2832 #ifdef DEBUG_CLOSURES
2837 CV *outside = CvOUTSIDE(cv);
2838 AV* padlist = CvPADLIST(cv);
2839 AV* pad_name = (AV*)*av_fetch(padlist, 0, FALSE);
2840 AV* pad = (AV*)*av_fetch(padlist, 1, FALSE);
2841 SV** pname = AvARRAY(pad_name);
2842 SV** ppad = AvARRAY(pad);
2845 PerlIO_printf(Perl_debug_log, "\tCV=0x%p (%s), OUTSIDE=0x%p (%s)\n",
2847 (CvANON(cv) ? "ANON"
2848 : (cv == main_cv) ? "MAIN"
2849 : CvUNIQUE(outside) ? "UNIQUE"
2850 : CvGV(cv) ? GvNAME(CvGV(cv)) : "?mystery?"),
2853 : CvANON(outside) ? "ANON"
2854 : (outside == main_cv) ? "MAIN"
2855 : CvUNIQUE(outside) ? "UNIQUE"
2856 : CvGV(outside) ? GvNAME(CvGV(outside)) : "?mystery?"));
2858 for (ix = 1; ix <= AvFILL(pad); ix++) {
2859 if (SvPOK(pname[ix]))
2860 PerlIO_printf(Perl_debug_log, "\t%4d. 0x%p (\"%s\" %ld-%ld)\n",
2861 ix, ppad[ix], SvPVX(pname[ix]),
2862 (long)I_32(SvNVX(pname[ix])),
2863 (long)SvIVX(pname[ix]));
2866 #endif /* DEBUG_CLOSURES */
2869 cv_clone2(proto, outside)
2875 AV* protopadlist = CvPADLIST(proto);
2876 AV* protopad_name = (AV*)*av_fetch(protopadlist, 0, FALSE);
2877 AV* protopad = (AV*)*av_fetch(protopadlist, 1, FALSE);
2878 SV** pname = AvARRAY(protopad_name);
2879 SV** ppad = AvARRAY(protopad);
2883 assert(!CvUNIQUE(proto));
2890 cv = compcv = (CV*)NEWSV(1104,0);
2891 sv_upgrade((SV *)cv, SVt_PVCV);
2896 CvFILEGV(cv) = CvFILEGV(proto);
2897 CvGV(cv) = GvREFCNT_inc(CvGV(proto));
2898 CvSTASH(cv) = CvSTASH(proto);
2899 CvROOT(cv) = CvROOT(proto);
2900 CvSTART(cv) = CvSTART(proto);
2902 CvOUTSIDE(cv) = (CV*)SvREFCNT_inc(outside);
2906 comppadlist = newAV();
2907 AvREAL_off(comppadlist);
2908 av_store(comppadlist, 0, SvREFCNT_inc((SV*)protopad_name));
2909 av_store(comppadlist, 1, (SV*)comppad);
2910 CvPADLIST(cv) = comppadlist;
2911 av_fill(comppad, AvFILL(protopad));
2912 curpad = AvARRAY(comppad);
2914 av = newAV(); /* will be @_ */
2916 av_store(comppad, 0, (SV*)av);
2917 AvFLAGS(av) = AVf_REIFY;
2919 for (ix = AvFILL(protopad); ix > 0; ix--) {
2921 if (pname[ix] != &sv_undef) {
2922 char *name = SvPVX(pname[ix]); /* XXX */
2923 if (SvFLAGS(pname[ix]) & SVf_FAKE) { /* lexical from outside? */
2924 I32 off = pad_findlex(name, ix, SvIVX(pname[ix]),
2925 CvOUTSIDE(cv), cxstack_ix);
2927 curpad[ix] = SvREFCNT_inc(ppad[ix]);
2929 croak("panic: cv_clone: %s", name);
2931 else { /* our own lexical */
2933 /* anon code -- we'll come back for it */
2934 sv = SvREFCNT_inc(ppad[ix]);
2936 else if (*name == '@')
2938 else if (*name == '%')
2954 /* Now that vars are all in place, clone nested closures. */
2956 for (ix = AvFILL(protopad); ix > 0; ix--) {
2957 if (pname[ix] != &sv_undef
2958 && !(SvFLAGS(pname[ix]) & SVf_FAKE)
2959 && *SvPVX(pname[ix]) == '&'
2960 && CvCLONE(ppad[ix]))
2962 CV *kid = cv_clone2((CV*)ppad[ix], cv);
2963 SvREFCNT_dec(ppad[ix]);
2966 curpad[ix] = (SV*)kid;
2970 #ifdef DEBUG_CLOSURES
2971 PerlIO_printf(Perl_debug_log, "Cloned inside:\n");
2973 PerlIO_printf(Perl_debug_log, " from:\n");
2975 PerlIO_printf(Perl_debug_log, " to:\n");
2987 return cv_clone2(proto, CvOUTSIDE(proto));
2997 if(cv && SvPOK(cv) && !SvCUR(cv)) {
2998 for (o = CvSTART(cv); o; o = o->op_next) {
2999 OPCODE type = o->op_type;
3001 if (type == OP_NEXTSTATE || type == OP_NULL || type == OP_PUSHMARK)
3003 if (type == OP_LEAVESUB || type == OP_RETURN)
3005 if (type != OP_CONST || sv)
3008 sv = ((SVOP*)o)->op_sv;
3015 newSUB(floor,op,proto,block)
3022 char *name = op ? SvPVx(cSVOP->op_sv, na) : "__ANON__";
3023 GV* gv = gv_fetchpv(name, GV_ADDMULTI, SVt_PVCV);
3031 if (cv = GvCV(gv)) {
3033 /* just a cached method */
3037 else if (CvROOT(cv) || CvXSUB(cv) || GvASSUMECV(gv)) {
3038 /* already defined (or promised) */
3040 SV* const_sv = cv_const_sv(cv);
3041 char *p = proto ? SvPVx(((SVOP*)proto)->op_sv, na) : Nullch;
3043 if((!proto != !SvPOK(cv)) || (p && strNE(SvPV((SV*)cv,na), p))) {
3044 warn("Prototype mismatch: (%s) vs (%s)",
3045 SvPOK(cv) ? SvPV((SV*)cv,na) : "none",
3048 if ((const_sv || dowarn) && strNE(name, "BEGIN")) {
3049 line_t oldline = curcop->cop_line;
3051 curcop->cop_line = copline;
3052 warn(const_sv ? "Constant subroutine %s redefined"
3053 : "Subroutine %s redefined",name);
3054 curcop->cop_line = oldline;
3060 if (cv) { /* must reuse cv if autoloaded */
3062 CvFLAGS(cv) = (CvFLAGS(cv)&~CVf_CLONE) | (CvFLAGS(compcv)&CVf_CLONE);
3063 CvOUTSIDE(cv) = CvOUTSIDE(compcv);
3064 CvOUTSIDE(compcv) = 0;
3065 CvPADLIST(cv) = CvPADLIST(compcv);
3066 CvPADLIST(compcv) = 0;
3067 if (SvREFCNT(compcv) > 1) /* XXX Make closures transit through stub. */
3068 CvOUTSIDE(compcv) = (CV*)SvREFCNT_inc((SV*)cv);
3069 SvREFCNT_dec(compcv);
3076 CvFILEGV(cv) = curcop->cop_filegv;
3077 CvGV(cv) = GvREFCNT_inc(gv);
3078 CvSTASH(cv) = curstash;
3081 char *p = SvPVx(((SVOP*)proto)->op_sv, na);
3082 sv_setpv((SV*)cv, p);
3097 av = newAV(); /* Will be @_ */
3099 av_store(comppad, 0, (SV*)av);
3100 AvFLAGS(av) = AVf_REIFY;
3102 for (ix = AvFILL(comppad); ix > 0; ix--) {
3103 if (!SvPADMY(curpad[ix]))
3104 SvPADTMP_on(curpad[ix]);
3107 if (AvFILL(comppad_name) < AvFILL(comppad))
3108 av_store(comppad_name, AvFILL(comppad), Nullsv);
3110 CvROOT(cv) = newUNOP(OP_LEAVESUB, 0, scalarseq(block));
3111 CvSTART(cv) = LINKLIST(CvROOT(cv));
3112 CvROOT(cv)->op_next = 0;
3116 char *s = strrchr(name,':');
3121 if (strEQ(s, "BEGIN") && !error_count) {
3123 SAVESPTR(compiling.cop_filegv);
3124 SAVEI16(compiling.cop_line);
3131 DEBUG_x( dump_sub(gv) );
3132 av_push(beginav, (SV *)cv);
3136 curcop = &compiling;
3139 else if (strEQ(s, "END") && !error_count) {
3142 av_unshift(endav, 1);
3143 av_store(endav, 0, (SV *)cv);
3148 if (perldb && curstash != debstash) {
3150 SV *tmpstr = sv_newmortal();
3151 static GV *db_postponed;
3155 sprintf(buf,"%s:%ld",SvPVX(GvSV(curcop->cop_filegv)), (long)subline);
3156 sv = newSVpv(buf,0);
3158 sprintf(buf,"%ld",(long)curcop->cop_line);
3160 gv_efullname3(tmpstr, gv, Nullch);
3161 hv_store(GvHV(DBsub), SvPVX(tmpstr), SvCUR(tmpstr), sv, 0);
3162 if (!db_postponed) {
3163 db_postponed = gv_fetchpv("DB::postponed", TRUE, SVt_PVHV);
3165 hv = GvHVn(db_postponed);
3166 if (HvFILL(hv) >= 0 && hv_exists(hv, SvPVX(tmpstr), SvCUR(tmpstr))
3167 && (cv = GvCV(db_postponed))) {
3172 perl_call_sv((SV*)cv, G_DISCARD);
3177 GvCV(gv) = 0; /* Will remember in SVOP instead. */
3186 newXSUB(name, ix, subaddr, filename)
3192 CV* cv = newXS(name, (void(*)())subaddr, filename);
3194 CvXSUBANY(cv).any_i32 = ix;
3200 newXS(name, subaddr, filename)
3202 void (*subaddr) _((CV*));
3206 GV *gv = gv_fetchpv((name ? name : "__ANON__"), GV_ADDMULTI, SVt_PVCV);
3210 if (cv = GvCV(gv)) {
3212 cv = 0; /* just a cached method */
3213 else if (CvROOT(cv) || CvXSUB(cv)) { /* already defined? */
3215 line_t oldline = curcop->cop_line;
3217 curcop->cop_line = copline;
3218 warn("Subroutine %s redefined",name);
3219 curcop->cop_line = oldline;
3225 if (cv) { /* must reuse cv if autoloaded */
3226 assert(SvREFCNT(CvGV(cv)) > 1);
3227 SvREFCNT_dec(CvGV(cv));
3230 cv = (CV*)NEWSV(1105,0);
3231 sv_upgrade((SV *)cv, SVt_PVCV);
3234 CvGV(cv) = GvREFCNT_inc(gv);
3236 CvFILEGV(cv) = gv_fetchfile(filename);
3237 CvXSUB(cv) = subaddr;
3239 char *s = strrchr(name,':');
3244 if (strEQ(s, "BEGIN")) {
3247 av_push(beginav, SvREFCNT_inc(gv));
3249 else if (strEQ(s, "END")) {
3252 av_unshift(endav, 1);
3253 av_store(endav, 0, SvREFCNT_inc(gv));
3257 GvCV(gv) = 0; /* Will remember elsewhere instead. */
3264 newFORM(floor,op,block)
3275 name = SvPVx(cSVOP->op_sv, na);
3278 gv = gv_fetchpv(name,TRUE, SVt_PVFM);
3280 if (cv = GvFORM(gv)) {
3282 line_t oldline = curcop->cop_line;
3284 curcop->cop_line = copline;
3285 warn("Format %s redefined",name);
3286 curcop->cop_line = oldline;
3292 CvGV(cv) = GvREFCNT_inc(gv);
3293 CvFILEGV(cv) = curcop->cop_filegv;
3295 for (ix = AvFILL(comppad); ix > 0; ix--) {
3296 if (!SvPADMY(curpad[ix]))
3297 SvPADTMP_on(curpad[ix]);
3300 CvROOT(cv) = newUNOP(OP_LEAVEWRITE, 0, scalarseq(block));
3301 CvSTART(cv) = LINKLIST(CvROOT(cv));
3302 CvROOT(cv)->op_next = 0;
3314 return newUNOP(OP_REFGEN, 0,
3315 mod(list(convert(OP_ANONLIST, 0, op)), OP_REFGEN));
3322 return newUNOP(OP_REFGEN, 0,
3323 mod(list(convert(OP_ANONHASH, 0, op)), OP_REFGEN));
3327 newANONSUB(floor, proto, block)
3332 return newUNOP(OP_REFGEN, 0,
3333 newSVOP(OP_ANONCODE, 0, (SV*)newSUB(floor, 0, proto, block)));
3340 switch (o->op_type) {
3342 o->op_type = OP_PADAV;
3343 o->op_ppaddr = ppaddr[OP_PADAV];
3344 return ref(newUNOP(OP_RV2AV, 0, scalar(o)), OP_RV2AV);
3347 o->op_type = OP_RV2AV;
3348 o->op_ppaddr = ppaddr[OP_RV2AV];
3353 warn("oops: oopsAV");
3363 switch (o->op_type) {
3366 o->op_type = OP_PADHV;
3367 o->op_ppaddr = ppaddr[OP_PADHV];
3368 return ref(newUNOP(OP_RV2HV, 0, scalar(o)), OP_RV2HV);
3372 o->op_type = OP_RV2HV;
3373 o->op_ppaddr = ppaddr[OP_RV2HV];
3378 warn("oops: oopsHV");
3388 if (o->op_type == OP_PADANY) {
3389 o->op_type = OP_PADAV;
3390 o->op_ppaddr = ppaddr[OP_PADAV];
3393 return newUNOP(OP_RV2AV, 0, scalar(o));
3401 if (type == OP_MAPSTART)
3402 return newUNOP(OP_NULL, 0, o);
3403 return ref(newUNOP(OP_RV2GV, OPf_REF, o), type);
3410 if (o->op_type == OP_PADANY) {
3411 o->op_type = OP_PADHV;
3412 o->op_ppaddr = ppaddr[OP_PADHV];
3415 return newUNOP(OP_RV2HV, 0, scalar(o));
3422 croak("NOT IMPL LINE %d",__LINE__);
3432 return newUNOP(OP_RV2CV, flags, scalar(o));
3439 if (o->op_type == OP_PADANY) {
3440 o->op_type = OP_PADSV;
3441 o->op_ppaddr = ppaddr[OP_PADSV];
3444 return newUNOP(OP_RV2SV, 0, scalar(o));
3447 /* Check routines. */
3456 name = NEWSV(1106,0);
3457 sv_upgrade(name, SVt_PVNV);
3458 sv_setpvn(name, "&", 1);
3461 ix = pad_alloc(op->op_type, SVs_PADMY);
3462 av_store(comppad_name, ix, name);
3463 av_store(comppad, ix, cSVOP->op_sv);
3464 SvPADMY_on(cSVOP->op_sv);
3465 cSVOP->op_sv = Nullsv;
3466 cSVOP->op_targ = ix;
3474 op->op_private = hints;
3482 if (cUNOP->op_first->op_type == OP_CONCAT)
3483 op->op_flags |= OPf_STACKED;
3491 if (op->op_flags & OPf_KIDS) {
3494 OPCODE type = op->op_type;
3495 op = modkids(ck_fun(op), type);
3496 kid = cUNOP->op_first;
3497 newop = kUNOP->op_first->op_sibling;
3499 (newop->op_sibling ||
3500 !(opargs[newop->op_type] & OA_RETSCALAR) ||
3501 newop->op_type == OP_PADAV || newop->op_type == OP_PADHV ||
3502 newop->op_type == OP_RV2AV || newop->op_type == OP_RV2HV)) {
3506 op_free(kUNOP->op_first);
3507 kUNOP->op_first = newop;
3509 op->op_ppaddr = ppaddr[++op->op_type];
3519 if (op->op_flags & OPf_KIDS) {
3520 OP *kid = cUNOP->op_first;
3521 if (kid->op_type == OP_HSLICE)
3522 op->op_private |= OPpSLICE;
3523 else if (kid->op_type != OP_HELEM)
3524 croak("%s argument is not a HASH element or slice",
3525 op_desc[op->op_type]);
3535 I32 type = op->op_type;
3537 if (op->op_flags & OPf_KIDS) {
3538 if (cLISTOP->op_first->op_type == OP_STUB) {
3540 op = newUNOP(type, OPf_SPECIAL,
3541 newGVOP(OP_GV, 0, gv_fetchpv("main'ARGV", TRUE, SVt_PVAV)));
3552 hints |= HINT_BLOCK_SCOPE;
3553 if (op->op_flags & OPf_KIDS) {
3554 SVOP *kid = (SVOP*)cUNOP->op_first;
3557 op->op_flags &= ~OPf_KIDS;
3560 else if (kid->op_type == OP_LINESEQ) {
3563 kid->op_next = op->op_next;
3564 cUNOP->op_first = 0;
3567 Newz(1101, enter, 1, LOGOP);
3568 enter->op_type = OP_ENTERTRY;
3569 enter->op_ppaddr = ppaddr[OP_ENTERTRY];
3570 enter->op_private = 0;
3572 /* establish postfix order */
3573 enter->op_next = (OP*)enter;
3575 op = prepend_elem(OP_LINESEQ, (OP*)enter, (OP*)kid);
3576 op->op_type = OP_LEAVETRY;
3577 op->op_ppaddr = ppaddr[OP_LEAVETRY];
3578 enter->op_other = op;
3584 op = newUNOP(OP_ENTEREVAL, 0, newSVREF(newGVOP(OP_GV, 0, defgv)));
3586 op->op_targ = (PADOFFSET)hints;
3595 if (op->op_flags & OPf_STACKED) {
3597 kid = cUNOP->op_first->op_sibling;
3598 if (kid->op_type == OP_RV2GV)
3611 if (op->op_flags & OPf_KIDS) {
3612 OP *kid = cUNOP->op_first;
3613 if (kid->op_type != OP_HELEM)
3614 croak("%s argument is not a HASH element", op_desc[op->op_type]);
3624 o = fold_constants(o);
3625 if (o->op_type == OP_CONST)
3634 SVOP *kid = (SVOP*)cUNOP->op_first;
3636 op->op_private |= (hints & HINT_STRICT_REFS);
3637 if (kid->op_type == OP_CONST) {
3638 int iscv = (op->op_type==OP_RV2CV)*2;
3640 kid->op_type = OP_GV;
3641 for (gv = 0; !gv; iscv++) {
3643 * This is a little tricky. We only want to add the symbol if we
3644 * didn't add it in the lexer. Otherwise we get duplicate strict
3645 * warnings. But if we didn't add it in the lexer, we must at
3646 * least pretend like we wanted to add it even if it existed before,
3647 * or we get possible typo warnings. OPpCONST_ENTERED says
3648 * whether the lexer already added THIS instance of this symbol.
3650 gv = gv_fetchpv(SvPVx(kid->op_sv, na),
3651 iscv | !(kid->op_private & OPpCONST_ENTERED),
3654 : op->op_type == OP_RV2SV
3656 : op->op_type == OP_RV2AV
3658 : op->op_type == OP_RV2HV
3662 SvREFCNT_dec(kid->op_sv);
3663 kid->op_sv = SvREFCNT_inc(gv);
3672 I32 type = op->op_type;
3674 if (op->op_flags & OPf_REF)
3677 if (op->op_flags & OPf_KIDS) {
3678 SVOP *kid = (SVOP*)cUNOP->op_first;
3680 if (kid->op_type == OP_CONST && (kid->op_private & OPpCONST_BARE)) {
3681 OP *newop = newGVOP(type, OPf_REF,
3682 gv_fetchpv(SvPVx(kid->op_sv, na), TRUE, SVt_PVIO));
3689 if (type == OP_FTTTY)
3690 return newGVOP(type, OPf_REF, gv_fetchpv("main'STDIN", TRUE,
3693 return newUNOP(type, 0, newSVREF(newGVOP(OP_GV, 0, defgv)));
3706 int type = op->op_type;
3707 register I32 oa = opargs[type] >> OASHIFT;
3709 if (op->op_flags & OPf_STACKED) {
3710 if ((oa & OA_OPTIONAL) && (oa >> 4) && !((oa >> 4) & OA_OPTIONAL))
3713 return no_fh_allowed(op);
3716 if (op->op_flags & OPf_KIDS) {
3717 tokid = &cLISTOP->op_first;
3718 kid = cLISTOP->op_first;
3719 if (kid->op_type == OP_PUSHMARK ||
3720 kid->op_type == OP_NULL && kid->op_targ == OP_PUSHMARK)
3722 tokid = &kid->op_sibling;
3723 kid = kid->op_sibling;
3725 if (!kid && opargs[type] & OA_DEFGV)
3726 *tokid = kid = newSVREF(newGVOP(OP_GV, 0, defgv));
3730 sibl = kid->op_sibling;
3744 if (kid->op_type == OP_CONST &&
3745 (kid->op_private & OPpCONST_BARE)) {
3746 char *name = SvPVx(((SVOP*)kid)->op_sv, na);
3747 OP *newop = newAVREF(newGVOP(OP_GV, 0,
3748 gv_fetchpv(name, TRUE, SVt_PVAV) ));
3750 warn("Array @%s missing the @ in argument %d of %s()",
3751 name, numargs, op_desc[type]);
3754 kid->op_sibling = sibl;
3757 else if (kid->op_type != OP_RV2AV && kid->op_type != OP_PADAV)
3758 bad_type(numargs, "array", op_desc[op->op_type], kid);
3762 if (kid->op_type == OP_CONST &&
3763 (kid->op_private & OPpCONST_BARE)) {
3764 char *name = SvPVx(((SVOP*)kid)->op_sv, na);
3765 OP *newop = newHVREF(newGVOP(OP_GV, 0,
3766 gv_fetchpv(name, TRUE, SVt_PVHV) ));
3768 warn("Hash %%%s missing the %% in argument %d of %s()",
3769 name, numargs, op_desc[type]);
3772 kid->op_sibling = sibl;
3775 else if (kid->op_type != OP_RV2HV && kid->op_type != OP_PADHV)
3776 bad_type(numargs, "hash", op_desc[op->op_type], kid);
3781 OP *newop = newUNOP(OP_NULL, 0, kid);
3782 kid->op_sibling = 0;
3784 newop->op_next = newop;
3786 kid->op_sibling = sibl;
3791 if (kid->op_type != OP_GV) {
3792 if (kid->op_type == OP_CONST &&
3793 (kid->op_private & OPpCONST_BARE)) {
3794 OP *newop = newGVOP(OP_GV, 0,
3795 gv_fetchpv(SvPVx(((SVOP*)kid)->op_sv, na), TRUE,
3801 kid->op_sibling = 0;
3802 kid = newUNOP(OP_RV2GV, 0, scalar(kid));
3804 kid->op_sibling = sibl;
3810 mod(scalar(kid), type);
3814 tokid = &kid->op_sibling;
3815 kid = kid->op_sibling;
3817 op->op_private |= numargs;
3819 return too_many_arguments(op,op_desc[op->op_type]);
3822 else if (opargs[type] & OA_DEFGV) {
3824 return newUNOP(type, 0, newSVREF(newGVOP(OP_GV, 0, defgv)));
3828 while (oa & OA_OPTIONAL)
3830 if (oa && oa != OA_LIST)
3831 return too_few_arguments(op,op_desc[op->op_type]);
3840 GV *gv = gv_fetchpv("glob", FALSE, SVt_PVCV);
3842 if (gv && GvIMPORTED_CV(gv)) {
3843 op->op_type = OP_LIST;
3844 op->op_ppaddr = ppaddr[OP_LIST];
3845 op = newUNOP(OP_ENTERSUB, OPf_STACKED,
3846 append_elem(OP_LIST, op,
3847 scalar(newUNOP(OP_RV2CV, 0,
3848 newGVOP(OP_GV, 0, gv)))));
3851 gv = newGVgen("main");
3853 append_elem(OP_GLOB, op, newGVOP(OP_GV, 0, gv));
3864 OPCODE type = op->op_type == OP_GREPSTART ? OP_GREPWHILE : OP_MAPWHILE;
3866 op->op_ppaddr = ppaddr[OP_GREPSTART];
3867 Newz(1101, gwop, 1, LOGOP);
3869 if (op->op_flags & OPf_STACKED) {
3872 kid = cLISTOP->op_first->op_sibling;
3873 for (k = cLISTOP->op_first->op_sibling->op_next; k; k = k->op_next) {
3876 kid->op_next = (OP*)gwop;
3877 op->op_flags &= ~OPf_STACKED;
3879 kid = cLISTOP->op_first->op_sibling;
3880 if (type == OP_MAPWHILE)
3887 kid = cLISTOP->op_first->op_sibling;
3888 if (kid->op_type != OP_NULL)
3889 croak("panic: ck_grep");
3890 kid = kUNOP->op_first;
3892 gwop->op_type = type;
3893 gwop->op_ppaddr = ppaddr[type];
3894 gwop->op_first = listkids(op);
3895 gwop->op_flags |= OPf_KIDS;
3896 gwop->op_private = 1;
3897 gwop->op_other = LINKLIST(kid);
3898 gwop->op_targ = pad_alloc(type, SVs_PADTMP);
3899 kid->op_next = (OP*)gwop;
3901 kid = cLISTOP->op_first->op_sibling;
3902 if (!kid || !kid->op_sibling)
3903 return too_few_arguments(op,op_desc[op->op_type]);
3904 for (kid = kid->op_sibling; kid; kid = kid->op_sibling)
3905 mod(kid, OP_GREPSTART);
3914 if (op->op_flags & OPf_KIDS) {
3915 OP *kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
3916 if (kid && kid->op_type == OP_CONST)
3917 fbm_compile(((SVOP*)kid)->op_sv);
3926 /* XXX length optimization goes here */
3934 OPCODE type = op->op_type;
3935 return modkids(ck_fun(op), type);
3942 OPCODE type = op->op_type;
3943 return refkids(ck_fun(op), type);
3952 kid = cLISTOP->op_first;
3954 op = force_list(op);
3955 kid = cLISTOP->op_first;
3957 if (kid->op_type == OP_PUSHMARK)
3958 kid = kid->op_sibling;
3959 if (kid && op->op_flags & OPf_STACKED)
3960 kid = kid->op_sibling;
3961 else if (kid && !kid->op_sibling) { /* print HANDLE; */
3962 if (kid->op_type == OP_CONST && kid->op_private & OPpCONST_BARE) {
3963 op->op_flags |= OPf_STACKED; /* make it a filehandle */
3964 kid = newUNOP(OP_RV2GV, OPf_REF, scalar(kid));
3965 cLISTOP->op_first->op_sibling = kid;
3966 cLISTOP->op_last = kid;
3967 kid = kid->op_sibling;
3972 append_elem(op->op_type, op, newSVREF(newGVOP(OP_GV, 0, defgv)) );
3978 if (hints & HINT_LOCALE)
3979 op->op_private |= OPpLOCALE;
3993 if (hints & HINT_LOCALE)
3994 op->op_private |= OPpLOCALE;
4006 if (hints & HINT_LOCALE)
4007 op->op_private |= OPpLOCALE;
4017 cPMOP->op_pmflags |= PMf_RUNTIME;
4018 cPMOP->op_pmpermflags |= PMf_RUNTIME;
4033 if (cBINOP->op_first->op_flags & OPf_PARENS) {
4034 op->op_private |= OPpREPEAT_DOLIST;
4035 cBINOP->op_first = force_list(cBINOP->op_first);
4046 if (op->op_flags & OPf_KIDS) { /* Shall we supply missing .pm? */
4047 SVOP *kid = (SVOP*)cUNOP->op_first;
4049 if (kid->op_type == OP_CONST && (kid->op_private & OPpCONST_BARE)) {
4051 for (s = SvPVX(kid->op_sv); *s; s++) {
4052 if (*s == ':' && s[1] == ':') {
4054 Move(s+2, s+1, strlen(s+2)+1, char);
4055 --SvCUR(kid->op_sv);
4058 sv_catpvn(kid->op_sv, ".pm", 3);
4068 croak("NOT IMPL LINE %d",__LINE__);
4078 if (op->op_flags & OPf_KIDS) {
4079 kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4080 if (kid && kid->op_sibling) {
4081 op->op_type = OP_SSELECT;
4082 op->op_ppaddr = ppaddr[OP_SSELECT];
4084 return fold_constants(op);
4088 kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4089 if (kid && kid->op_type == OP_RV2GV)
4090 kid->op_private &= ~HINT_STRICT_REFS;
4098 I32 type = op->op_type;
4100 if (!(op->op_flags & OPf_KIDS)) {
4102 return newUNOP(type, 0,
4103 scalar(newUNOP(OP_RV2AV, 0,
4104 scalar(newGVOP(OP_GV, 0, subline
4106 : gv_fetchpv("ARGV", TRUE, SVt_PVAV) )))));
4108 return scalar(modkids(ck_fun(op), type));
4117 if (hints & HINT_LOCALE)
4118 op->op_private |= OPpLOCALE;
4121 if (op->op_flags & OPf_STACKED) {
4122 OP *kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4124 kid = kUNOP->op_first; /* get past rv2gv */
4126 if (kid->op_type == OP_SCOPE || kid->op_type == OP_LEAVE) {
4128 if (kid->op_type == OP_SCOPE) {
4132 else if (kid->op_type == OP_LEAVE) {
4133 if (op->op_type == OP_SORT) {
4134 null(kid); /* wipe out leave */
4137 for (k = kLISTOP->op_first->op_next; k; k = k->op_next) {
4138 if (k->op_next == kid)
4143 kid->op_next = 0; /* just disconnect the leave */
4144 k = kLISTOP->op_first;
4148 kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4149 null(kid); /* wipe out rv2gv */
4150 if (op->op_type == OP_SORT)
4154 op->op_flags |= OPf_SPECIAL;
4168 if (op->op_flags & OPf_STACKED)
4169 return no_fh_allowed(op);
4171 kid = cLISTOP->op_first;
4172 if (kid->op_type != OP_NULL)
4173 croak("panic: ck_split");
4174 kid = kid->op_sibling;
4175 op_free(cLISTOP->op_first);
4176 cLISTOP->op_first = kid;
4178 cLISTOP->op_first = kid = newSVOP(OP_CONST, 0, newSVpv(" ", 1));
4179 cLISTOP->op_last = kid; /* There was only one element previously */
4182 if (kid->op_type != OP_MATCH) {
4183 OP *sibl = kid->op_sibling;
4184 kid->op_sibling = 0;
4185 kid = pmruntime( newPMOP(OP_MATCH, OPf_SPECIAL), kid, Nullop);
4186 if (cLISTOP->op_first == cLISTOP->op_last)
4187 cLISTOP->op_last = kid;
4188 cLISTOP->op_first = kid;
4189 kid->op_sibling = sibl;
4192 if (pm->op_pmshort && !(pm->op_pmflags & PMf_ALL)) {
4193 SvREFCNT_dec(pm->op_pmshort); /* can't use substring to optimize */
4197 kid->op_type = OP_PUSHRE;
4198 kid->op_ppaddr = ppaddr[OP_PUSHRE];
4201 if (!kid->op_sibling)
4202 append_elem(OP_SPLIT, op, newSVREF(newGVOP(OP_GV, 0, defgv)) );
4204 kid = kid->op_sibling;
4207 if (!kid->op_sibling)
4208 append_elem(OP_SPLIT, op, newSVOP(OP_CONST, 0, newSViv(0)));
4210 kid = kid->op_sibling;
4213 if (kid->op_sibling)
4214 return too_many_arguments(op,op_desc[op->op_type]);
4223 OP *prev = ((cUNOP->op_first->op_sibling)
4224 ? cUNOP : ((UNOP*)cUNOP->op_first))->op_first;
4225 OP *o = prev->op_sibling;
4232 for (cvop = o; cvop->op_sibling; cvop = cvop->op_sibling) ;
4233 if (cvop->op_type == OP_RV2CV) {
4235 op->op_private |= (cvop->op_private & OPpENTERSUB_AMPER);
4236 null(cvop); /* disable rv2cv */
4237 tmpop = (SVOP*)((UNOP*)cvop)->op_first;
4238 if (tmpop->op_type == OP_GV) {
4239 cv = GvCVu(tmpop->op_sv);
4240 if (cv && SvPOK(cv) && !(op->op_private & OPpENTERSUB_AMPER))
4241 proto = SvPV((SV*)cv,na);
4244 op->op_private |= (hints & HINT_STRICT_REFS);
4245 if (perldb && curstash != debstash)
4246 op->op_private |= OPpENTERSUB_DB;
4251 return too_many_arguments(op, CvNAME(cv));
4269 if (o->op_type != OP_REFGEN && o->op_type != OP_UNDEF)
4270 bad_type(arg, "block", CvNAME(cv), o);
4275 if (o->op_type == OP_RV2GV)
4279 o = newUNOP(OP_RV2GV, 0, kid);
4280 o->op_sibling = kid->op_sibling;
4281 kid->op_sibling = 0;
4282 prev->op_sibling = o;
4290 if (o->op_type != OP_RV2GV)
4291 bad_type(arg, "symbol", CvNAME(cv), o);
4294 if (o->op_type != OP_RV2CV)
4295 bad_type(arg, "sub", CvNAME(cv), o);
4298 if (o->op_type != OP_RV2SV && o->op_type != OP_PADSV)
4299 bad_type(arg, "scalar", CvNAME(cv), o);
4302 if (o->op_type != OP_RV2AV && o->op_type != OP_PADAV)
4303 bad_type(arg, "array", CvNAME(cv), o);
4306 if (o->op_type != OP_RV2HV && o->op_type != OP_PADHV)
4307 bad_type(arg, "hash", CvNAME(cv), o);
4311 o = newUNOP(OP_REFGEN, 0, kid);
4312 o->op_sibling = kid->op_sibling;
4313 kid->op_sibling = 0;
4314 prev->op_sibling = o;
4325 croak("Malformed prototype for %s: %s",
4326 CvNAME(cv),SvPV((SV*)cv,na));
4331 mod(o, OP_ENTERSUB);
4335 if (proto && !optional && *proto == '$')
4336 return too_few_arguments(op, CvNAME(cv));
4344 SvREADONLY_on(cSVOP->op_sv);
4352 if (op->op_flags & OPf_KIDS) {
4353 SVOP *kid = (SVOP*)cUNOP->op_first;
4355 if (kid->op_type == OP_NULL)
4356 kid = (SVOP*)kid->op_sibling;
4358 kid->op_type == OP_CONST && (kid->op_private & OPpCONST_BARE))
4359 op->op_flags |= OPf_SPECIAL;
4364 /* A peephole optimizer. We visit the ops in the order they're to execute. */
4370 register OP* oldop = 0;
4371 if (!o || o->op_seq)
4376 for (; o; o = o->op_next) {
4382 switch (o->op_type) {
4385 curcop = ((COP*)o); /* for warnings */
4386 o->op_seq = op_seqmax++;
4397 if (o->op_next->op_type == OP_STRINGIFY)
4399 o->op_seq = op_seqmax++;
4402 if ((o->op_flags & (OPf_KNOW|OPf_LIST)) != (OPf_KNOW|OPf_LIST)) {
4403 o->op_seq = op_seqmax++;
4404 break; /* Scalar stub must produce undef. List stub is noop */
4408 if (o->op_targ == OP_NEXTSTATE || o->op_targ == OP_DBSTATE)
4409 curcop = ((COP*)op);
4415 if (oldop && o->op_next) {
4416 oldop->op_next = o->op_next;
4419 o->op_seq = op_seqmax++;
4423 if (o->op_next->op_type == OP_RV2SV) {
4424 if (!(o->op_next->op_private & OPpDEREF)) {
4426 o->op_private |= o->op_next->op_private & OPpLVAL_INTRO;
4427 o->op_next = o->op_next->op_next;
4428 o->op_type = OP_GVSV;
4429 o->op_ppaddr = ppaddr[OP_GVSV];
4432 else if (o->op_next->op_type == OP_RV2AV) {
4433 OP* pop = o->op_next->op_next;
4435 if (pop->op_type == OP_CONST &&
4436 (op = pop->op_next) &&
4437 pop->op_next->op_type == OP_AELEM &&
4438 !(pop->op_next->op_private & (OPpDEREF|OPpLVAL_INTRO)) &&
4439 (i = SvIV(((SVOP*)pop)->op_sv) - compiling.cop_arybase)
4443 SvREFCNT_dec(((SVOP*)pop)->op_sv);
4447 o->op_flags |= pop->op_next->op_flags & OPf_MOD;
4448 o->op_next = pop->op_next->op_next;
4449 o->op_type = OP_AELEMFAST;
4450 o->op_ppaddr = ppaddr[OP_AELEMFAST];
4451 o->op_private = (U8)i;
4452 GvAVn(((GVOP*)o)->op_gv);
4455 o->op_seq = op_seqmax++;
4462 o->op_seq = op_seqmax++;
4463 peep(cLOGOP->op_other);
4467 o->op_seq = op_seqmax++;
4468 peep(cCONDOP->op_true);
4469 peep(cCONDOP->op_false);
4473 o->op_seq = op_seqmax++;
4474 peep(cLOOP->op_redoop);
4475 peep(cLOOP->op_nextop);
4476 peep(cLOOP->op_lastop);
4481 o->op_seq = op_seqmax++;
4482 peep(cPMOP->op_pmreplstart);
4486 o->op_seq = op_seqmax++;
4487 if (dowarn && o->op_next && o->op_next->op_type == OP_NEXTSTATE) {
4488 if (o->op_next->op_sibling &&
4489 o->op_next->op_sibling->op_type != OP_DIE) {
4490 line_t oldline = curcop->cop_line;
4492 curcop->cop_line = ((COP*)o->op_next)->cop_line;
4493 warn("Statement unlikely to be reached");
4494 warn("(Maybe you meant system() when you said exec()?)\n");
4495 curcop->cop_line = oldline;
4500 o->op_seq = op_seqmax++;