3 * Copyright (c) 1991-1997, 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);
184 if (!svp || *svp == &sv_undef)
187 svp = AvARRAY(curname);
188 for (off = AvFILL(curname); off > 0; off--) {
189 if ((sv = svp[off]) &&
192 seq > I_32(SvNVX(sv)) &&
193 strEQ(SvPVX(sv), name))
204 return 0; /* don't clone from inactive stack frame */
208 oldpad = (AV*)*av_fetch(curlist, depth, FALSE);
209 oldsv = *av_fetch(oldpad, off, TRUE);
210 if (!newoff) { /* Not a mere clone operation. */
211 SV *namesv = NEWSV(1103,0);
212 newoff = pad_alloc(OP_PADSV, SVs_PADMY);
213 sv_upgrade(namesv, SVt_PVNV);
214 sv_setpv(namesv, name);
215 av_store(comppad_name, newoff, namesv);
216 SvNVX(namesv) = (double)curcop->cop_seq;
217 SvIVX(namesv) = 999999999; /* A ref, intro immediately */
218 SvFAKE_on(namesv); /* A ref, not a real var */
219 if (CvANON(compcv) || SvTYPE(compcv) == SVt_PVFM) {
220 /* "It's closures all the way down." */
225 bcv && bcv != cv && !CvCLONE(bcv);
226 bcv = CvOUTSIDE(bcv)) {
230 if (dowarn && !CvUNIQUE(cv))
232 "Variable \"%s\" may be unavailable",
239 else if (!CvUNIQUE(compcv)) {
240 if (dowarn && !SvFAKE(sv) && !CvUNIQUE(cv))
241 warn("Variable \"%s\" will not stay shared", name);
244 av_store(comppad, newoff, SvREFCNT_inc(oldsv));
250 /* Nothing in current lexical context--try eval's context, if any.
251 * This is necessary to let the perldb get at lexically scoped variables.
252 * XXX This will also probably interact badly with eval tree caching.
256 for (i = cx_ix; i >= 0; i--) {
258 switch (cx->cx_type) {
260 if (i == 0 && saweval) {
261 seq = cxstack[saweval].blk_oldcop->cop_seq;
262 return pad_findlex(name, newoff, seq, main_cv, 0);
266 switch (cx->blk_eval.old_op_type) {
271 /* require must have its own scope */
279 if (debstash && CvSTASH(cv) == debstash) { /* ignore DB'* scope */
280 saweval = i; /* so we know where we were called from */
283 seq = cxstack[saweval].blk_oldcop->cop_seq;
284 return pad_findlex(name, newoff, seq, cv, i-1);
297 SV **svp = AvARRAY(comppad_name);
298 U32 seq = cop_seqmax;
300 /* The one we're looking for is probably just before comppad_name_fill. */
301 for (off = AvFILL(comppad_name); off > 0; off--) {
302 if ((sv = svp[off]) &&
305 seq > I_32(SvNVX(sv)) &&
306 strEQ(SvPVX(sv), name))
308 return (PADOFFSET)off;
312 /* See if it's in a nested scope */
313 off = pad_findlex(name, 0, seq, CvOUTSIDE(compcv), cxstack_ix);
325 SV **svp = AvARRAY(comppad_name);
327 if (min_intro_pending && fill < min_intro_pending) {
328 for (off = max_intro_pending; off >= min_intro_pending; off--) {
329 if ((sv = svp[off]) && sv != &sv_undef)
330 warn("%s never introduced", SvPVX(sv));
333 /* "Deintroduce" my variables that are leaving with this scope. */
334 for (off = AvFILL(comppad_name); off > fill; off--) {
335 if ((sv = svp[off]) && sv != &sv_undef && SvIVX(sv) == 999999999)
336 SvIVX(sv) = cop_seqmax;
341 pad_alloc(optype,tmptype)
348 if (AvARRAY(comppad) != curpad)
349 croak("panic: pad_alloc");
350 if (pad_reset_pending)
352 if (tmptype & SVs_PADMY) {
354 sv = *av_fetch(comppad, AvFILL(comppad) + 1, TRUE);
355 } while (SvPADBUSY(sv)); /* need a fresh one */
356 retval = AvFILL(comppad);
359 SV **names = AvARRAY(comppad_name);
360 SSize_t names_fill = AvFILL(comppad_name);
363 * "foreach" index vars temporarily become aliases to non-"my"
364 * values. Thus we must skip, not just pad values that are
365 * marked as current pad values, but also those with names.
367 if (++padix <= names_fill &&
368 (sv = names[padix]) && sv != &sv_undef)
370 sv = *av_fetch(comppad, padix, TRUE);
371 if (!(SvFLAGS(sv) & (SVs_PADTMP|SVs_PADMY)))
376 SvFLAGS(sv) |= tmptype;
377 curpad = AvARRAY(comppad);
378 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad alloc %ld for %s\n", (long) retval, op_name[optype]));
379 return (PADOFFSET)retval;
383 #ifndef CAN_PROTOTYPE
388 #endif /* CAN_PROTOTYPE */
391 croak("panic: pad_sv po");
392 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad sv %lu\n", (unsigned long)po));
393 return curpad[po]; /* eventually we'll turn this into a macro */
397 #ifndef CAN_PROTOTYPE
401 pad_free(PADOFFSET po)
402 #endif /* CAN_PROTOTYPE */
406 if (AvARRAY(comppad) != curpad)
407 croak("panic: pad_free curpad");
409 croak("panic: pad_free po");
410 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad free %lu\n", (unsigned long)po));
411 if (curpad[po] && !SvIMMORTAL(curpad[po]))
412 SvPADTMP_off(curpad[po]);
418 #ifndef CAN_PROTOTYPE
422 pad_swipe(PADOFFSET po)
423 #endif /* CAN_PROTOTYPE */
425 if (AvARRAY(comppad) != curpad)
426 croak("panic: pad_swipe curpad");
428 croak("panic: pad_swipe po");
429 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad swipe %lu\n", (unsigned long)po));
430 SvPADTMP_off(curpad[po]);
431 curpad[po] = NEWSV(1107,0);
432 SvPADTMP_on(curpad[po]);
442 if (AvARRAY(comppad) != curpad)
443 croak("panic: pad_reset curpad");
444 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad reset\n"));
445 if (!tainting) { /* Can't mix tainted and non-tainted temporaries. */
446 for (po = AvMAX(comppad); po > padix_floor; po--) {
447 if (curpad[po] && !SvIMMORTAL(curpad[po]))
448 SvPADTMP_off(curpad[po]);
452 pad_reset_pending = FALSE;
461 register OP *kid, *nextkid;
463 if (!op || op->op_seq == (U16)-1)
466 if (op->op_flags & OPf_KIDS) {
467 for (kid = cUNOP->op_first; kid; kid = nextkid) {
468 nextkid = kid->op_sibling; /* Get before next freeing kid */
473 switch (op->op_type) {
475 op->op_targ = 0; /* Was holding old type, if any. */
478 op->op_targ = 0; /* Was holding hints. */
481 if (!(op->op_flags & OPf_REF) || (check[op->op_type] != ck_ftst))
487 SvREFCNT_dec(cGVOP->op_gv);
491 Safefree(cCOP->cop_label);
492 SvREFCNT_dec(cCOP->cop_filegv);
495 SvREFCNT_dec(cSVOP->op_sv);
501 if (op->op_flags & (OPf_SPECIAL|OPf_STACKED|OPf_KIDS))
505 Safefree(cPVOP->op_pv);
508 op_free(cPMOP->op_pmreplroot);
512 pregfree(cPMOP->op_pmregexp);
513 SvREFCNT_dec(cPMOP->op_pmshort);
518 pad_free(op->op_targ);
527 if (op->op_type != OP_NULL && op->op_targ > 0)
528 pad_free(op->op_targ);
529 op->op_targ = op->op_type;
530 op->op_type = OP_NULL;
531 op->op_ppaddr = ppaddr[OP_NULL];
534 /* Contextualizers */
536 #define LINKLIST(o) ((o)->op_next ? (o)->op_next : linklist((OP*)o))
547 /* establish postfix order */
548 if (cUNOP->op_first) {
549 op->op_next = LINKLIST(cUNOP->op_first);
550 for (kid = cUNOP->op_first; kid; kid = kid->op_sibling) {
552 kid->op_next = LINKLIST(kid->op_sibling);
568 if (op && op->op_flags & OPf_KIDS) {
569 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
580 op->op_type == OP_SASSIGN && cBINOP->op_first->op_type == OP_CONST) {
581 line_t oldline = curcop->cop_line;
583 if (copline != NOLINE)
584 curcop->cop_line = copline;
585 warn("Found = in conditional, should be ==");
586 curcop->cop_line = oldline;
597 /* assumes no premature commitment */
598 if (!op || (op->op_flags & OPf_KNOW) || op->op_type == OP_RETURN
602 op->op_flags &= ~OPf_LIST;
603 op->op_flags |= OPf_KNOW;
605 switch (op->op_type) {
607 if (op->op_private & OPpREPEAT_DOLIST)
608 null(((LISTOP*)cBINOP->op_first)->op_first);
609 scalar(cBINOP->op_first);
614 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
618 if ((kid = ((LISTOP*)op)->op_first) && kid->op_type == OP_PUSHRE) {
619 if (!kPMOP->op_pmreplroot)
620 deprecate("implicit split to @_");
627 if (op->op_flags & OPf_KIDS) {
628 for (kid = cUNOP->op_first; kid; kid = kid->op_sibling)
634 scalar(cLISTOP->op_first);
639 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling) {
659 if (!op || error_count)
661 if (op->op_flags & OPf_LIST)
664 op->op_flags |= OPf_KNOW;
666 switch (op->op_type) {
668 if (!(opargs[op->op_type] & OA_FOLDCONST))
672 if (op->op_flags & OPf_STACKED)
743 if (!(op->op_private & OPpLVAL_INTRO))
744 useless = op_desc[op->op_type];
751 if (!(op->op_private & OPpLVAL_INTRO) &&
752 (!op->op_sibling || op->op_sibling->op_type != OP_READLINE))
753 useless = "a variable";
758 curcop = ((COP*)op); /* for warning below */
764 useless = "a constant";
765 if (SvNIOK(sv) && (SvNV(sv) == 0.0 || SvNV(sv) == 1.0))
767 else if (SvPOK(sv)) {
768 if (strnEQ(SvPVX(sv), "di", 2) ||
769 strnEQ(SvPVX(sv), "ds", 2) ||
770 strnEQ(SvPVX(sv), "ig", 2))
774 null(op); /* don't execute a constant */
775 SvREFCNT_dec(sv); /* don't even remember it */
779 op->op_type = OP_PREINC; /* pre-increment is faster */
780 op->op_ppaddr = ppaddr[OP_PREINC];
784 op->op_type = OP_PREDEC; /* pre-decrement is faster */
785 op->op_ppaddr = ppaddr[OP_PREDEC];
791 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
795 if (op->op_targ == OP_NEXTSTATE || op->op_targ == OP_DBSTATE)
796 curcop = ((COP*)op); /* for warning below */
797 if (op->op_flags & OPf_STACKED)
802 if (!(op->op_flags & OPf_KIDS))
808 op->op_private |= OPpLEAVE_VOID;
811 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
815 if ((kid = ((LISTOP*)op)->op_first) && kid->op_type == OP_PUSHRE) {
816 if (!kPMOP->op_pmreplroot)
817 deprecate("implicit split to @_");
823 op->op_private |= OPpLEAVE_VOID;
826 if (useless && dowarn)
827 warn("Useless use of %s in void context", useless);
836 if (op && op->op_flags & OPf_KIDS) {
837 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
849 /* assumes no premature commitment */
850 if (!op || (op->op_flags & OPf_KNOW) || op->op_type == OP_RETURN
854 op->op_flags |= (OPf_KNOW | OPf_LIST);
856 switch (op->op_type) {
859 list(cBINOP->op_first);
864 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
871 if (!(op->op_flags & OPf_KIDS))
873 if (!op->op_next && cUNOP->op_first->op_type == OP_FLOP) {
874 list(cBINOP->op_first);
875 return gen_constant_list(op);
882 list(cLISTOP->op_first);
886 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling) {
905 if (op->op_type == OP_LINESEQ ||
906 op->op_type == OP_SCOPE ||
907 op->op_type == OP_LEAVE ||
908 op->op_type == OP_LEAVETRY)
910 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling) {
911 if (kid->op_sibling) {
917 op->op_flags &= ~OPf_PARENS;
918 if (hints & HINT_BLOCK_SCOPE)
919 op->op_flags |= OPf_PARENS;
922 op = newOP(OP_STUB, 0);
932 if (op && op->op_flags & OPf_KIDS) {
933 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
949 if (!op || error_count)
952 switch (op->op_type) {
954 if (!(op->op_private & (OPpCONST_ARYBASE)))
956 if (eval_start && eval_start->op_type == OP_CONST) {
957 compiling.cop_arybase = (I32)SvIV(((SVOP*)eval_start)->op_sv);
961 SAVEI32(compiling.cop_arybase);
962 compiling.cop_arybase = 0;
964 else if (type == OP_REFGEN)
967 croak("That use of $[ is unsupported");
970 if (op->op_flags & OPf_PARENS)
974 if ((type == OP_UNDEF || type == OP_REFGEN) &&
975 !(op->op_flags & OPf_STACKED)) {
976 op->op_type = OP_RV2CV; /* entersub => rv2cv */
977 op->op_ppaddr = ppaddr[OP_RV2CV];
978 assert(cUNOP->op_first->op_type == OP_NULL);
979 null(((LISTOP*)cUNOP->op_first)->op_first); /* disable pushmark */
985 /* grep, foreach, subcalls, refgen */
986 if (type == OP_GREPSTART || type == OP_ENTERSUB || type == OP_REFGEN)
988 sprintf(tokenbuf, "Can't modify %s in %s",
989 op_desc[op->op_type],
990 type ? op_desc[type] : "local");
1005 case OP_RIGHT_SHIFT:
1014 if (!(op->op_flags & OPf_STACKED))
1020 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
1026 if (type == OP_REFGEN && op->op_flags & OPf_PARENS) {
1028 return op; /* Treat \(@foo) like ordinary list. */
1032 ref(cUNOP->op_first, op->op_type);
1044 if (!type && cUNOP->op_first->op_type != OP_GV)
1045 croak("Can't localize a reference");
1046 ref(cUNOP->op_first, op->op_type);
1059 if (type == OP_REFGEN && op->op_flags & OPf_PARENS)
1060 return op; /* Treat \(@foo) like ordinary list. */
1065 croak("Can't localize lexical variable %s",
1066 SvPV(*av_fetch(comppad_name, op->op_targ, 4), na));
1073 if (type != OP_SASSIGN)
1079 pad_free(op->op_targ);
1080 op->op_targ = pad_alloc(op->op_type, SVs_PADMY);
1081 assert(SvTYPE(PAD_SV(op->op_targ)) == SVt_NULL);
1082 if (op->op_flags & OPf_KIDS)
1083 mod(cBINOP->op_first->op_sibling, type);
1088 ref(cBINOP->op_first, op->op_type);
1095 if (op->op_flags & OPf_KIDS)
1096 mod(cLISTOP->op_last, type);
1100 if (!(op->op_flags & OPf_KIDS))
1102 if (op->op_targ != OP_LIST) {
1103 mod(cBINOP->op_first, type);
1108 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
1112 op->op_flags |= OPf_MOD;
1114 if (type == OP_AASSIGN || type == OP_SASSIGN)
1115 op->op_flags |= OPf_SPECIAL|OPf_REF;
1117 op->op_private |= OPpLVAL_INTRO;
1118 op->op_flags &= ~OPf_SPECIAL;
1120 else if (type != OP_GREPSTART && type != OP_ENTERSUB)
1121 op->op_flags |= OPf_REF;
1131 if (op && op->op_flags & OPf_KIDS) {
1132 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
1145 if (!op || error_count)
1148 switch (op->op_type) {
1150 if ((type == OP_DEFINED) &&
1151 !(op->op_flags & OPf_STACKED)) {
1152 op->op_type = OP_RV2CV; /* entersub => rv2cv */
1153 op->op_ppaddr = ppaddr[OP_RV2CV];
1154 assert(cUNOP->op_first->op_type == OP_NULL);
1155 null(((LISTOP*)cUNOP->op_first)->op_first); /* disable pushmark */
1156 op->op_flags |= OPf_SPECIAL;
1161 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
1165 ref(cUNOP->op_first, op->op_type);
1168 if (type == OP_RV2SV || type == OP_RV2AV || type == OP_RV2HV) {
1169 op->op_private |= (type == OP_RV2AV ? OPpDEREF_AV
1170 : type == OP_RV2HV ? OPpDEREF_HV
1172 op->op_flags |= OPf_MOD;
1178 op->op_flags |= OPf_REF;
1181 ref(cUNOP->op_first, op->op_type);
1186 op->op_flags |= OPf_REF;
1191 if (!(op->op_flags & OPf_KIDS))
1193 ref(cBINOP->op_first, type);
1197 ref(cBINOP->op_first, op->op_type);
1198 if (type == OP_RV2SV || type == OP_RV2AV || type == OP_RV2HV) {
1199 op->op_private |= (type == OP_RV2AV ? OPpDEREF_AV
1200 : type == OP_RV2HV ? OPpDEREF_HV
1202 op->op_flags |= OPf_MOD;
1210 if (!(op->op_flags & OPf_KIDS))
1212 ref(cLISTOP->op_last, type);
1228 if (!op || error_count)
1232 if (type == OP_LIST) {
1233 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
1236 else if (type != OP_PADSV &&
1239 type != OP_PUSHMARK)
1241 sprintf(tokenbuf, "Can't declare %s in my", op_desc[op->op_type]);
1245 op->op_flags |= OPf_MOD;
1246 op->op_private |= OPpLVAL_INTRO;
1255 o->op_flags |= OPf_PARENS;
1260 bind_match(type, left, right)
1268 (left->op_type == OP_RV2AV ||
1269 left->op_type == OP_RV2HV ||
1270 left->op_type == OP_PADAV ||
1271 left->op_type == OP_PADHV)) {
1272 char *desc = op_desc[(right->op_type == OP_SUBST ||
1273 right->op_type == OP_TRANS)
1274 ? right->op_type : OP_MATCH];
1275 char *sample = ((left->op_type == OP_RV2AV ||
1276 left->op_type == OP_PADAV)
1277 ? "@array" : "%hash");
1278 warn("Applying %s to %s will act on scalar(%s)", desc, sample, sample);
1281 if (right->op_type == OP_MATCH ||
1282 right->op_type == OP_SUBST ||
1283 right->op_type == OP_TRANS) {
1284 right->op_flags |= OPf_STACKED;
1285 if (right->op_type != OP_MATCH)
1286 left = mod(left, right->op_type);
1287 if (right->op_type == OP_TRANS)
1288 op = newBINOP(OP_NULL, OPf_STACKED, scalar(left), right);
1290 op = prepend_elem(right->op_type, scalar(left), right);
1292 return newUNOP(OP_NOT, 0, scalar(op));
1296 return bind_match(type, left,
1297 pmruntime(newPMOP(OP_MATCH, 0), right, Nullop));
1306 /* XXX need to optimize away NOT NOT here? Or do we let optimizer do it? */
1307 return newUNOP(OP_NOT, OPf_SPECIAL, scalar(op));
1315 if (o->op_flags & OPf_PARENS || perldb || tainting) {
1316 o = prepend_elem(OP_LINESEQ, newOP(OP_ENTER, 0), o);
1317 o->op_type = OP_LEAVE;
1318 o->op_ppaddr = ppaddr[OP_LEAVE];
1321 if (o->op_type == OP_LINESEQ) {
1323 o->op_type = OP_SCOPE;
1324 o->op_ppaddr = ppaddr[OP_SCOPE];
1325 kid = ((LISTOP*)o)->op_first;
1326 if (kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE){
1327 SvREFCNT_dec(((COP*)kid)->cop_filegv);
1332 o = newLISTOP(OP_SCOPE, 0, o, Nullop);
1342 int retval = savestack_ix;
1343 SAVEI32(comppad_name_floor);
1345 if ((comppad_name_fill = AvFILL(comppad_name)) > 0)
1346 comppad_name_floor = comppad_name_fill;
1348 comppad_name_floor = 0;
1350 SAVEI32(min_intro_pending);
1351 SAVEI32(max_intro_pending);
1352 min_intro_pending = 0;
1353 SAVEI32(comppad_name_fill);
1354 SAVEI32(padix_floor);
1355 padix_floor = padix;
1356 pad_reset_pending = FALSE;
1358 hints &= ~HINT_BLOCK_SCOPE;
1363 block_end(floor, seq)
1367 int needblockscope = hints & HINT_BLOCK_SCOPE;
1368 OP* retval = scalarseq(seq);
1370 pad_reset_pending = FALSE;
1372 hints |= HINT_BLOCK_SCOPE; /* propagate out */
1373 pad_leavemy(comppad_name_fill);
1383 eval_root = newUNOP(OP_LEAVEEVAL, ((in_eval & 4) ? OPf_SPECIAL : 0), op);
1384 eval_start = linklist(eval_root);
1385 eval_root->op_next = 0;
1391 main_root = scope(sawparens(scalarvoid(op)));
1392 curcop = &compiling;
1393 main_start = LINKLIST(main_root);
1394 main_root->op_next = 0;
1398 /* Register with debugger */
1400 CV *cv = perl_get_cv("DB::postponed", FALSE);
1404 XPUSHs((SV*)compiling.cop_filegv);
1406 perl_call_sv((SV*)cv, G_DISCARD);
1417 if (o->op_flags & OPf_PARENS)
1421 if (dowarn && bufptr > oldbufptr && bufptr[-1] == ',') {
1423 for (s = bufptr; *s && (isALNUM(*s) || strchr("@$%, ",*s)); s++) ;
1424 if (*s == ';' || *s == '=')
1425 warn("Parens missing around \"%s\" list", lex ? "my" : "local");
1432 return mod(o, OP_NULL); /* a bit kludgey */
1439 if (o->op_type == OP_LIST) {
1440 o = convert(OP_JOIN, 0,
1441 prepend_elem(OP_LIST,
1442 newSVREF(newGVOP(OP_GV, 0, gv_fetchpv(";", TRUE, SVt_PV))),
1453 I32 type = o->op_type;
1456 if (opargs[type] & OA_RETSCALAR)
1458 if (opargs[type] & OA_TARGET)
1459 o->op_targ = pad_alloc(type, SVs_PADTMP);
1461 if ((opargs[type] & OA_OTHERINT) && (hints & HINT_INTEGER))
1462 o->op_ppaddr = ppaddr[type = ++(o->op_type)];
1464 if (!(opargs[type] & OA_FOLDCONST))
1468 goto nope; /* Don't try to run w/ errors */
1470 for (curop = LINKLIST(o); curop != o; curop = LINKLIST(curop)) {
1471 if (curop->op_type != OP_CONST &&
1472 curop->op_type != OP_LIST &&
1473 curop->op_type != OP_SCALAR &&
1474 curop->op_type != OP_NULL &&
1475 curop->op_type != OP_PUSHMARK) {
1480 curop = LINKLIST(o);
1485 if (o->op_targ && sv == PAD_SV(o->op_targ)) /* grab pad temp? */
1486 pad_swipe(o->op_targ);
1487 else if (SvTEMP(sv)) { /* grab mortal temp? */
1488 (void)SvREFCNT_inc(sv);
1492 if (type == OP_RV2GV)
1493 return newGVOP(OP_GV, 0, (GV*)sv);
1495 if ((SvFLAGS(sv) & (SVf_IOK|SVf_NOK|SVf_POK)) == SVf_NOK) {
1497 if ((double)iv == SvNV(sv)) { /* can we smush double to int */
1502 SvIOK_off(sv); /* undo SvIV() damage */
1504 return newSVOP(OP_CONST, 0, sv);
1508 if (!(opargs[type] & OA_OTHERINT))
1511 if (!(hints & HINT_INTEGER)) {
1512 if (type == OP_DIVIDE || !(o->op_flags & OPf_KIDS))
1515 for (curop = ((UNOP*)o)->op_first; curop; curop = curop->op_sibling) {
1516 if (curop->op_type == OP_CONST) {
1517 if (SvIOK(((SVOP*)curop)->op_sv))
1521 if (opargs[curop->op_type] & OA_RETINTEGER)
1525 o->op_ppaddr = ppaddr[++(o->op_type)];
1532 gen_constant_list(o)
1536 I32 oldtmps_floor = tmps_floor;
1540 return o; /* Don't attempt to run with errors */
1542 op = curop = LINKLIST(o);
1548 tmps_floor = oldtmps_floor;
1550 o->op_type = OP_RV2AV;
1551 o->op_ppaddr = ppaddr[OP_RV2AV];
1552 curop = ((UNOP*)o)->op_first;
1553 ((UNOP*)o)->op_first = newSVOP(OP_CONST, 0, SvREFCNT_inc(*stack_sp--));
1560 convert(type, flags, op)
1568 if (!op || op->op_type != OP_LIST)
1569 op = newLISTOP(OP_LIST, 0, op, Nullop);
1571 op->op_flags &= ~(OPf_KNOW|OPf_LIST);
1573 if (!(opargs[type] & OA_MARK))
1574 null(cLISTOP->op_first);
1577 op->op_ppaddr = ppaddr[type];
1578 op->op_flags |= flags;
1580 op = CHECKOP(type, op);
1581 if (op->op_type != type)
1584 if (cLISTOP->op_children < 7) {
1585 /* XXX do we really need to do this if we're done appending?? */
1586 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
1588 cLISTOP->op_last = last; /* in case check substituted last arg */
1591 return fold_constants(op);
1594 /* List constructors */
1597 append_elem(type, first, last)
1608 if (first->op_type != type || type==OP_LIST && first->op_flags & OPf_PARENS)
1609 return newLISTOP(type, 0, first, last);
1611 if (first->op_flags & OPf_KIDS)
1612 ((LISTOP*)first)->op_last->op_sibling = last;
1614 first->op_flags |= OPf_KIDS;
1615 ((LISTOP*)first)->op_first = last;
1617 ((LISTOP*)first)->op_last = last;
1618 ((LISTOP*)first)->op_children++;
1623 append_list(type, first, last)
1634 if (first->op_type != type)
1635 return prepend_elem(type, (OP*)first, (OP*)last);
1637 if (last->op_type != type)
1638 return append_elem(type, (OP*)first, (OP*)last);
1640 first->op_last->op_sibling = last->op_first;
1641 first->op_last = last->op_last;
1642 first->op_children += last->op_children;
1643 if (first->op_children)
1644 last->op_flags |= OPf_KIDS;
1651 prepend_elem(type, first, last)
1662 if (last->op_type == type) {
1663 if (type == OP_LIST) { /* already a PUSHMARK there */
1664 first->op_sibling = ((LISTOP*)last)->op_first->op_sibling;
1665 ((LISTOP*)last)->op_first->op_sibling = first;
1668 if (!(last->op_flags & OPf_KIDS)) {
1669 ((LISTOP*)last)->op_last = first;
1670 last->op_flags |= OPf_KIDS;
1672 first->op_sibling = ((LISTOP*)last)->op_first;
1673 ((LISTOP*)last)->op_first = first;
1675 ((LISTOP*)last)->op_children++;
1679 return newLISTOP(type, 0, first, last);
1687 return newOP(OP_STUB, 0);
1694 if (!op || op->op_type != OP_LIST)
1695 op = newLISTOP(OP_LIST, 0, op, Nullop);
1701 newLISTOP(type, flags, first, last)
1709 Newz(1101, listop, 1, LISTOP);
1711 listop->op_type = type;
1712 listop->op_ppaddr = ppaddr[type];
1713 listop->op_children = (first != 0) + (last != 0);
1714 listop->op_flags = flags;
1718 else if (!first && last)
1721 first->op_sibling = last;
1722 listop->op_first = first;
1723 listop->op_last = last;
1724 if (type == OP_LIST) {
1726 pushop = newOP(OP_PUSHMARK, 0);
1727 pushop->op_sibling = first;
1728 listop->op_first = pushop;
1729 listop->op_flags |= OPf_KIDS;
1731 listop->op_last = pushop;
1733 else if (listop->op_children)
1734 listop->op_flags |= OPf_KIDS;
1745 Newz(1101, op, 1, OP);
1747 op->op_ppaddr = ppaddr[type];
1748 op->op_flags = flags;
1751 op->op_private = 0 + (flags >> 8);
1752 if (opargs[type] & OA_RETSCALAR)
1754 if (opargs[type] & OA_TARGET)
1755 op->op_targ = pad_alloc(type, SVs_PADTMP);
1756 return CHECKOP(type, op);
1760 newUNOP(type, flags, first)
1768 first = newOP(OP_STUB, 0);
1769 if (opargs[type] & OA_MARK)
1770 first = force_list(first);
1772 Newz(1101, unop, 1, UNOP);
1773 unop->op_type = type;
1774 unop->op_ppaddr = ppaddr[type];
1775 unop->op_first = first;
1776 unop->op_flags = flags | OPf_KIDS;
1777 unop->op_private = 1 | (flags >> 8);
1779 unop = (UNOP*) CHECKOP(type, unop);
1783 return fold_constants((OP *) unop);
1787 newBINOP(type, flags, first, last)
1794 Newz(1101, binop, 1, BINOP);
1797 first = newOP(OP_NULL, 0);
1799 binop->op_type = type;
1800 binop->op_ppaddr = ppaddr[type];
1801 binop->op_first = first;
1802 binop->op_flags = flags | OPf_KIDS;
1805 binop->op_private = 1 | (flags >> 8);
1808 binop->op_private = 2 | (flags >> 8);
1809 first->op_sibling = last;
1812 binop = (BINOP*)CHECKOP(type, binop);
1816 binop->op_last = last = binop->op_first->op_sibling;
1818 return fold_constants((OP *)binop);
1822 pmtrans(op, expr, repl)
1827 SV *tstr = ((SVOP*)expr)->op_sv;
1828 SV *rstr = ((SVOP*)repl)->op_sv;
1831 register U8 *t = (U8*)SvPV(tstr, tlen);
1832 register U8 *r = (U8*)SvPV(rstr, rlen);
1837 register short *tbl;
1839 tbl = (short*)cPVOP->op_pv;
1840 complement = op->op_private & OPpTRANS_COMPLEMENT;
1841 delete = op->op_private & OPpTRANS_DELETE;
1842 /* squash = op->op_private & OPpTRANS_SQUASH; */
1845 Zero(tbl, 256, short);
1846 for (i = 0; i < tlen; i++)
1848 for (i = 0, j = 0; i < 256; i++) {
1864 if (!rlen && !delete) {
1867 for (i = 0; i < 256; i++)
1869 for (i = 0, j = 0; i < tlen; i++,j++) {
1872 if (tbl[t[i]] == -1)
1878 if (tbl[t[i]] == -1)
1889 newPMOP(type, flags)
1895 Newz(1101, pmop, 1, PMOP);
1896 pmop->op_type = type;
1897 pmop->op_ppaddr = ppaddr[type];
1898 pmop->op_flags = flags;
1899 pmop->op_private = 0 | (flags >> 8);
1901 if (hints & HINT_LOCALE)
1902 pmop->op_pmpermflags = (pmop->op_pmflags |= PMf_LOCALE);
1904 /* link into pm list */
1905 if (type != OP_TRANS && curstash) {
1906 pmop->op_pmnext = HvPMROOT(curstash);
1907 HvPMROOT(curstash) = pmop;
1914 pmruntime(op, expr, repl)
1922 if (op->op_type == OP_TRANS)
1923 return pmtrans(op, expr, repl);
1927 if (expr->op_type == OP_CONST) {
1929 SV *pat = ((SVOP*)expr)->op_sv;
1930 char *p = SvPV(pat, plen);
1931 if ((op->op_flags & OPf_SPECIAL) && strEQ(p, " ")) {
1932 sv_setpvn(pat, "\\s+", 3);
1933 p = SvPV(pat, plen);
1934 pm->op_pmflags |= PMf_SKIPWHITE;
1936 pm->op_pmregexp = pregcomp(p, p + plen, pm);
1937 if (strEQ("\\s+", pm->op_pmregexp->precomp))
1938 pm->op_pmflags |= PMf_WHITE;
1943 if (pm->op_pmflags & PMf_KEEP)
1944 expr = newUNOP(OP_REGCMAYBE,0,expr);
1946 Newz(1101, rcop, 1, LOGOP);
1947 rcop->op_type = OP_REGCOMP;
1948 rcop->op_ppaddr = ppaddr[OP_REGCOMP];
1949 rcop->op_first = scalar(expr);
1950 rcop->op_flags |= OPf_KIDS;
1951 rcop->op_private = 1;
1952 rcop->op_other = op;
1954 /* establish postfix order */
1955 if (pm->op_pmflags & PMf_KEEP) {
1957 rcop->op_next = expr;
1958 ((UNOP*)expr)->op_first->op_next = (OP*)rcop;
1961 rcop->op_next = LINKLIST(expr);
1962 expr->op_next = (OP*)rcop;
1965 prepend_elem(op->op_type, scalar((OP*)rcop), op);
1970 if (pm->op_pmflags & PMf_EVAL)
1972 else if (repl->op_type == OP_CONST)
1976 for (curop = LINKLIST(repl); curop!=repl; curop = LINKLIST(curop)) {
1977 if (opargs[curop->op_type] & OA_DANGEROUS) {
1978 if (curop->op_type == OP_GV) {
1979 GV *gv = ((GVOP*)curop)->op_gv;
1980 if (strchr("&`'123456789+", *GvENAME(gv)))
1983 else if (curop->op_type == OP_RV2CV)
1985 else if (curop->op_type == OP_RV2SV ||
1986 curop->op_type == OP_RV2AV ||
1987 curop->op_type == OP_RV2HV ||
1988 curop->op_type == OP_RV2GV) {
1989 if (lastop && lastop->op_type != OP_GV) /*funny deref?*/
1992 else if (curop->op_type == OP_PADSV ||
1993 curop->op_type == OP_PADAV ||
1994 curop->op_type == OP_PADHV ||
1995 curop->op_type == OP_PADANY) {
2004 if (curop == repl) {
2005 pm->op_pmflags |= PMf_CONST; /* const for long enough */
2006 pm->op_pmpermflags |= PMf_CONST; /* const for long enough */
2007 prepend_elem(op->op_type, scalar(repl), op);
2010 Newz(1101, rcop, 1, LOGOP);
2011 rcop->op_type = OP_SUBSTCONT;
2012 rcop->op_ppaddr = ppaddr[OP_SUBSTCONT];
2013 rcop->op_first = scalar(repl);
2014 rcop->op_flags |= OPf_KIDS;
2015 rcop->op_private = 1;
2016 rcop->op_other = op;
2018 /* establish postfix order */
2019 rcop->op_next = LINKLIST(repl);
2020 repl->op_next = (OP*)rcop;
2022 pm->op_pmreplroot = scalar((OP*)rcop);
2023 pm->op_pmreplstart = LINKLIST(rcop);
2032 newSVOP(type, flags, sv)
2038 Newz(1101, svop, 1, SVOP);
2039 svop->op_type = type;
2040 svop->op_ppaddr = ppaddr[type];
2042 svop->op_next = (OP*)svop;
2043 svop->op_flags = flags;
2044 if (opargs[type] & OA_RETSCALAR)
2046 if (opargs[type] & OA_TARGET)
2047 svop->op_targ = pad_alloc(type, SVs_PADTMP);
2048 return CHECKOP(type, svop);
2052 newGVOP(type, flags, gv)
2058 Newz(1101, gvop, 1, GVOP);
2059 gvop->op_type = type;
2060 gvop->op_ppaddr = ppaddr[type];
2061 gvop->op_gv = (GV*)SvREFCNT_inc(gv);
2062 gvop->op_next = (OP*)gvop;
2063 gvop->op_flags = flags;
2064 if (opargs[type] & OA_RETSCALAR)
2066 if (opargs[type] & OA_TARGET)
2067 gvop->op_targ = pad_alloc(type, SVs_PADTMP);
2068 return CHECKOP(type, gvop);
2072 newPVOP(type, flags, pv)
2078 Newz(1101, pvop, 1, PVOP);
2079 pvop->op_type = type;
2080 pvop->op_ppaddr = ppaddr[type];
2082 pvop->op_next = (OP*)pvop;
2083 pvop->op_flags = flags;
2084 if (opargs[type] & OA_RETSCALAR)
2086 if (opargs[type] & OA_TARGET)
2087 pvop->op_targ = pad_alloc(type, SVs_PADTMP);
2088 return CHECKOP(type, pvop);
2097 save_hptr(&curstash);
2098 save_item(curstname);
2103 name = SvPV(sv, len);
2104 curstash = gv_stashpvn(name,len,TRUE);
2105 sv_setpvn(curstname, name, len);
2109 sv_setpv(curstname,"<none>");
2117 utilize(aver, floor, version, id, arg)
2130 if (id->op_type != OP_CONST)
2131 croak("Module name must be constant");
2135 if(version != Nullop) {
2136 SV *vesv = ((SVOP*)version)->op_sv;
2138 if (arg == Nullop && !SvNIOK(vesv)) {
2145 if (version->op_type != OP_CONST || !SvNIOK(vesv))
2146 croak("Version number must be constant number");
2148 /* Make copy of id so we don't free it twice */
2149 pack = newSVOP(OP_CONST, 0, newSVsv(((SVOP*)id)->op_sv));
2151 /* Fake up a method call to VERSION */
2152 meth = newSVOP(OP_CONST, 0, newSVpv("VERSION", 7));
2153 veop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL,
2154 append_elem(OP_LIST,
2155 prepend_elem(OP_LIST, pack, list(version)),
2156 newUNOP(OP_METHOD, 0, meth)));
2160 /* Fake up an import/unimport */
2161 if (arg && arg->op_type == OP_STUB)
2162 imop = arg; /* no import on explicit () */
2163 else if(SvNIOK(((SVOP*)id)->op_sv)) {
2164 imop = Nullop; /* use 5.0; */
2167 /* Make copy of id so we don't free it twice */
2168 pack = newSVOP(OP_CONST, 0, newSVsv(((SVOP*)id)->op_sv));
2169 meth = newSVOP(OP_CONST, 0,
2171 ? newSVpv("import", 6)
2172 : newSVpv("unimport", 8)
2174 imop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL,
2175 append_elem(OP_LIST,
2176 prepend_elem(OP_LIST, pack, list(arg)),
2177 newUNOP(OP_METHOD, 0, meth)));
2180 /* Fake up a require */
2181 rqop = newUNOP(OP_REQUIRE, 0, id);
2183 /* Fake up the BEGIN {}, which does its thing immediately. */
2185 newSVOP(OP_CONST, 0, newSVpv("BEGIN", 5)),
2187 append_elem(OP_LINESEQ,
2188 append_elem(OP_LINESEQ,
2189 newSTATEOP(0, Nullch, rqop),
2190 newSTATEOP(0, Nullch, veop)),
2191 newSTATEOP(0, Nullch, imop) ));
2198 newSLICEOP(flags, subscript, listval)
2203 return newBINOP(OP_LSLICE, flags,
2204 list(force_list(subscript)),
2205 list(force_list(listval)) );
2215 if (op->op_type == OP_NULL && op->op_flags & OPf_KIDS)
2216 op = cUNOP->op_first;
2218 if (op->op_type == OP_COND_EXPR) {
2219 I32 t = list_assignment(cCONDOP->op_first->op_sibling);
2220 I32 f = list_assignment(cCONDOP->op_first->op_sibling->op_sibling);
2225 yyerror("Assignment to both a list and a scalar");
2229 if (op->op_type == OP_LIST || op->op_flags & OPf_PARENS ||
2230 op->op_type == OP_RV2AV || op->op_type == OP_RV2HV ||
2231 op->op_type == OP_ASLICE || op->op_type == OP_HSLICE)
2234 if (op->op_type == OP_PADAV || op->op_type == OP_PADHV)
2237 if (op->op_type == OP_RV2SV)
2244 newASSIGNOP(flags, left, optype, right)
2253 if (optype == OP_ANDASSIGN || optype == OP_ORASSIGN) {
2254 return newLOGOP(optype, 0,
2255 mod(scalar(left), optype),
2256 newUNOP(OP_SASSIGN, 0, scalar(right)));
2259 return newBINOP(optype, OPf_STACKED,
2260 mod(scalar(left), optype), scalar(right));
2264 if (list_assignment(left)) {
2266 eval_start = right; /* Grandfathering $[ assignment here. Bletch.*/
2267 left = mod(left, OP_AASSIGN);
2275 op = newBINOP(OP_AASSIGN, flags,
2276 list(force_list(right)),
2277 list(force_list(left)) );
2278 op->op_private = 0 | (flags >> 8);
2279 if (!(left->op_private & OPpLVAL_INTRO)) {
2280 static int generation = 100;
2284 for (curop = LINKLIST(op); curop != op; curop = LINKLIST(curop)) {
2285 if (opargs[curop->op_type] & OA_DANGEROUS) {
2286 if (curop->op_type == OP_GV) {
2287 GV *gv = ((GVOP*)curop)->op_gv;
2288 if (gv == defgv || SvCUR(gv) == generation)
2290 SvCUR(gv) = generation;
2292 else if (curop->op_type == OP_PADSV ||
2293 curop->op_type == OP_PADAV ||
2294 curop->op_type == OP_PADHV ||
2295 curop->op_type == OP_PADANY) {
2296 SV **svp = AvARRAY(comppad_name);
2297 SV *sv = svp[curop->op_targ];
2298 if (SvCUR(sv) == generation)
2300 SvCUR(sv) = generation; /* (SvCUR not used any more) */
2302 else if (curop->op_type == OP_RV2CV)
2304 else if (curop->op_type == OP_RV2SV ||
2305 curop->op_type == OP_RV2AV ||
2306 curop->op_type == OP_RV2HV ||
2307 curop->op_type == OP_RV2GV) {
2308 if (lastop->op_type != OP_GV) /* funny deref? */
2317 op->op_private = OPpASSIGN_COMMON;
2319 if (right && right->op_type == OP_SPLIT) {
2321 if ((tmpop = ((LISTOP*)right)->op_first) &&
2322 tmpop->op_type == OP_PUSHRE)
2324 PMOP *pm = (PMOP*)tmpop;
2325 if (left->op_type == OP_RV2AV &&
2326 !(left->op_private & OPpLVAL_INTRO) &&
2327 !(op->op_private & OPpASSIGN_COMMON) )
2329 tmpop = ((UNOP*)left)->op_first;
2330 if (tmpop->op_type == OP_GV && !pm->op_pmreplroot) {
2331 pm->op_pmreplroot = (OP*)((GVOP*)tmpop)->op_gv;
2332 pm->op_pmflags |= PMf_ONCE;
2333 tmpop = ((UNOP*)op)->op_first; /* to list (nulled) */
2334 tmpop = ((UNOP*)tmpop)->op_first; /* to pushmark */
2335 tmpop->op_sibling = Nullop; /* don't free split */
2336 right->op_next = tmpop->op_next; /* fix starting loc */
2337 op_free(op); /* blow off assign */
2338 right->op_flags &= ~(OPf_KNOW|OPf_LIST);
2339 /* "I don't know and I don't care." */
2344 if (modcount < 10000 &&
2345 ((LISTOP*)right)->op_last->op_type == OP_CONST)
2347 SV *sv = ((SVOP*)((LISTOP*)right)->op_last)->op_sv;
2349 sv_setiv(sv, modcount+1);
2357 right = newOP(OP_UNDEF, 0);
2358 if (right->op_type == OP_READLINE) {
2359 right->op_flags |= OPf_STACKED;
2360 return newBINOP(OP_NULL, flags, mod(scalar(left), OP_SASSIGN), scalar(right));
2363 eval_start = right; /* Grandfathering $[ assignment here. Bletch.*/
2364 op = newBINOP(OP_SASSIGN, flags,
2365 scalar(right), mod(scalar(left), OP_SASSIGN) );
2377 newSTATEOP(flags, label, op)
2382 U32 seq = intro_my();
2385 Newz(1101, cop, 1, COP);
2386 if (perldb && curcop->cop_line && curstash != debstash) {
2387 cop->op_type = OP_DBSTATE;
2388 cop->op_ppaddr = ppaddr[ OP_DBSTATE ];
2391 cop->op_type = OP_NEXTSTATE;
2392 cop->op_ppaddr = ppaddr[ OP_NEXTSTATE ];
2394 cop->op_flags = flags;
2395 cop->op_private = 0 | (flags >> 8);
2397 cop->op_private |= NATIVE_HINTS;
2399 cop->op_next = (OP*)cop;
2402 cop->cop_label = label;
2403 hints |= HINT_BLOCK_SCOPE;
2406 cop->cop_arybase = curcop->cop_arybase;
2408 if (copline == NOLINE)
2409 cop->cop_line = curcop->cop_line;
2411 cop->cop_line = copline;
2414 cop->cop_filegv = (GV*)SvREFCNT_inc(curcop->cop_filegv);
2415 cop->cop_stash = curstash;
2417 if (perldb && curstash != debstash) {
2418 SV **svp = av_fetch(GvAV(curcop->cop_filegv),(I32)cop->cop_line, FALSE);
2419 if (svp && *svp != &sv_undef && !SvIOK(*svp)) {
2420 (void)SvIOK_on(*svp);
2422 SvSTASH(*svp) = (HV*)cop;
2426 return prepend_elem(OP_LINESEQ, (OP*)cop, op);
2429 /* "Introduce" my variables to visible status. */
2437 if (! min_intro_pending)
2440 svp = AvARRAY(comppad_name);
2441 for (i = min_intro_pending; i <= max_intro_pending; i++) {
2442 if ((sv = svp[i]) && sv != &sv_undef && !SvIVX(sv)) {
2443 SvIVX(sv) = 999999999; /* Don't know scope end yet. */
2444 SvNVX(sv) = (double)cop_seqmax;
2447 min_intro_pending = 0;
2448 comppad_name_fill = max_intro_pending; /* Needn't search higher */
2449 return cop_seqmax++;
2453 newLOGOP(type, flags, first, other)
2462 if (type == OP_XOR) /* Not short circuit, but here by precedence. */
2463 return newBINOP(type, flags, scalar(first), scalar(other));
2465 scalarboolean(first);
2466 /* optimize "!a && b" to "a || b", and "!a || b" to "a && b" */
2467 if (first->op_type == OP_NOT && (first->op_flags & OPf_SPECIAL)) {
2468 if (type == OP_AND || type == OP_OR) {
2474 first = cUNOP->op_first;
2476 first->op_next = op->op_next;
2477 cUNOP->op_first = Nullop;
2481 if (first->op_type == OP_CONST) {
2482 if (dowarn && (first->op_private & OPpCONST_BARE))
2483 warn("Probable precedence problem on %s", op_desc[type]);
2484 if ((type == OP_AND) == (SvTRUE(((SVOP*)first)->op_sv))) {
2493 else if (first->op_type == OP_WANTARRAY) {
2499 else if (dowarn && (first->op_flags & OPf_KIDS)) {
2500 OP *k1 = ((UNOP*)first)->op_first;
2501 OP *k2 = k1->op_sibling;
2503 switch (first->op_type)
2506 if (k2 && k2->op_type == OP_READLINE
2507 && (k2->op_flags & OPf_STACKED)
2508 && (k1->op_type == OP_RV2SV || k1->op_type == OP_PADSV))
2509 warnop = k2->op_type;
2513 if (k1->op_type == OP_READDIR || k1->op_type == OP_GLOB)
2514 warnop = k1->op_type;
2518 line_t oldline = curcop->cop_line;
2519 curcop->cop_line = copline;
2520 warn("Value of %s construct can be \"0\"; test with defined()",
2522 curcop->cop_line = oldline;
2529 if (type == OP_ANDASSIGN || type == OP_ORASSIGN)
2530 other->op_private |= OPpASSIGN_BACKWARDS; /* other is an OP_SASSIGN */
2532 Newz(1101, logop, 1, LOGOP);
2534 logop->op_type = type;
2535 logop->op_ppaddr = ppaddr[type];
2536 logop->op_first = first;
2537 logop->op_flags = flags | OPf_KIDS;
2538 logop->op_other = LINKLIST(other);
2539 logop->op_private = 1 | (flags >> 8);
2541 /* establish postfix order */
2542 logop->op_next = LINKLIST(first);
2543 first->op_next = (OP*)logop;
2544 first->op_sibling = other;
2546 op = newUNOP(OP_NULL, 0, (OP*)logop);
2547 other->op_next = op;
2553 newCONDOP(flags, first, trueop, falseop)
2563 return newLOGOP(OP_AND, 0, first, trueop);
2565 return newLOGOP(OP_OR, 0, first, falseop);
2567 scalarboolean(first);
2568 if (first->op_type == OP_CONST) {
2569 if (SvTRUE(((SVOP*)first)->op_sv)) {
2580 else if (first->op_type == OP_WANTARRAY) {
2584 Newz(1101, condop, 1, CONDOP);
2586 condop->op_type = OP_COND_EXPR;
2587 condop->op_ppaddr = ppaddr[OP_COND_EXPR];
2588 condop->op_first = first;
2589 condop->op_flags = flags | OPf_KIDS;
2590 condop->op_true = LINKLIST(trueop);
2591 condop->op_false = LINKLIST(falseop);
2592 condop->op_private = 1 | (flags >> 8);
2594 /* establish postfix order */
2595 condop->op_next = LINKLIST(first);
2596 first->op_next = (OP*)condop;
2598 first->op_sibling = trueop;
2599 trueop->op_sibling = falseop;
2600 op = newUNOP(OP_NULL, 0, (OP*)condop);
2602 trueop->op_next = op;
2603 falseop->op_next = op;
2609 newRANGE(flags, left, right)
2619 Newz(1101, condop, 1, CONDOP);
2621 condop->op_type = OP_RANGE;
2622 condop->op_ppaddr = ppaddr[OP_RANGE];
2623 condop->op_first = left;
2624 condop->op_flags = OPf_KIDS;
2625 condop->op_true = LINKLIST(left);
2626 condop->op_false = LINKLIST(right);
2627 condop->op_private = 1 | (flags >> 8);
2629 left->op_sibling = right;
2631 condop->op_next = (OP*)condop;
2632 flip = newUNOP(OP_FLIP, flags, (OP*)condop);
2633 flop = newUNOP(OP_FLOP, 0, flip);
2634 op = newUNOP(OP_NULL, 0, flop);
2637 left->op_next = flip;
2638 right->op_next = flop;
2640 condop->op_targ = pad_alloc(OP_RANGE, SVs_PADMY);
2641 sv_upgrade(PAD_SV(condop->op_targ), SVt_PVNV);
2642 flip->op_targ = pad_alloc(OP_RANGE, SVs_PADMY);
2643 sv_upgrade(PAD_SV(flip->op_targ), SVt_PVNV);
2645 flip->op_private = left->op_type == OP_CONST ? OPpFLIP_LINENUM : 0;
2646 flop->op_private = right->op_type == OP_CONST ? OPpFLIP_LINENUM : 0;
2649 if (!flip->op_private || !flop->op_private)
2650 linklist(op); /* blow off optimizer unless constant */
2656 newLOOPOP(flags, debuggable, expr, block)
2664 int once = block && block->op_flags & OPf_SPECIAL &&
2665 (block->op_type == OP_ENTERSUB || block->op_type == OP_NULL);
2668 if (once && expr->op_type == OP_CONST && !SvTRUE(((SVOP*)expr)->op_sv))
2669 return block; /* do {} while 0 does once */
2670 if (expr->op_type == OP_READLINE || expr->op_type == OP_GLOB) {
2671 expr = newUNOP(OP_DEFINED, 0,
2672 newASSIGNOP(0, newSVREF(newGVOP(OP_GV, 0, defgv)), 0, expr) );
2676 listop = append_elem(OP_LINESEQ, block, newOP(OP_UNSTACK, 0));
2677 op = newLOGOP(OP_AND, 0, expr, listop);
2679 ((LISTOP*)listop)->op_last->op_next = LINKLIST(op);
2681 if (once && op != listop)
2682 op->op_next = ((LOGOP*)cUNOP->op_first)->op_other;
2685 op = newUNOP(OP_NULL, 0, op); /* or do {} while 1 loses outer block */
2687 op->op_flags |= flags;
2689 op->op_flags |= OPf_SPECIAL; /* suppress POPBLOCK curpm restoration*/
2694 newWHILEOP(flags, debuggable, loop, expr, block, cont)
2708 if (expr && (expr->op_type == OP_READLINE || expr->op_type == OP_GLOB)) {
2709 expr = newUNOP(OP_DEFINED, 0,
2710 newASSIGNOP(0, newSVREF(newGVOP(OP_GV, 0, defgv)), 0, expr) );
2714 block = newOP(OP_NULL, 0);
2717 next = LINKLIST(cont);
2719 cont = append_elem(OP_LINESEQ, cont, newOP(OP_UNSTACK, 0));
2721 listop = append_list(OP_LINESEQ, (LISTOP*)block, (LISTOP*)cont);
2722 redo = LINKLIST(listop);
2725 op = newLOGOP(OP_AND, 0, expr, scalar(listop));
2726 if (op == expr && op->op_type == OP_CONST && !SvTRUE(cSVOP->op_sv)) {
2727 op_free(expr); /* oops, it's a while (0) */
2729 return Nullop; /* (listop already freed by newLOGOP) */
2731 ((LISTOP*)listop)->op_last->op_next = condop =
2732 (op == listop ? redo : LINKLIST(op));
2740 Newz(1101,loop,1,LOOP);
2741 loop->op_type = OP_ENTERLOOP;
2742 loop->op_ppaddr = ppaddr[OP_ENTERLOOP];
2743 loop->op_private = 0;
2744 loop->op_next = (OP*)loop;
2747 op = newBINOP(OP_LEAVELOOP, 0, (OP*)loop, op);
2749 loop->op_redoop = redo;
2750 loop->op_lastop = op;
2753 loop->op_nextop = next;
2755 loop->op_nextop = op;
2757 op->op_flags |= flags;
2758 op->op_private |= (flags >> 8);
2763 #ifndef CAN_PROTOTYPE
2764 newFOROP(flags,label,forline,sv,expr,block,cont)
2773 newFOROP(I32 flags,char *label,line_t forline,OP *sv,OP *expr,OP *block,OP *cont)
2774 #endif /* CAN_PROTOTYPE */
2782 if (sv->op_type == OP_RV2SV) { /* symbol table variable */
2783 sv->op_type = OP_RV2GV;
2784 sv->op_ppaddr = ppaddr[OP_RV2GV];
2786 else if (sv->op_type == OP_PADSV) { /* private variable */
2787 padoff = sv->op_targ;
2792 croak("Can't use %s for loop variable", op_desc[sv->op_type]);
2795 sv = newGVOP(OP_GV, 0, defgv);
2797 if (expr->op_type == OP_RV2AV || expr->op_type == OP_PADAV) {
2798 expr = scalar(ref(expr, OP_ITER));
2799 iterflags |= OPf_STACKED;
2801 loop = (LOOP*)list(convert(OP_ENTERITER, iterflags,
2802 append_elem(OP_LIST, mod(force_list(expr), OP_GREPSTART),
2804 assert(!loop->op_next);
2805 Renew(loop, 1, LOOP);
2806 loop->op_targ = padoff;
2807 return newSTATEOP(0, label, newWHILEOP(flags, 1, loop,
2808 newOP(OP_ITER, 0), block, cont));
2812 newLOOPEX(type, label)
2817 if (type != OP_GOTO || label->op_type == OP_CONST) {
2818 op = newPVOP(type, 0, savepv(
2819 label->op_type == OP_CONST
2820 ? SvPVx(((SVOP*)label)->op_sv, na)
2825 if (label->op_type == OP_ENTERSUB)
2826 label = newUNOP(OP_REFGEN, 0, mod(label, OP_REFGEN));
2827 op = newUNOP(type, OPf_STACKED, label);
2829 hints |= HINT_BLOCK_SCOPE;
2837 if (!CvXSUB(cv) && CvROOT(cv)) {
2839 croak("Can't undef active subroutine");
2846 op_free(CvROOT(cv));
2847 CvROOT(cv) = Nullop;
2851 SvREFCNT_dec(CvGV(cv));
2853 SvREFCNT_dec(CvOUTSIDE(cv));
2854 CvOUTSIDE(cv) = Nullcv;
2855 if (CvPADLIST(cv)) {
2856 /* may be during global destruction */
2857 if (SvREFCNT(CvPADLIST(cv))) {
2858 I32 i = AvFILL(CvPADLIST(cv));
2860 SV** svp = av_fetch(CvPADLIST(cv), i--, FALSE);
2864 SvREFCNT_dec((SV*)CvPADLIST(cv));
2866 CvPADLIST(cv) = Nullav;
2870 #ifdef DEBUG_CLOSURES
2875 CV *outside = CvOUTSIDE(cv);
2876 AV* padlist = CvPADLIST(cv);
2883 PerlIO_printf(Perl_debug_log, "\tCV=0x%p (%s), OUTSIDE=0x%p (%s)\n",
2885 (CvANON(cv) ? "ANON"
2886 : (cv == main_cv) ? "MAIN"
2887 : CvUNIQUE(outside) ? "UNIQUE"
2888 : CvGV(cv) ? GvNAME(CvGV(cv)) : "UNDEFINED"),
2891 : CvANON(outside) ? "ANON"
2892 : (outside == main_cv) ? "MAIN"
2893 : CvUNIQUE(outside) ? "UNIQUE"
2894 : CvGV(outside) ? GvNAME(CvGV(outside)) : "UNDEFINED"));
2899 pad_name = (AV*)*av_fetch(padlist, 0, FALSE);
2900 pad = (AV*)*av_fetch(padlist, 1, FALSE);
2901 pname = AvARRAY(pad_name);
2902 ppad = AvARRAY(pad);
2904 for (ix = 1; ix <= AvFILL(pad_name); ix++) {
2905 if (SvPOK(pname[ix]))
2906 PerlIO_printf(Perl_debug_log, "\t%4d. 0x%p (%s\"%s\" %ld-%ld)\n",
2908 SvFAKE(pname[ix]) ? "FAKE " : "",
2910 (long)I_32(SvNVX(pname[ix])),
2911 (long)SvIVX(pname[ix]));
2914 #endif /* DEBUG_CLOSURES */
2917 cv_clone2(proto, outside)
2923 AV* protopadlist = CvPADLIST(proto);
2924 AV* protopad_name = (AV*)*av_fetch(protopadlist, 0, FALSE);
2925 AV* protopad = (AV*)*av_fetch(protopadlist, 1, FALSE);
2926 SV** pname = AvARRAY(protopad_name);
2927 SV** ppad = AvARRAY(protopad);
2928 I32 fname = AvFILL(protopad_name);
2929 I32 fpad = AvFILL(protopad);
2933 assert(!CvUNIQUE(proto));
2940 cv = compcv = (CV*)NEWSV(1104,0);
2941 sv_upgrade((SV *)cv, SvTYPE(proto));
2946 CvFILEGV(cv) = CvFILEGV(proto);
2947 CvGV(cv) = (GV*)SvREFCNT_inc(CvGV(proto));
2948 CvSTASH(cv) = CvSTASH(proto);
2949 CvROOT(cv) = CvROOT(proto);
2950 CvSTART(cv) = CvSTART(proto);
2952 CvOUTSIDE(cv) = (CV*)SvREFCNT_inc(outside);
2956 comppadlist = newAV();
2957 AvREAL_off(comppadlist);
2958 av_store(comppadlist, 0, SvREFCNT_inc((SV*)protopad_name));
2959 av_store(comppadlist, 1, (SV*)comppad);
2960 CvPADLIST(cv) = comppadlist;
2961 av_fill(comppad, AvFILL(protopad));
2962 curpad = AvARRAY(comppad);
2964 av = newAV(); /* will be @_ */
2966 av_store(comppad, 0, (SV*)av);
2967 AvFLAGS(av) = AVf_REIFY;
2969 for (ix = fpad; ix > 0; ix--) {
2970 SV* namesv = (ix <= fname) ? pname[ix] : Nullsv;
2971 if (namesv && namesv != &sv_undef) {
2972 char *name = SvPVX(namesv); /* XXX */
2973 if (SvFLAGS(namesv) & SVf_FAKE) { /* lexical from outside? */
2974 I32 off = pad_findlex(name, ix, SvIVX(namesv),
2975 CvOUTSIDE(cv), cxstack_ix);
2977 curpad[ix] = SvREFCNT_inc(ppad[ix]);
2979 croak("panic: cv_clone: %s", name);
2981 else { /* our own lexical */
2984 /* anon code -- we'll come back for it */
2985 sv = SvREFCNT_inc(ppad[ix]);
2987 else if (*name == '@')
2989 else if (*name == '%')
2999 SV* sv = NEWSV(0,0);
3005 /* Now that vars are all in place, clone nested closures. */
3007 for (ix = fpad; ix > 0; ix--) {
3008 SV* namesv = (ix <= fname) ? pname[ix] : Nullsv;
3010 && namesv != &sv_undef
3011 && !(SvFLAGS(namesv) & SVf_FAKE)
3012 && *SvPVX(namesv) == '&'
3013 && CvCLONE(ppad[ix]))
3015 CV *kid = cv_clone2((CV*)ppad[ix], cv);
3016 SvREFCNT_dec(ppad[ix]);
3019 curpad[ix] = (SV*)kid;
3023 #ifdef DEBUG_CLOSURES
3024 PerlIO_printf(Perl_debug_log, "Cloned inside:\n");
3026 PerlIO_printf(Perl_debug_log, " from:\n");
3028 PerlIO_printf(Perl_debug_log, " to:\n");
3040 return cv_clone2(proto, CvOUTSIDE(proto));
3050 if(cv && SvPOK(cv) && !SvCUR(cv)) {
3051 for (o = CvSTART(cv); o; o = o->op_next) {
3052 OPCODE type = o->op_type;
3054 if (type == OP_NEXTSTATE || type == OP_NULL || type == OP_PUSHMARK)
3056 if (type == OP_LEAVESUB || type == OP_RETURN)
3058 if (type != OP_CONST || sv)
3061 sv = ((SVOP*)o)->op_sv;
3068 newSUB(floor,op,proto,block)
3074 char *name = op ? SvPVx(cSVOP->op_sv, na) : Nullch;
3075 GV *gv = gv_fetchpv(name ? name : "__ANON__", GV_ADDMULTI, SVt_PVCV);
3082 if (cv = (name ? GvCV(gv) : Nullcv)) {
3084 /* just a cached method */
3088 else if (CvROOT(cv) || CvXSUB(cv) || GvASSUMECV(gv)) {
3089 /* already defined (or promised) */
3091 SV* const_sv = cv_const_sv(cv);
3092 char *p = proto ? SvPVx(((SVOP*)proto)->op_sv, na) : Nullch;
3094 if((!proto != !SvPOK(cv)) || (p && strNE(SvPV((SV*)cv,na), p))) {
3095 warn("Prototype mismatch: (%s) vs (%s)",
3096 SvPOK(cv) ? SvPV((SV*)cv,na) : "none",
3100 /* just a "sub foo;" when &foo is already defined */
3104 if (const_sv || dowarn) {
3105 line_t oldline = curcop->cop_line;
3106 curcop->cop_line = copline;
3107 warn(const_sv ? "Constant subroutine %s redefined"
3108 : "Subroutine %s redefined",name);
3109 curcop->cop_line = oldline;
3115 if (cv) { /* must reuse cv if autoloaded */
3117 CvFLAGS(cv) = CvFLAGS(compcv);
3118 CvOUTSIDE(cv) = CvOUTSIDE(compcv);
3119 CvOUTSIDE(compcv) = 0;
3120 CvPADLIST(cv) = CvPADLIST(compcv);
3121 CvPADLIST(compcv) = 0;
3122 if (SvREFCNT(compcv) > 1) /* XXX Make closures transit through stub. */
3123 CvOUTSIDE(compcv) = (CV*)SvREFCNT_inc((SV*)cv);
3124 SvREFCNT_dec(compcv);
3134 CvGV(cv) = (GV*)SvREFCNT_inc(gv);
3135 CvFILEGV(cv) = curcop->cop_filegv;
3136 CvSTASH(cv) = curstash;
3139 char *p = SvPVx(((SVOP*)proto)->op_sv, na);
3140 sv_setpv((SV*)cv, p);
3154 av = newAV(); /* Will be @_ */
3156 av_store(comppad, 0, (SV*)av);
3157 AvFLAGS(av) = AVf_REIFY;
3159 for (ix = AvFILL(comppad); ix > 0; ix--) {
3160 if (!SvPADMY(curpad[ix]) && !SvIMMORTAL(curpad[ix]))
3161 SvPADTMP_on(curpad[ix]);
3164 if (AvFILL(comppad_name) < AvFILL(comppad))
3165 av_store(comppad_name, AvFILL(comppad), Nullsv);
3167 CvROOT(cv) = newUNOP(OP_LEAVESUB, 0, scalarseq(block));
3168 CvSTART(cv) = LINKLIST(CvROOT(cv));
3169 CvROOT(cv)->op_next = 0;
3175 if (perldb && curstash != debstash) {
3177 SV *tmpstr = sv_newmortal();
3178 static GV *db_postponed;
3182 sprintf(buf, "%s:%ld",
3183 SvPVX(GvSV(curcop->cop_filegv)), (long)subline);
3184 sv = newSVpv(buf,0);
3186 sprintf(buf,"%ld",(long)curcop->cop_line);
3188 gv_efullname3(tmpstr, gv, Nullch);
3189 hv_store(GvHV(DBsub), SvPVX(tmpstr), SvCUR(tmpstr), sv, 0);
3190 if (!db_postponed) {
3191 db_postponed = gv_fetchpv("DB::postponed", GV_ADDMULTI, SVt_PVHV);
3193 hv = GvHVn(db_postponed);
3194 if (HvFILL(hv) > 0 && hv_exists(hv, SvPVX(tmpstr), SvCUR(tmpstr))
3195 && (cv = GvCV(db_postponed))) {
3200 perl_call_sv((SV*)cv, G_DISCARD);
3204 if ((s = strrchr(name,':')))
3208 if (strEQ(s, "BEGIN") && !error_count) {
3209 I32 oldscope = scopestack_ix;
3211 SAVESPTR(compiling.cop_filegv);
3212 SAVEI16(compiling.cop_line);
3219 DEBUG_x( dump_sub(gv) );
3220 av_push(beginav, (SV *)cv);
3222 calllist(oldscope, beginav);
3224 curcop = &compiling;
3227 else if (strEQ(s, "END") && !error_count) {
3230 av_unshift(endav, 1);
3231 av_store(endav, 0, (SV *)cv);
3244 newXSUB(name, ix, subaddr, filename)
3250 CV* cv = newXS(name, (void(*)())subaddr, filename);
3252 CvXSUBANY(cv).any_i32 = ix;
3258 newXS(name, subaddr, filename)
3260 void (*subaddr) _((CV*));
3263 GV *gv = gv_fetchpv(name ? name : "__ANON__", GV_ADDMULTI, SVt_PVCV);
3266 if (cv = (name ? GvCV(gv) : Nullcv)) {
3268 /* just a cached method */
3272 else if (CvROOT(cv) || CvXSUB(cv) || GvASSUMECV(gv)) {
3273 /* already defined (or promised) */
3275 line_t oldline = curcop->cop_line;
3276 curcop->cop_line = copline;
3277 warn("Subroutine %s redefined",name);
3278 curcop->cop_line = oldline;
3285 if (cv) /* must reuse cv if autoloaded */
3288 cv = (CV*)NEWSV(1105,0);
3289 sv_upgrade((SV *)cv, SVt_PVCV);
3296 CvGV(cv) = (GV*)SvREFCNT_inc(gv);
3297 CvFILEGV(cv) = gv_fetchfile(filename);
3298 CvXSUB(cv) = subaddr;
3301 char *s = strrchr(name,':');
3306 if (strEQ(s, "BEGIN")) {
3309 av_push(beginav, (SV *)cv);
3312 else if (strEQ(s, "END")) {
3315 av_unshift(endav, 1);
3316 av_store(endav, 0, (SV *)cv);
3327 newFORM(floor,op,block)
3338 name = SvPVx(cSVOP->op_sv, na);
3341 gv = gv_fetchpv(name,TRUE, SVt_PVFM);
3343 if (cv = GvFORM(gv)) {
3345 line_t oldline = curcop->cop_line;
3347 curcop->cop_line = copline;
3348 warn("Format %s redefined",name);
3349 curcop->cop_line = oldline;
3355 CvGV(cv) = (GV*)SvREFCNT_inc(gv);
3356 CvFILEGV(cv) = curcop->cop_filegv;
3358 for (ix = AvFILL(comppad); ix > 0; ix--) {
3359 if (!SvPADMY(curpad[ix]) && !SvIMMORTAL(curpad[ix]))
3360 SvPADTMP_on(curpad[ix]);
3363 CvROOT(cv) = newUNOP(OP_LEAVEWRITE, 0, scalarseq(block));
3364 CvSTART(cv) = LINKLIST(CvROOT(cv));
3365 CvROOT(cv)->op_next = 0;
3376 return newUNOP(OP_REFGEN, 0,
3377 mod(list(convert(OP_ANONLIST, 0, op)), OP_REFGEN));
3384 return newUNOP(OP_REFGEN, 0,
3385 mod(list(convert(OP_ANONHASH, 0, op)), OP_REFGEN));
3389 newANONSUB(floor, proto, block)
3394 return newUNOP(OP_REFGEN, 0,
3395 newSVOP(OP_ANONCODE, 0, (SV*)newSUB(floor, 0, proto, block)));
3402 switch (o->op_type) {
3404 o->op_type = OP_PADAV;
3405 o->op_ppaddr = ppaddr[OP_PADAV];
3406 return ref(newUNOP(OP_RV2AV, 0, scalar(o)), OP_RV2AV);
3409 o->op_type = OP_RV2AV;
3410 o->op_ppaddr = ppaddr[OP_RV2AV];
3415 warn("oops: oopsAV");
3425 switch (o->op_type) {
3428 o->op_type = OP_PADHV;
3429 o->op_ppaddr = ppaddr[OP_PADHV];
3430 return ref(newUNOP(OP_RV2HV, 0, scalar(o)), OP_RV2HV);
3434 o->op_type = OP_RV2HV;
3435 o->op_ppaddr = ppaddr[OP_RV2HV];
3440 warn("oops: oopsHV");
3450 if (o->op_type == OP_PADANY) {
3451 o->op_type = OP_PADAV;
3452 o->op_ppaddr = ppaddr[OP_PADAV];
3455 return newUNOP(OP_RV2AV, 0, scalar(o));
3463 if (type == OP_MAPSTART)
3464 return newUNOP(OP_NULL, 0, o);
3465 return ref(newUNOP(OP_RV2GV, OPf_REF, o), type);
3472 if (o->op_type == OP_PADANY) {
3473 o->op_type = OP_PADHV;
3474 o->op_ppaddr = ppaddr[OP_PADHV];
3477 return newUNOP(OP_RV2HV, 0, scalar(o));
3484 croak("NOT IMPL LINE %d",__LINE__);
3494 return newUNOP(OP_RV2CV, flags, scalar(o));
3501 if (o->op_type == OP_PADANY) {
3502 o->op_type = OP_PADSV;
3503 o->op_ppaddr = ppaddr[OP_PADSV];
3506 return newUNOP(OP_RV2SV, 0, scalar(o));
3509 /* Check routines. */
3518 name = NEWSV(1106,0);
3519 sv_upgrade(name, SVt_PVNV);
3520 sv_setpvn(name, "&", 1);
3523 ix = pad_alloc(op->op_type, SVs_PADMY);
3524 av_store(comppad_name, ix, name);
3525 av_store(comppad, ix, cSVOP->op_sv);
3526 SvPADMY_on(cSVOP->op_sv);
3527 cSVOP->op_sv = Nullsv;
3528 cSVOP->op_targ = ix;
3536 op->op_private = hints;
3544 if (cUNOP->op_first->op_type == OP_CONCAT)
3545 op->op_flags |= OPf_STACKED;
3553 if (op->op_flags & OPf_KIDS) {
3556 OPCODE type = op->op_type;
3557 op = modkids(ck_fun(op), type);
3558 kid = cUNOP->op_first;
3559 newop = kUNOP->op_first->op_sibling;
3561 (newop->op_sibling ||
3562 !(opargs[newop->op_type] & OA_RETSCALAR) ||
3563 newop->op_type == OP_PADAV || newop->op_type == OP_PADHV ||
3564 newop->op_type == OP_RV2AV || newop->op_type == OP_RV2HV)) {
3568 op_free(kUNOP->op_first);
3569 kUNOP->op_first = newop;
3571 op->op_ppaddr = ppaddr[++op->op_type];
3581 if (op->op_flags & OPf_KIDS) {
3582 OP *kid = cUNOP->op_first;
3583 if (kid->op_type == OP_HSLICE)
3584 op->op_private |= OPpSLICE;
3585 else if (kid->op_type != OP_HELEM)
3586 croak("%s argument is not a HASH element or slice",
3587 op_desc[op->op_type]);
3597 I32 type = op->op_type;
3599 if (op->op_flags & OPf_KIDS) {
3600 if (cLISTOP->op_first->op_type == OP_STUB) {
3602 op = newUNOP(type, OPf_SPECIAL,
3603 newGVOP(OP_GV, 0, gv_fetchpv("main'ARGV", TRUE, SVt_PVAV)));
3614 hints |= HINT_BLOCK_SCOPE;
3615 if (op->op_flags & OPf_KIDS) {
3616 SVOP *kid = (SVOP*)cUNOP->op_first;
3619 op->op_flags &= ~OPf_KIDS;
3622 else if (kid->op_type == OP_LINESEQ) {
3625 kid->op_next = op->op_next;
3626 cUNOP->op_first = 0;
3629 Newz(1101, enter, 1, LOGOP);
3630 enter->op_type = OP_ENTERTRY;
3631 enter->op_ppaddr = ppaddr[OP_ENTERTRY];
3632 enter->op_private = 0;
3634 /* establish postfix order */
3635 enter->op_next = (OP*)enter;
3637 op = prepend_elem(OP_LINESEQ, (OP*)enter, (OP*)kid);
3638 op->op_type = OP_LEAVETRY;
3639 op->op_ppaddr = ppaddr[OP_LEAVETRY];
3640 enter->op_other = op;
3646 op = newUNOP(OP_ENTEREVAL, 0, newSVREF(newGVOP(OP_GV, 0, defgv)));
3648 op->op_targ = (PADOFFSET)hints;
3657 if (op->op_flags & OPf_STACKED) {
3659 kid = cUNOP->op_first->op_sibling;
3660 if (kid->op_type == OP_RV2GV)
3673 if (op->op_flags & OPf_KIDS) {
3674 OP *kid = cUNOP->op_first;
3675 if (kid->op_type != OP_HELEM)
3676 croak("%s argument is not a HASH element", op_desc[op->op_type]);
3686 o = fold_constants(o);
3687 if (o->op_type == OP_CONST)
3696 SVOP *kid = (SVOP*)cUNOP->op_first;
3698 op->op_private |= (hints & HINT_STRICT_REFS);
3699 if (kid->op_type == OP_CONST) {
3704 name = SvPV(kid->op_sv, na);
3705 if ((hints & HINT_STRICT_REFS) && (kid->op_private & OPpCONST_BARE)) {
3706 char *badthing = Nullch;
3707 switch (op->op_type) {
3709 badthing = "a SCALAR";
3712 badthing = "an ARRAY";
3715 badthing = "a HASH";
3720 "Can't use bareword (\"%s\") as %s ref while \"strict refs\" in use",
3723 kid->op_type = OP_GV;
3724 iscv = (op->op_type == OP_RV2CV) * 2;
3725 for (gv = 0; !gv; iscv++) {
3727 * This is a little tricky. We only want to add the symbol if we
3728 * didn't add it in the lexer. Otherwise we get duplicate strict
3729 * warnings. But if we didn't add it in the lexer, we must at
3730 * least pretend like we wanted to add it even if it existed before,
3731 * or we get possible typo warnings. OPpCONST_ENTERED says
3732 * whether the lexer already added THIS instance of this symbol.
3734 gv = gv_fetchpv(name,
3735 iscv | !(kid->op_private & OPpCONST_ENTERED),
3738 : op->op_type == OP_RV2SV
3740 : op->op_type == OP_RV2AV
3742 : op->op_type == OP_RV2HV
3746 SvREFCNT_dec(kid->op_sv);
3747 kid->op_sv = SvREFCNT_inc(gv);
3756 I32 type = op->op_type;
3758 if (op->op_flags & OPf_REF)
3761 if (op->op_flags & OPf_KIDS) {
3762 SVOP *kid = (SVOP*)cUNOP->op_first;
3764 if (kid->op_type == OP_CONST && (kid->op_private & OPpCONST_BARE)) {
3765 OP *newop = newGVOP(type, OPf_REF,
3766 gv_fetchpv(SvPVx(kid->op_sv, na), TRUE, SVt_PVIO));
3773 if (type == OP_FTTTY)
3774 return newGVOP(type, OPf_REF, gv_fetchpv("main'STDIN", TRUE,
3777 return newUNOP(type, 0, newSVREF(newGVOP(OP_GV, 0, defgv)));
3790 int type = op->op_type;
3791 register I32 oa = opargs[type] >> OASHIFT;
3793 if (op->op_flags & OPf_STACKED) {
3794 if ((oa & OA_OPTIONAL) && (oa >> 4) && !((oa >> 4) & OA_OPTIONAL))
3797 return no_fh_allowed(op);
3800 if (op->op_flags & OPf_KIDS) {
3801 tokid = &cLISTOP->op_first;
3802 kid = cLISTOP->op_first;
3803 if (kid->op_type == OP_PUSHMARK ||
3804 kid->op_type == OP_NULL && kid->op_targ == OP_PUSHMARK)
3806 tokid = &kid->op_sibling;
3807 kid = kid->op_sibling;
3809 if (!kid && opargs[type] & OA_DEFGV)
3810 *tokid = kid = newSVREF(newGVOP(OP_GV, 0, defgv));
3814 sibl = kid->op_sibling;
3828 if (kid->op_type == OP_CONST &&
3829 (kid->op_private & OPpCONST_BARE)) {
3830 char *name = SvPVx(((SVOP*)kid)->op_sv, na);
3831 OP *newop = newAVREF(newGVOP(OP_GV, 0,
3832 gv_fetchpv(name, TRUE, SVt_PVAV) ));
3834 warn("Array @%s missing the @ in argument %ld of %s()",
3835 name, (long)numargs, op_desc[type]);
3838 kid->op_sibling = sibl;
3841 else if (kid->op_type != OP_RV2AV && kid->op_type != OP_PADAV)
3842 bad_type(numargs, "array", op_desc[op->op_type], kid);
3846 if (kid->op_type == OP_CONST &&
3847 (kid->op_private & OPpCONST_BARE)) {
3848 char *name = SvPVx(((SVOP*)kid)->op_sv, na);
3849 OP *newop = newHVREF(newGVOP(OP_GV, 0,
3850 gv_fetchpv(name, TRUE, SVt_PVHV) ));
3852 warn("Hash %%%s missing the %% in argument %ld of %s()",
3853 name, (long)numargs, op_desc[type]);
3856 kid->op_sibling = sibl;
3859 else if (kid->op_type != OP_RV2HV && kid->op_type != OP_PADHV)
3860 bad_type(numargs, "hash", op_desc[op->op_type], kid);
3865 OP *newop = newUNOP(OP_NULL, 0, kid);
3866 kid->op_sibling = 0;
3868 newop->op_next = newop;
3870 kid->op_sibling = sibl;
3875 if (kid->op_type != OP_GV) {
3876 if (kid->op_type == OP_CONST &&
3877 (kid->op_private & OPpCONST_BARE)) {
3878 OP *newop = newGVOP(OP_GV, 0,
3879 gv_fetchpv(SvPVx(((SVOP*)kid)->op_sv, na), TRUE,
3885 kid->op_sibling = 0;
3886 kid = newUNOP(OP_RV2GV, 0, scalar(kid));
3888 kid->op_sibling = sibl;
3894 mod(scalar(kid), type);
3898 tokid = &kid->op_sibling;
3899 kid = kid->op_sibling;
3901 op->op_private |= numargs;
3903 return too_many_arguments(op,op_desc[op->op_type]);
3906 else if (opargs[type] & OA_DEFGV) {
3908 return newUNOP(type, 0, newSVREF(newGVOP(OP_GV, 0, defgv)));
3912 while (oa & OA_OPTIONAL)
3914 if (oa && oa != OA_LIST)
3915 return too_few_arguments(op,op_desc[op->op_type]);
3924 GV *gv = gv_fetchpv("glob", FALSE, SVt_PVCV);
3926 if (gv && GvIMPORTED_CV(gv)) {
3927 op->op_type = OP_LIST;
3928 op->op_ppaddr = ppaddr[OP_LIST];
3929 op = newUNOP(OP_ENTERSUB, OPf_STACKED,
3930 append_elem(OP_LIST, op,
3931 scalar(newUNOP(OP_RV2CV, 0,
3932 newGVOP(OP_GV, 0, gv)))));
3935 if ((op->op_flags & OPf_KIDS) && !cLISTOP->op_first->op_sibling)
3936 append_elem(OP_GLOB, op, newSVREF(newGVOP(OP_GV, 0, defgv)));
3937 gv = newGVgen("main");
3939 append_elem(OP_GLOB, op, newGVOP(OP_GV, 0, gv));
3950 OPCODE type = op->op_type == OP_GREPSTART ? OP_GREPWHILE : OP_MAPWHILE;
3952 op->op_ppaddr = ppaddr[OP_GREPSTART];
3953 Newz(1101, gwop, 1, LOGOP);
3955 if (op->op_flags & OPf_STACKED) {
3958 kid = cLISTOP->op_first->op_sibling;
3959 for (k = cLISTOP->op_first->op_sibling->op_next; k; k = k->op_next) {
3962 kid->op_next = (OP*)gwop;
3963 op->op_flags &= ~OPf_STACKED;
3965 kid = cLISTOP->op_first->op_sibling;
3966 if (type == OP_MAPWHILE)
3973 kid = cLISTOP->op_first->op_sibling;
3974 if (kid->op_type != OP_NULL)
3975 croak("panic: ck_grep");
3976 kid = kUNOP->op_first;
3978 gwop->op_type = type;
3979 gwop->op_ppaddr = ppaddr[type];
3980 gwop->op_first = listkids(op);
3981 gwop->op_flags |= OPf_KIDS;
3982 gwop->op_private = 1;
3983 gwop->op_other = LINKLIST(kid);
3984 gwop->op_targ = pad_alloc(type, SVs_PADTMP);
3985 kid->op_next = (OP*)gwop;
3987 kid = cLISTOP->op_first->op_sibling;
3988 if (!kid || !kid->op_sibling)
3989 return too_few_arguments(op,op_desc[op->op_type]);
3990 for (kid = kid->op_sibling; kid; kid = kid->op_sibling)
3991 mod(kid, OP_GREPSTART);
4000 if (op->op_flags & OPf_KIDS) {
4001 OP *kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4002 if (kid && kid->op_type == OP_CONST)
4003 fbm_compile(((SVOP*)kid)->op_sv);
4012 /* XXX length optimization goes here */
4020 OPCODE type = op->op_type;
4021 return modkids(ck_fun(op), type);
4028 OPCODE type = op->op_type;
4029 return refkids(ck_fun(op), type);
4038 kid = cLISTOP->op_first;
4040 op = force_list(op);
4041 kid = cLISTOP->op_first;
4043 if (kid->op_type == OP_PUSHMARK)
4044 kid = kid->op_sibling;
4045 if (kid && op->op_flags & OPf_STACKED)
4046 kid = kid->op_sibling;
4047 else if (kid && !kid->op_sibling) { /* print HANDLE; */
4048 if (kid->op_type == OP_CONST && kid->op_private & OPpCONST_BARE) {
4049 op->op_flags |= OPf_STACKED; /* make it a filehandle */
4050 kid = newUNOP(OP_RV2GV, OPf_REF, scalar(kid));
4051 cLISTOP->op_first->op_sibling = kid;
4052 cLISTOP->op_last = kid;
4053 kid = kid->op_sibling;
4058 append_elem(op->op_type, op, newSVREF(newGVOP(OP_GV, 0, defgv)) );
4064 if (hints & HINT_LOCALE)
4065 op->op_private |= OPpLOCALE;
4079 if (hints & HINT_LOCALE)
4080 op->op_private |= OPpLOCALE;
4092 if (hints & HINT_LOCALE)
4093 op->op_private |= OPpLOCALE;
4103 cPMOP->op_pmflags |= PMf_RUNTIME;
4104 cPMOP->op_pmpermflags |= PMf_RUNTIME;
4119 if (cBINOP->op_first->op_flags & OPf_PARENS) {
4120 op->op_private |= OPpREPEAT_DOLIST;
4121 cBINOP->op_first = force_list(cBINOP->op_first);
4132 if (op->op_flags & OPf_KIDS) { /* Shall we supply missing .pm? */
4133 SVOP *kid = (SVOP*)cUNOP->op_first;
4135 if (kid->op_type == OP_CONST && (kid->op_private & OPpCONST_BARE)) {
4137 for (s = SvPVX(kid->op_sv); *s; s++) {
4138 if (*s == ':' && s[1] == ':') {
4140 Move(s+2, s+1, strlen(s+2)+1, char);
4141 --SvCUR(kid->op_sv);
4144 sv_catpvn(kid->op_sv, ".pm", 3);
4154 croak("NOT IMPL LINE %d",__LINE__);
4164 if (op->op_flags & OPf_KIDS) {
4165 kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4166 if (kid && kid->op_sibling) {
4167 op->op_type = OP_SSELECT;
4168 op->op_ppaddr = ppaddr[OP_SSELECT];
4170 return fold_constants(op);
4174 kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4175 if (kid && kid->op_type == OP_RV2GV)
4176 kid->op_private &= ~HINT_STRICT_REFS;
4184 I32 type = op->op_type;
4186 if (!(op->op_flags & OPf_KIDS)) {
4188 return newUNOP(type, 0,
4189 scalar(newUNOP(OP_RV2AV, 0,
4190 scalar(newGVOP(OP_GV, 0, subline
4192 : gv_fetchpv("ARGV", TRUE, SVt_PVAV) )))));
4194 return scalar(modkids(ck_fun(op), type));
4203 if (hints & HINT_LOCALE)
4204 op->op_private |= OPpLOCALE;
4207 if (op->op_flags & OPf_STACKED) {
4208 OP *kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4210 kid = kUNOP->op_first; /* get past rv2gv */
4212 if (kid->op_type == OP_SCOPE || kid->op_type == OP_LEAVE) {
4214 if (kid->op_type == OP_SCOPE) {
4218 else if (kid->op_type == OP_LEAVE) {
4219 if (op->op_type == OP_SORT) {
4220 null(kid); /* wipe out leave */
4223 for (k = kLISTOP->op_first->op_next; k; k = k->op_next) {
4224 if (k->op_next == kid)
4229 kid->op_next = 0; /* just disconnect the leave */
4230 k = kLISTOP->op_first;
4234 kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4235 null(kid); /* wipe out rv2gv */
4236 if (op->op_type == OP_SORT)
4240 op->op_flags |= OPf_SPECIAL;
4254 if (op->op_flags & OPf_STACKED)
4255 return no_fh_allowed(op);
4257 kid = cLISTOP->op_first;
4258 if (kid->op_type != OP_NULL)
4259 croak("panic: ck_split");
4260 kid = kid->op_sibling;
4261 op_free(cLISTOP->op_first);
4262 cLISTOP->op_first = kid;
4264 cLISTOP->op_first = kid = newSVOP(OP_CONST, 0, newSVpv(" ", 1));
4265 cLISTOP->op_last = kid; /* There was only one element previously */
4268 if (kid->op_type != OP_MATCH) {
4269 OP *sibl = kid->op_sibling;
4270 kid->op_sibling = 0;
4271 kid = pmruntime( newPMOP(OP_MATCH, OPf_SPECIAL), kid, Nullop);
4272 if (cLISTOP->op_first == cLISTOP->op_last)
4273 cLISTOP->op_last = kid;
4274 cLISTOP->op_first = kid;
4275 kid->op_sibling = sibl;
4278 if (pm->op_pmshort && !(pm->op_pmflags & PMf_ALL)) {
4279 SvREFCNT_dec(pm->op_pmshort); /* can't use substring to optimize */
4283 kid->op_type = OP_PUSHRE;
4284 kid->op_ppaddr = ppaddr[OP_PUSHRE];
4287 if (!kid->op_sibling)
4288 append_elem(OP_SPLIT, op, newSVREF(newGVOP(OP_GV, 0, defgv)) );
4290 kid = kid->op_sibling;
4293 if (!kid->op_sibling)
4294 append_elem(OP_SPLIT, op, newSVOP(OP_CONST, 0, newSViv(0)));
4296 kid = kid->op_sibling;
4299 if (kid->op_sibling)
4300 return too_many_arguments(op,op_desc[op->op_type]);
4309 OP *prev = ((cUNOP->op_first->op_sibling)
4310 ? cUNOP : ((UNOP*)cUNOP->op_first))->op_first;
4311 OP *o = prev->op_sibling;
4318 for (cvop = o; cvop->op_sibling; cvop = cvop->op_sibling) ;
4319 if (cvop->op_type == OP_RV2CV) {
4321 op->op_private |= (cvop->op_private & OPpENTERSUB_AMPER);
4322 null(cvop); /* disable rv2cv */
4323 tmpop = (SVOP*)((UNOP*)cvop)->op_first;
4324 if (tmpop->op_type == OP_GV) {
4325 cv = GvCVu(tmpop->op_sv);
4326 if (cv && SvPOK(cv) && !(op->op_private & OPpENTERSUB_AMPER))
4327 proto = SvPV((SV*)cv,na);
4330 op->op_private |= (hints & HINT_STRICT_REFS);
4331 if (perldb && curstash != debstash)
4332 op->op_private |= OPpENTERSUB_DB;
4337 return too_many_arguments(op, CvNAME(cv));
4355 if (o->op_type != OP_REFGEN && o->op_type != OP_UNDEF)
4356 bad_type(arg, "block", CvNAME(cv), o);
4361 if (o->op_type == OP_RV2GV)
4365 o = newUNOP(OP_RV2GV, 0, kid);
4366 o->op_sibling = kid->op_sibling;
4367 kid->op_sibling = 0;
4368 prev->op_sibling = o;
4376 if (o->op_type != OP_RV2GV)
4377 bad_type(arg, "symbol", CvNAME(cv), o);
4380 if (o->op_type != OP_RV2CV)
4381 bad_type(arg, "sub", CvNAME(cv), o);
4384 if (o->op_type != OP_RV2SV && o->op_type != OP_PADSV)
4385 bad_type(arg, "scalar", CvNAME(cv), o);
4388 if (o->op_type != OP_RV2AV && o->op_type != OP_PADAV)
4389 bad_type(arg, "array", CvNAME(cv), o);
4392 if (o->op_type != OP_RV2HV && o->op_type != OP_PADHV)
4393 bad_type(arg, "hash", CvNAME(cv), o);
4397 o = newUNOP(OP_REFGEN, 0, kid);
4398 o->op_sibling = kid->op_sibling;
4399 kid->op_sibling = 0;
4400 prev->op_sibling = o;
4411 croak("Malformed prototype for %s: %s",
4412 CvNAME(cv),SvPV((SV*)cv,na));
4420 if (proto && !optional && *proto == '$')
4421 return too_few_arguments(op, CvNAME(cv));
4429 SvREADONLY_on(cSVOP->op_sv);
4437 if (op->op_flags & OPf_KIDS) {
4438 SVOP *kid = (SVOP*)cUNOP->op_first;
4440 if (kid->op_type == OP_NULL)
4441 kid = (SVOP*)kid->op_sibling;
4443 kid->op_type == OP_CONST && (kid->op_private & OPpCONST_BARE))
4444 op->op_flags |= OPf_SPECIAL;
4449 /* A peephole optimizer. We visit the ops in the order they're to execute. */
4455 register OP* oldop = 0;
4456 if (!o || o->op_seq)
4461 for (; o; o = o->op_next) {
4467 switch (o->op_type) {
4470 curcop = ((COP*)o); /* for warnings */
4471 o->op_seq = op_seqmax++;
4482 if (o->op_next->op_type == OP_STRINGIFY)
4484 o->op_seq = op_seqmax++;
4487 if ((o->op_flags & (OPf_KNOW|OPf_LIST)) != (OPf_KNOW|OPf_LIST)) {
4488 o->op_seq = op_seqmax++;
4489 break; /* Scalar stub must produce undef. List stub is noop */
4493 if (o->op_targ == OP_NEXTSTATE || o->op_targ == OP_DBSTATE)
4494 curcop = ((COP*)op);
4500 if (oldop && o->op_next) {
4501 oldop->op_next = o->op_next;
4504 o->op_seq = op_seqmax++;
4508 if (o->op_next->op_type == OP_RV2SV) {
4509 if (!(o->op_next->op_private & OPpDEREF)) {
4511 o->op_private |= o->op_next->op_private & OPpLVAL_INTRO;
4512 o->op_next = o->op_next->op_next;
4513 o->op_type = OP_GVSV;
4514 o->op_ppaddr = ppaddr[OP_GVSV];
4517 else if (o->op_next->op_type == OP_RV2AV) {
4518 OP* pop = o->op_next->op_next;
4520 if (pop->op_type == OP_CONST &&
4521 (op = pop->op_next) &&
4522 pop->op_next->op_type == OP_AELEM &&
4523 !(pop->op_next->op_private & (OPpDEREF|OPpLVAL_INTRO)) &&
4524 (i = SvIV(((SVOP*)pop)->op_sv) - compiling.cop_arybase)
4528 SvREFCNT_dec(((SVOP*)pop)->op_sv);
4532 o->op_flags |= pop->op_next->op_flags & OPf_MOD;
4533 o->op_next = pop->op_next->op_next;
4534 o->op_type = OP_AELEMFAST;
4535 o->op_ppaddr = ppaddr[OP_AELEMFAST];
4536 o->op_private = (U8)i;
4537 GvAVn(((GVOP*)o)->op_gv);
4540 o->op_seq = op_seqmax++;
4547 o->op_seq = op_seqmax++;
4548 peep(cLOGOP->op_other);
4552 o->op_seq = op_seqmax++;
4553 peep(cCONDOP->op_true);
4554 peep(cCONDOP->op_false);
4558 o->op_seq = op_seqmax++;
4559 peep(cLOOP->op_redoop);
4560 peep(cLOOP->op_nextop);
4561 peep(cLOOP->op_lastop);
4566 o->op_seq = op_seqmax++;
4567 peep(cPMOP->op_pmreplstart);
4571 o->op_seq = op_seqmax++;
4572 if (dowarn && o->op_next && o->op_next->op_type == OP_NEXTSTATE) {
4573 if (o->op_next->op_sibling &&
4574 o->op_next->op_sibling->op_type != OP_DIE) {
4575 line_t oldline = curcop->cop_line;
4577 curcop->cop_line = ((COP*)o->op_next)->cop_line;
4578 warn("Statement unlikely to be reached");
4579 warn("(Maybe you meant system() when you said exec()?)\n");
4580 curcop->cop_line = oldline;
4585 o->op_seq = op_seqmax++;