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 %d\n", 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 %d\n", 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 %d\n", 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)
1267 if (right->op_type == OP_MATCH ||
1268 right->op_type == OP_SUBST ||
1269 right->op_type == OP_TRANS) {
1270 right->op_flags |= OPf_STACKED;
1271 if (right->op_type != OP_MATCH)
1272 left = mod(left, right->op_type);
1273 if (right->op_type == OP_TRANS)
1274 op = newBINOP(OP_NULL, OPf_STACKED, scalar(left), right);
1276 op = prepend_elem(right->op_type, scalar(left), right);
1278 return newUNOP(OP_NOT, 0, scalar(op));
1282 return bind_match(type, left,
1283 pmruntime(newPMOP(OP_MATCH, 0), right, Nullop));
1292 /* XXX need to optimize away NOT NOT here? Or do we let optimizer do it? */
1293 return newUNOP(OP_NOT, OPf_SPECIAL, scalar(op));
1301 if (o->op_flags & OPf_PARENS || perldb || tainting) {
1302 o = prepend_elem(OP_LINESEQ, newOP(OP_ENTER, 0), o);
1303 o->op_type = OP_LEAVE;
1304 o->op_ppaddr = ppaddr[OP_LEAVE];
1307 if (o->op_type == OP_LINESEQ) {
1309 o->op_type = OP_SCOPE;
1310 o->op_ppaddr = ppaddr[OP_SCOPE];
1311 kid = ((LISTOP*)o)->op_first;
1312 if (kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE){
1313 SvREFCNT_dec(((COP*)kid)->cop_filegv);
1318 o = newLISTOP(OP_SCOPE, 0, o, Nullop);
1328 int retval = savestack_ix;
1329 SAVEI32(comppad_name_floor);
1331 if ((comppad_name_fill = AvFILL(comppad_name)) > 0)
1332 comppad_name_floor = comppad_name_fill;
1334 comppad_name_floor = 0;
1336 SAVEI32(min_intro_pending);
1337 SAVEI32(max_intro_pending);
1338 min_intro_pending = 0;
1339 SAVEI32(comppad_name_fill);
1340 SAVEI32(padix_floor);
1341 padix_floor = padix;
1342 pad_reset_pending = FALSE;
1344 hints &= ~HINT_BLOCK_SCOPE;
1349 block_end(floor, seq)
1353 int needblockscope = hints & HINT_BLOCK_SCOPE;
1354 OP* retval = scalarseq(seq);
1356 pad_reset_pending = FALSE;
1358 hints |= HINT_BLOCK_SCOPE; /* propagate out */
1359 pad_leavemy(comppad_name_fill);
1369 eval_root = newUNOP(OP_LEAVEEVAL, ((in_eval & 4) ? OPf_SPECIAL : 0), op);
1370 eval_start = linklist(eval_root);
1371 eval_root->op_next = 0;
1377 main_root = scope(sawparens(scalarvoid(op)));
1378 curcop = &compiling;
1379 main_start = LINKLIST(main_root);
1380 main_root->op_next = 0;
1384 /* Register with debugger */
1386 CV *cv = perl_get_cv("DB::postponed", FALSE);
1390 XPUSHs((SV*)compiling.cop_filegv);
1392 perl_call_sv((SV*)cv, G_DISCARD);
1403 if (o->op_flags & OPf_PARENS)
1407 if (dowarn && bufptr > oldbufptr && bufptr[-1] == ',') {
1409 for (s = bufptr; *s && (isALNUM(*s) || strchr("@$%, ",*s)); s++) ;
1410 if (*s == ';' || *s == '=')
1411 warn("Parens missing around \"%s\" list", lex ? "my" : "local");
1418 return mod(o, OP_NULL); /* a bit kludgey */
1425 if (o->op_type == OP_LIST) {
1426 o = convert(OP_JOIN, 0,
1427 prepend_elem(OP_LIST,
1428 newSVREF(newGVOP(OP_GV, 0, gv_fetchpv(";", TRUE, SVt_PV))),
1439 I32 type = o->op_type;
1442 if (opargs[type] & OA_RETSCALAR)
1444 if (opargs[type] & OA_TARGET)
1445 o->op_targ = pad_alloc(type, SVs_PADTMP);
1447 if ((opargs[type] & OA_OTHERINT) && (hints & HINT_INTEGER))
1448 o->op_ppaddr = ppaddr[type = ++(o->op_type)];
1450 if (!(opargs[type] & OA_FOLDCONST))
1454 goto nope; /* Don't try to run w/ errors */
1456 for (curop = LINKLIST(o); curop != o; curop = LINKLIST(curop)) {
1457 if (curop->op_type != OP_CONST &&
1458 curop->op_type != OP_LIST &&
1459 curop->op_type != OP_SCALAR &&
1460 curop->op_type != OP_NULL &&
1461 curop->op_type != OP_PUSHMARK) {
1466 curop = LINKLIST(o);
1471 if (o->op_targ && sv == PAD_SV(o->op_targ)) /* grab pad temp? */
1472 pad_swipe(o->op_targ);
1473 else if (SvTEMP(sv)) { /* grab mortal temp? */
1474 (void)SvREFCNT_inc(sv);
1478 if (type == OP_RV2GV)
1479 return newGVOP(OP_GV, 0, (GV*)sv);
1481 if ((SvFLAGS(sv) & (SVf_IOK|SVf_NOK|SVf_POK)) == SVf_NOK) {
1483 if ((double)iv == SvNV(sv)) { /* can we smush double to int */
1488 SvIOK_off(sv); /* undo SvIV() damage */
1490 return newSVOP(OP_CONST, 0, sv);
1494 if (!(opargs[type] & OA_OTHERINT))
1497 if (!(hints & HINT_INTEGER)) {
1498 if (type == OP_DIVIDE || !(o->op_flags & OPf_KIDS))
1501 for (curop = ((UNOP*)o)->op_first; curop; curop = curop->op_sibling) {
1502 if (curop->op_type == OP_CONST) {
1503 if (SvIOK(((SVOP*)curop)->op_sv))
1507 if (opargs[curop->op_type] & OA_RETINTEGER)
1511 o->op_ppaddr = ppaddr[++(o->op_type)];
1518 gen_constant_list(o)
1522 I32 oldtmps_floor = tmps_floor;
1526 return o; /* Don't attempt to run with errors */
1528 op = curop = LINKLIST(o);
1534 tmps_floor = oldtmps_floor;
1536 o->op_type = OP_RV2AV;
1537 o->op_ppaddr = ppaddr[OP_RV2AV];
1538 curop = ((UNOP*)o)->op_first;
1539 ((UNOP*)o)->op_first = newSVOP(OP_CONST, 0, SvREFCNT_inc(*stack_sp--));
1546 convert(type, flags, op)
1554 if (!op || op->op_type != OP_LIST)
1555 op = newLISTOP(OP_LIST, 0, op, Nullop);
1557 op->op_flags &= ~(OPf_KNOW|OPf_LIST);
1559 if (!(opargs[type] & OA_MARK))
1560 null(cLISTOP->op_first);
1563 op->op_ppaddr = ppaddr[type];
1564 op->op_flags |= flags;
1566 op = CHECKOP(type, op);
1567 if (op->op_type != type)
1570 if (cLISTOP->op_children < 7) {
1571 /* XXX do we really need to do this if we're done appending?? */
1572 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
1574 cLISTOP->op_last = last; /* in case check substituted last arg */
1577 return fold_constants(op);
1580 /* List constructors */
1583 append_elem(type, first, last)
1594 if (first->op_type != type || type==OP_LIST && first->op_flags & OPf_PARENS)
1595 return newLISTOP(type, 0, first, last);
1597 if (first->op_flags & OPf_KIDS)
1598 ((LISTOP*)first)->op_last->op_sibling = last;
1600 first->op_flags |= OPf_KIDS;
1601 ((LISTOP*)first)->op_first = last;
1603 ((LISTOP*)first)->op_last = last;
1604 ((LISTOP*)first)->op_children++;
1609 append_list(type, first, last)
1620 if (first->op_type != type)
1621 return prepend_elem(type, (OP*)first, (OP*)last);
1623 if (last->op_type != type)
1624 return append_elem(type, (OP*)first, (OP*)last);
1626 first->op_last->op_sibling = last->op_first;
1627 first->op_last = last->op_last;
1628 first->op_children += last->op_children;
1629 if (first->op_children)
1630 last->op_flags |= OPf_KIDS;
1637 prepend_elem(type, first, last)
1648 if (last->op_type == type) {
1649 if (type == OP_LIST) { /* already a PUSHMARK there */
1650 first->op_sibling = ((LISTOP*)last)->op_first->op_sibling;
1651 ((LISTOP*)last)->op_first->op_sibling = first;
1654 if (!(last->op_flags & OPf_KIDS)) {
1655 ((LISTOP*)last)->op_last = first;
1656 last->op_flags |= OPf_KIDS;
1658 first->op_sibling = ((LISTOP*)last)->op_first;
1659 ((LISTOP*)last)->op_first = first;
1661 ((LISTOP*)last)->op_children++;
1665 return newLISTOP(type, 0, first, last);
1673 return newOP(OP_STUB, 0);
1680 if (!op || op->op_type != OP_LIST)
1681 op = newLISTOP(OP_LIST, 0, op, Nullop);
1687 newLISTOP(type, flags, first, last)
1695 Newz(1101, listop, 1, LISTOP);
1697 listop->op_type = type;
1698 listop->op_ppaddr = ppaddr[type];
1699 listop->op_children = (first != 0) + (last != 0);
1700 listop->op_flags = flags;
1704 else if (!first && last)
1707 first->op_sibling = last;
1708 listop->op_first = first;
1709 listop->op_last = last;
1710 if (type == OP_LIST) {
1712 pushop = newOP(OP_PUSHMARK, 0);
1713 pushop->op_sibling = first;
1714 listop->op_first = pushop;
1715 listop->op_flags |= OPf_KIDS;
1717 listop->op_last = pushop;
1719 else if (listop->op_children)
1720 listop->op_flags |= OPf_KIDS;
1731 Newz(1101, op, 1, OP);
1733 op->op_ppaddr = ppaddr[type];
1734 op->op_flags = flags;
1737 op->op_private = 0 + (flags >> 8);
1738 if (opargs[type] & OA_RETSCALAR)
1740 if (opargs[type] & OA_TARGET)
1741 op->op_targ = pad_alloc(type, SVs_PADTMP);
1742 return CHECKOP(type, op);
1746 newUNOP(type, flags, first)
1754 first = newOP(OP_STUB, 0);
1755 if (opargs[type] & OA_MARK)
1756 first = force_list(first);
1758 Newz(1101, unop, 1, UNOP);
1759 unop->op_type = type;
1760 unop->op_ppaddr = ppaddr[type];
1761 unop->op_first = first;
1762 unop->op_flags = flags | OPf_KIDS;
1763 unop->op_private = 1 | (flags >> 8);
1765 unop = (UNOP*) CHECKOP(type, unop);
1769 return fold_constants((OP *) unop);
1773 newBINOP(type, flags, first, last)
1780 Newz(1101, binop, 1, BINOP);
1783 first = newOP(OP_NULL, 0);
1785 binop->op_type = type;
1786 binop->op_ppaddr = ppaddr[type];
1787 binop->op_first = first;
1788 binop->op_flags = flags | OPf_KIDS;
1791 binop->op_private = 1 | (flags >> 8);
1794 binop->op_private = 2 | (flags >> 8);
1795 first->op_sibling = last;
1798 binop = (BINOP*)CHECKOP(type, binop);
1802 binop->op_last = last = binop->op_first->op_sibling;
1804 return fold_constants((OP *)binop);
1808 pmtrans(op, expr, repl)
1813 SV *tstr = ((SVOP*)expr)->op_sv;
1814 SV *rstr = ((SVOP*)repl)->op_sv;
1817 register U8 *t = (U8*)SvPV(tstr, tlen);
1818 register U8 *r = (U8*)SvPV(rstr, rlen);
1823 register short *tbl;
1825 tbl = (short*)cPVOP->op_pv;
1826 complement = op->op_private & OPpTRANS_COMPLEMENT;
1827 delete = op->op_private & OPpTRANS_DELETE;
1828 /* squash = op->op_private & OPpTRANS_SQUASH; */
1831 Zero(tbl, 256, short);
1832 for (i = 0; i < tlen; i++)
1834 for (i = 0, j = 0; i < 256; i++) {
1850 if (!rlen && !delete) {
1853 for (i = 0; i < 256; i++)
1855 for (i = 0, j = 0; i < tlen; i++,j++) {
1858 if (tbl[t[i]] == -1)
1864 if (tbl[t[i]] == -1)
1875 newPMOP(type, flags)
1881 Newz(1101, pmop, 1, PMOP);
1882 pmop->op_type = type;
1883 pmop->op_ppaddr = ppaddr[type];
1884 pmop->op_flags = flags;
1885 pmop->op_private = 0 | (flags >> 8);
1887 if (hints & HINT_LOCALE)
1888 pmop->op_pmpermflags = (pmop->op_pmflags |= PMf_LOCALE);
1890 /* link into pm list */
1891 if (type != OP_TRANS && curstash) {
1892 pmop->op_pmnext = HvPMROOT(curstash);
1893 HvPMROOT(curstash) = pmop;
1900 pmruntime(op, expr, repl)
1908 if (op->op_type == OP_TRANS)
1909 return pmtrans(op, expr, repl);
1913 if (expr->op_type == OP_CONST) {
1915 SV *pat = ((SVOP*)expr)->op_sv;
1916 char *p = SvPV(pat, plen);
1917 if ((op->op_flags & OPf_SPECIAL) && strEQ(p, " ")) {
1918 sv_setpvn(pat, "\\s+", 3);
1919 p = SvPV(pat, plen);
1920 pm->op_pmflags |= PMf_SKIPWHITE;
1922 pm->op_pmregexp = pregcomp(p, p + plen, pm);
1923 if (strEQ("\\s+", pm->op_pmregexp->precomp))
1924 pm->op_pmflags |= PMf_WHITE;
1929 if (pm->op_pmflags & PMf_KEEP)
1930 expr = newUNOP(OP_REGCMAYBE,0,expr);
1932 Newz(1101, rcop, 1, LOGOP);
1933 rcop->op_type = OP_REGCOMP;
1934 rcop->op_ppaddr = ppaddr[OP_REGCOMP];
1935 rcop->op_first = scalar(expr);
1936 rcop->op_flags |= OPf_KIDS;
1937 rcop->op_private = 1;
1938 rcop->op_other = op;
1940 /* establish postfix order */
1941 if (pm->op_pmflags & PMf_KEEP) {
1943 rcop->op_next = expr;
1944 ((UNOP*)expr)->op_first->op_next = (OP*)rcop;
1947 rcop->op_next = LINKLIST(expr);
1948 expr->op_next = (OP*)rcop;
1951 prepend_elem(op->op_type, scalar((OP*)rcop), op);
1956 if (pm->op_pmflags & PMf_EVAL)
1958 else if (repl->op_type == OP_CONST)
1962 for (curop = LINKLIST(repl); curop!=repl; curop = LINKLIST(curop)) {
1963 if (opargs[curop->op_type] & OA_DANGEROUS) {
1964 if (curop->op_type == OP_GV) {
1965 GV *gv = ((GVOP*)curop)->op_gv;
1966 if (strchr("&`'123456789+", *GvENAME(gv)))
1969 else if (curop->op_type == OP_RV2CV)
1971 else if (curop->op_type == OP_RV2SV ||
1972 curop->op_type == OP_RV2AV ||
1973 curop->op_type == OP_RV2HV ||
1974 curop->op_type == OP_RV2GV) {
1975 if (lastop && lastop->op_type != OP_GV) /*funny deref?*/
1978 else if (curop->op_type == OP_PADSV ||
1979 curop->op_type == OP_PADAV ||
1980 curop->op_type == OP_PADHV ||
1981 curop->op_type == OP_PADANY) {
1990 if (curop == repl) {
1991 pm->op_pmflags |= PMf_CONST; /* const for long enough */
1992 pm->op_pmpermflags |= PMf_CONST; /* const for long enough */
1993 prepend_elem(op->op_type, scalar(repl), op);
1996 Newz(1101, rcop, 1, LOGOP);
1997 rcop->op_type = OP_SUBSTCONT;
1998 rcop->op_ppaddr = ppaddr[OP_SUBSTCONT];
1999 rcop->op_first = scalar(repl);
2000 rcop->op_flags |= OPf_KIDS;
2001 rcop->op_private = 1;
2002 rcop->op_other = op;
2004 /* establish postfix order */
2005 rcop->op_next = LINKLIST(repl);
2006 repl->op_next = (OP*)rcop;
2008 pm->op_pmreplroot = scalar((OP*)rcop);
2009 pm->op_pmreplstart = LINKLIST(rcop);
2018 newSVOP(type, flags, sv)
2024 Newz(1101, svop, 1, SVOP);
2025 svop->op_type = type;
2026 svop->op_ppaddr = ppaddr[type];
2028 svop->op_next = (OP*)svop;
2029 svop->op_flags = flags;
2030 if (opargs[type] & OA_RETSCALAR)
2032 if (opargs[type] & OA_TARGET)
2033 svop->op_targ = pad_alloc(type, SVs_PADTMP);
2034 return CHECKOP(type, svop);
2038 newGVOP(type, flags, gv)
2044 Newz(1101, gvop, 1, GVOP);
2045 gvop->op_type = type;
2046 gvop->op_ppaddr = ppaddr[type];
2047 gvop->op_gv = (GV*)SvREFCNT_inc(gv);
2048 gvop->op_next = (OP*)gvop;
2049 gvop->op_flags = flags;
2050 if (opargs[type] & OA_RETSCALAR)
2052 if (opargs[type] & OA_TARGET)
2053 gvop->op_targ = pad_alloc(type, SVs_PADTMP);
2054 return CHECKOP(type, gvop);
2058 newPVOP(type, flags, pv)
2064 Newz(1101, pvop, 1, PVOP);
2065 pvop->op_type = type;
2066 pvop->op_ppaddr = ppaddr[type];
2068 pvop->op_next = (OP*)pvop;
2069 pvop->op_flags = flags;
2070 if (opargs[type] & OA_RETSCALAR)
2072 if (opargs[type] & OA_TARGET)
2073 pvop->op_targ = pad_alloc(type, SVs_PADTMP);
2074 return CHECKOP(type, pvop);
2083 save_hptr(&curstash);
2084 save_item(curstname);
2089 name = SvPV(sv, len);
2090 curstash = gv_stashpvn(name,len,TRUE);
2091 sv_setpvn(curstname, name, len);
2095 sv_setpv(curstname,"<none>");
2103 utilize(aver, floor, version, id, arg)
2116 if (id->op_type != OP_CONST)
2117 croak("Module name must be constant");
2121 if(version != Nullop) {
2122 SV *vesv = ((SVOP*)version)->op_sv;
2124 if (arg == Nullop && !SvNIOK(vesv)) {
2131 if (version->op_type != OP_CONST || !SvNIOK(vesv))
2132 croak("Version number must be constant number");
2134 /* Make copy of id so we don't free it twice */
2135 pack = newSVOP(OP_CONST, 0, newSVsv(((SVOP*)id)->op_sv));
2137 /* Fake up a method call to VERSION */
2138 meth = newSVOP(OP_CONST, 0, newSVpv("VERSION", 7));
2139 veop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL,
2140 append_elem(OP_LIST,
2141 prepend_elem(OP_LIST, pack, list(version)),
2142 newUNOP(OP_METHOD, 0, meth)));
2146 /* Fake up an import/unimport */
2147 if (arg && arg->op_type == OP_STUB)
2148 imop = arg; /* no import on explicit () */
2149 else if(SvNIOK(((SVOP*)id)->op_sv)) {
2150 imop = Nullop; /* use 5.0; */
2153 /* Make copy of id so we don't free it twice */
2154 pack = newSVOP(OP_CONST, 0, newSVsv(((SVOP*)id)->op_sv));
2155 meth = newSVOP(OP_CONST, 0,
2157 ? newSVpv("import", 6)
2158 : newSVpv("unimport", 8)
2160 imop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL,
2161 append_elem(OP_LIST,
2162 prepend_elem(OP_LIST, pack, list(arg)),
2163 newUNOP(OP_METHOD, 0, meth)));
2166 /* Fake up a require */
2167 rqop = newUNOP(OP_REQUIRE, 0, id);
2169 /* Fake up the BEGIN {}, which does its thing immediately. */
2171 newSVOP(OP_CONST, 0, newSVpv("BEGIN", 5)),
2173 append_elem(OP_LINESEQ,
2174 append_elem(OP_LINESEQ,
2175 newSTATEOP(0, Nullch, rqop),
2176 newSTATEOP(0, Nullch, veop)),
2177 newSTATEOP(0, Nullch, imop) ));
2184 newSLICEOP(flags, subscript, listval)
2189 return newBINOP(OP_LSLICE, flags,
2190 list(force_list(subscript)),
2191 list(force_list(listval)) );
2201 if (op->op_type == OP_NULL && op->op_flags & OPf_KIDS)
2202 op = cUNOP->op_first;
2204 if (op->op_type == OP_COND_EXPR) {
2205 I32 t = list_assignment(cCONDOP->op_first->op_sibling);
2206 I32 f = list_assignment(cCONDOP->op_first->op_sibling->op_sibling);
2211 yyerror("Assignment to both a list and a scalar");
2215 if (op->op_type == OP_LIST || op->op_flags & OPf_PARENS ||
2216 op->op_type == OP_RV2AV || op->op_type == OP_RV2HV ||
2217 op->op_type == OP_ASLICE || op->op_type == OP_HSLICE)
2220 if (op->op_type == OP_PADAV || op->op_type == OP_PADHV)
2223 if (op->op_type == OP_RV2SV)
2230 newASSIGNOP(flags, left, optype, right)
2239 if (optype == OP_ANDASSIGN || optype == OP_ORASSIGN) {
2240 return newLOGOP(optype, 0,
2241 mod(scalar(left), optype),
2242 newUNOP(OP_SASSIGN, 0, scalar(right)));
2245 return newBINOP(optype, OPf_STACKED,
2246 mod(scalar(left), optype), scalar(right));
2250 if (list_assignment(left)) {
2252 eval_start = right; /* Grandfathering $[ assignment here. Bletch.*/
2253 left = mod(left, OP_AASSIGN);
2261 op = newBINOP(OP_AASSIGN, flags,
2262 list(force_list(right)),
2263 list(force_list(left)) );
2264 op->op_private = 0 | (flags >> 8);
2265 if (!(left->op_private & OPpLVAL_INTRO)) {
2266 static int generation = 100;
2270 for (curop = LINKLIST(op); curop != op; curop = LINKLIST(curop)) {
2271 if (opargs[curop->op_type] & OA_DANGEROUS) {
2272 if (curop->op_type == OP_GV) {
2273 GV *gv = ((GVOP*)curop)->op_gv;
2274 if (gv == defgv || SvCUR(gv) == generation)
2276 SvCUR(gv) = generation;
2278 else if (curop->op_type == OP_PADSV ||
2279 curop->op_type == OP_PADAV ||
2280 curop->op_type == OP_PADHV ||
2281 curop->op_type == OP_PADANY) {
2282 SV **svp = AvARRAY(comppad_name);
2283 SV *sv = svp[curop->op_targ];
2284 if (SvCUR(sv) == generation)
2286 SvCUR(sv) = generation; /* (SvCUR not used any more) */
2288 else if (curop->op_type == OP_RV2CV)
2290 else if (curop->op_type == OP_RV2SV ||
2291 curop->op_type == OP_RV2AV ||
2292 curop->op_type == OP_RV2HV ||
2293 curop->op_type == OP_RV2GV) {
2294 if (lastop->op_type != OP_GV) /* funny deref? */
2303 op->op_private = OPpASSIGN_COMMON;
2305 if (right && right->op_type == OP_SPLIT) {
2307 if ((tmpop = ((LISTOP*)right)->op_first) &&
2308 tmpop->op_type == OP_PUSHRE)
2310 PMOP *pm = (PMOP*)tmpop;
2311 if (left->op_type == OP_RV2AV &&
2312 !(left->op_private & OPpLVAL_INTRO) &&
2313 !(op->op_private & OPpASSIGN_COMMON) )
2315 tmpop = ((UNOP*)left)->op_first;
2316 if (tmpop->op_type == OP_GV && !pm->op_pmreplroot) {
2317 pm->op_pmreplroot = (OP*)((GVOP*)tmpop)->op_gv;
2318 pm->op_pmflags |= PMf_ONCE;
2319 tmpop = ((UNOP*)op)->op_first; /* to list (nulled) */
2320 tmpop = ((UNOP*)tmpop)->op_first; /* to pushmark */
2321 tmpop->op_sibling = Nullop; /* don't free split */
2322 right->op_next = tmpop->op_next; /* fix starting loc */
2323 op_free(op); /* blow off assign */
2324 right->op_flags &= ~(OPf_KNOW|OPf_LIST);
2325 /* "I don't know and I don't care." */
2330 if (modcount < 10000 &&
2331 ((LISTOP*)right)->op_last->op_type == OP_CONST)
2333 SV *sv = ((SVOP*)((LISTOP*)right)->op_last)->op_sv;
2335 sv_setiv(sv, modcount+1);
2343 right = newOP(OP_UNDEF, 0);
2344 if (right->op_type == OP_READLINE) {
2345 right->op_flags |= OPf_STACKED;
2346 return newBINOP(OP_NULL, flags, mod(scalar(left), OP_SASSIGN), scalar(right));
2349 eval_start = right; /* Grandfathering $[ assignment here. Bletch.*/
2350 op = newBINOP(OP_SASSIGN, flags,
2351 scalar(right), mod(scalar(left), OP_SASSIGN) );
2363 newSTATEOP(flags, label, op)
2368 U32 seq = intro_my();
2371 Newz(1101, cop, 1, COP);
2372 if (perldb && curcop->cop_line && curstash != debstash) {
2373 cop->op_type = OP_DBSTATE;
2374 cop->op_ppaddr = ppaddr[ OP_DBSTATE ];
2377 cop->op_type = OP_NEXTSTATE;
2378 cop->op_ppaddr = ppaddr[ OP_NEXTSTATE ];
2380 cop->op_flags = flags;
2381 cop->op_private = 0 | (flags >> 8);
2383 cop->op_private |= NATIVE_HINTS;
2385 cop->op_next = (OP*)cop;
2388 cop->cop_label = label;
2389 hints |= HINT_BLOCK_SCOPE;
2392 cop->cop_arybase = curcop->cop_arybase;
2394 if (copline == NOLINE)
2395 cop->cop_line = curcop->cop_line;
2397 cop->cop_line = copline;
2400 cop->cop_filegv = (GV*)SvREFCNT_inc(curcop->cop_filegv);
2401 cop->cop_stash = curstash;
2403 if (perldb && curstash != debstash) {
2404 SV **svp = av_fetch(GvAV(curcop->cop_filegv),(I32)cop->cop_line, FALSE);
2405 if (svp && *svp != &sv_undef && !SvIOK(*svp)) {
2406 (void)SvIOK_on(*svp);
2408 SvSTASH(*svp) = (HV*)cop;
2412 return prepend_elem(OP_LINESEQ, (OP*)cop, op);
2415 /* "Introduce" my variables to visible status. */
2423 if (! min_intro_pending)
2426 svp = AvARRAY(comppad_name);
2427 for (i = min_intro_pending; i <= max_intro_pending; i++) {
2428 if ((sv = svp[i]) && sv != &sv_undef && !SvIVX(sv)) {
2429 SvIVX(sv) = 999999999; /* Don't know scope end yet. */
2430 SvNVX(sv) = (double)cop_seqmax;
2433 min_intro_pending = 0;
2434 comppad_name_fill = max_intro_pending; /* Needn't search higher */
2435 return cop_seqmax++;
2439 newLOGOP(type, flags, first, other)
2448 if (type == OP_XOR) /* Not short circuit, but here by precedence. */
2449 return newBINOP(type, flags, scalar(first), scalar(other));
2451 scalarboolean(first);
2452 /* optimize "!a && b" to "a || b", and "!a || b" to "a && b" */
2453 if (first->op_type == OP_NOT && (first->op_flags & OPf_SPECIAL)) {
2454 if (type == OP_AND || type == OP_OR) {
2460 first = cUNOP->op_first;
2462 first->op_next = op->op_next;
2463 cUNOP->op_first = Nullop;
2467 if (first->op_type == OP_CONST) {
2468 if (dowarn && (first->op_private & OPpCONST_BARE))
2469 warn("Probable precedence problem on %s", op_desc[type]);
2470 if ((type == OP_AND) == (SvTRUE(((SVOP*)first)->op_sv))) {
2479 else if (first->op_type == OP_WANTARRAY) {
2485 else if (dowarn && (first->op_flags & OPf_KIDS)) {
2486 OP *k1 = ((UNOP*)first)->op_first;
2487 OP *k2 = k1->op_sibling;
2489 switch (first->op_type)
2492 if (k2 && k2->op_type == OP_READLINE
2493 && (k2->op_flags & OPf_STACKED)
2494 && (k1->op_type == OP_RV2SV || k1->op_type == OP_PADSV))
2495 warnop = k2->op_type;
2499 if (k1->op_type == OP_READDIR || k1->op_type == OP_GLOB)
2500 warnop = k1->op_type;
2504 line_t oldline = curcop->cop_line;
2505 curcop->cop_line = copline;
2506 warn("Value of %s construct can be \"0\"; test with defined()",
2508 curcop->cop_line = oldline;
2515 if (type == OP_ANDASSIGN || type == OP_ORASSIGN)
2516 other->op_private |= OPpASSIGN_BACKWARDS; /* other is an OP_SASSIGN */
2518 Newz(1101, logop, 1, LOGOP);
2520 logop->op_type = type;
2521 logop->op_ppaddr = ppaddr[type];
2522 logop->op_first = first;
2523 logop->op_flags = flags | OPf_KIDS;
2524 logop->op_other = LINKLIST(other);
2525 logop->op_private = 1 | (flags >> 8);
2527 /* establish postfix order */
2528 logop->op_next = LINKLIST(first);
2529 first->op_next = (OP*)logop;
2530 first->op_sibling = other;
2532 op = newUNOP(OP_NULL, 0, (OP*)logop);
2533 other->op_next = op;
2539 newCONDOP(flags, first, trueop, falseop)
2549 return newLOGOP(OP_AND, 0, first, trueop);
2551 return newLOGOP(OP_OR, 0, first, falseop);
2553 scalarboolean(first);
2554 if (first->op_type == OP_CONST) {
2555 if (SvTRUE(((SVOP*)first)->op_sv)) {
2566 else if (first->op_type == OP_WANTARRAY) {
2570 Newz(1101, condop, 1, CONDOP);
2572 condop->op_type = OP_COND_EXPR;
2573 condop->op_ppaddr = ppaddr[OP_COND_EXPR];
2574 condop->op_first = first;
2575 condop->op_flags = flags | OPf_KIDS;
2576 condop->op_true = LINKLIST(trueop);
2577 condop->op_false = LINKLIST(falseop);
2578 condop->op_private = 1 | (flags >> 8);
2580 /* establish postfix order */
2581 condop->op_next = LINKLIST(first);
2582 first->op_next = (OP*)condop;
2584 first->op_sibling = trueop;
2585 trueop->op_sibling = falseop;
2586 op = newUNOP(OP_NULL, 0, (OP*)condop);
2588 trueop->op_next = op;
2589 falseop->op_next = op;
2595 newRANGE(flags, left, right)
2605 Newz(1101, condop, 1, CONDOP);
2607 condop->op_type = OP_RANGE;
2608 condop->op_ppaddr = ppaddr[OP_RANGE];
2609 condop->op_first = left;
2610 condop->op_flags = OPf_KIDS;
2611 condop->op_true = LINKLIST(left);
2612 condop->op_false = LINKLIST(right);
2613 condop->op_private = 1 | (flags >> 8);
2615 left->op_sibling = right;
2617 condop->op_next = (OP*)condop;
2618 flip = newUNOP(OP_FLIP, flags, (OP*)condop);
2619 flop = newUNOP(OP_FLOP, 0, flip);
2620 op = newUNOP(OP_NULL, 0, flop);
2623 left->op_next = flip;
2624 right->op_next = flop;
2626 condop->op_targ = pad_alloc(OP_RANGE, SVs_PADMY);
2627 sv_upgrade(PAD_SV(condop->op_targ), SVt_PVNV);
2628 flip->op_targ = pad_alloc(OP_RANGE, SVs_PADMY);
2629 sv_upgrade(PAD_SV(flip->op_targ), SVt_PVNV);
2631 flip->op_private = left->op_type == OP_CONST ? OPpFLIP_LINENUM : 0;
2632 flop->op_private = right->op_type == OP_CONST ? OPpFLIP_LINENUM : 0;
2635 if (!flip->op_private || !flop->op_private)
2636 linklist(op); /* blow off optimizer unless constant */
2642 newLOOPOP(flags, debuggable, expr, block)
2650 int once = block && block->op_flags & OPf_SPECIAL &&
2651 (block->op_type == OP_ENTERSUB || block->op_type == OP_NULL);
2654 if (once && expr->op_type == OP_CONST && !SvTRUE(((SVOP*)expr)->op_sv))
2655 return block; /* do {} while 0 does once */
2656 if (expr->op_type == OP_READLINE || expr->op_type == OP_GLOB) {
2657 expr = newUNOP(OP_DEFINED, 0,
2658 newASSIGNOP(0, newSVREF(newGVOP(OP_GV, 0, defgv)), 0, expr) );
2662 listop = append_elem(OP_LINESEQ, block, newOP(OP_UNSTACK, 0));
2663 op = newLOGOP(OP_AND, 0, expr, listop);
2665 ((LISTOP*)listop)->op_last->op_next = LINKLIST(op);
2667 if (once && op != listop)
2668 op->op_next = ((LOGOP*)cUNOP->op_first)->op_other;
2671 op = newUNOP(OP_NULL, 0, op); /* or do {} while 1 loses outer block */
2673 op->op_flags |= flags;
2675 op->op_flags |= OPf_SPECIAL; /* suppress POPBLOCK curpm restoration*/
2680 newWHILEOP(flags, debuggable, loop, expr, block, cont)
2694 if (expr && (expr->op_type == OP_READLINE || expr->op_type == OP_GLOB)) {
2695 expr = newUNOP(OP_DEFINED, 0,
2696 newASSIGNOP(0, newSVREF(newGVOP(OP_GV, 0, defgv)), 0, expr) );
2700 block = newOP(OP_NULL, 0);
2703 next = LINKLIST(cont);
2705 cont = append_elem(OP_LINESEQ, cont, newOP(OP_UNSTACK, 0));
2707 listop = append_list(OP_LINESEQ, (LISTOP*)block, (LISTOP*)cont);
2708 redo = LINKLIST(listop);
2711 op = newLOGOP(OP_AND, 0, expr, scalar(listop));
2712 if (op == expr && op->op_type == OP_CONST && !SvTRUE(cSVOP->op_sv)) {
2713 op_free(expr); /* oops, it's a while (0) */
2715 return Nullop; /* (listop already freed by newLOGOP) */
2717 ((LISTOP*)listop)->op_last->op_next = condop =
2718 (op == listop ? redo : LINKLIST(op));
2726 Newz(1101,loop,1,LOOP);
2727 loop->op_type = OP_ENTERLOOP;
2728 loop->op_ppaddr = ppaddr[OP_ENTERLOOP];
2729 loop->op_private = 0;
2730 loop->op_next = (OP*)loop;
2733 op = newBINOP(OP_LEAVELOOP, 0, (OP*)loop, op);
2735 loop->op_redoop = redo;
2736 loop->op_lastop = op;
2739 loop->op_nextop = next;
2741 loop->op_nextop = op;
2743 op->op_flags |= flags;
2744 op->op_private |= (flags >> 8);
2749 #ifndef CAN_PROTOTYPE
2750 newFOROP(flags,label,forline,sv,expr,block,cont)
2759 newFOROP(I32 flags,char *label,line_t forline,OP *sv,OP *expr,OP *block,OP *cont)
2760 #endif /* CAN_PROTOTYPE */
2768 if (sv->op_type == OP_RV2SV) { /* symbol table variable */
2769 sv->op_type = OP_RV2GV;
2770 sv->op_ppaddr = ppaddr[OP_RV2GV];
2772 else if (sv->op_type == OP_PADSV) { /* private variable */
2773 padoff = sv->op_targ;
2778 croak("Can't use %s for loop variable", op_desc[sv->op_type]);
2781 sv = newGVOP(OP_GV, 0, defgv);
2783 if (expr->op_type == OP_RV2AV || expr->op_type == OP_PADAV) {
2784 expr = scalar(ref(expr, OP_ITER));
2785 iterflags |= OPf_STACKED;
2787 loop = (LOOP*)list(convert(OP_ENTERITER, iterflags,
2788 append_elem(OP_LIST, mod(force_list(expr), OP_GREPSTART),
2790 assert(!loop->op_next);
2791 Renew(loop, 1, LOOP);
2792 loop->op_targ = padoff;
2793 return newSTATEOP(0, label, newWHILEOP(flags, 1, loop,
2794 newOP(OP_ITER, 0), block, cont));
2798 newLOOPEX(type, label)
2803 if (type != OP_GOTO || label->op_type == OP_CONST) {
2804 op = newPVOP(type, 0, savepv(
2805 label->op_type == OP_CONST
2806 ? SvPVx(((SVOP*)label)->op_sv, na)
2811 if (label->op_type == OP_ENTERSUB)
2812 label = newUNOP(OP_REFGEN, 0, mod(label, OP_REFGEN));
2813 op = newUNOP(type, OPf_STACKED, label);
2815 hints |= HINT_BLOCK_SCOPE;
2823 if (!CvXSUB(cv) && CvROOT(cv)) {
2825 croak("Can't undef active subroutine");
2832 op_free(CvROOT(cv));
2833 CvROOT(cv) = Nullop;
2837 SvREFCNT_dec(CvGV(cv));
2839 SvREFCNT_dec(CvOUTSIDE(cv));
2840 CvOUTSIDE(cv) = Nullcv;
2841 if (CvPADLIST(cv)) {
2842 /* may be during global destruction */
2843 if (SvREFCNT(CvPADLIST(cv))) {
2844 I32 i = AvFILL(CvPADLIST(cv));
2846 SV** svp = av_fetch(CvPADLIST(cv), i--, FALSE);
2850 SvREFCNT_dec((SV*)CvPADLIST(cv));
2852 CvPADLIST(cv) = Nullav;
2856 #ifdef DEBUG_CLOSURES
2861 CV *outside = CvOUTSIDE(cv);
2862 AV* padlist = CvPADLIST(cv);
2869 PerlIO_printf(Perl_debug_log, "\tCV=0x%p (%s), OUTSIDE=0x%p (%s)\n",
2871 (CvANON(cv) ? "ANON"
2872 : (cv == main_cv) ? "MAIN"
2873 : CvUNIQUE(outside) ? "UNIQUE"
2874 : CvGV(cv) ? GvNAME(CvGV(cv)) : "UNDEFINED"),
2877 : CvANON(outside) ? "ANON"
2878 : (outside == main_cv) ? "MAIN"
2879 : CvUNIQUE(outside) ? "UNIQUE"
2880 : CvGV(outside) ? GvNAME(CvGV(outside)) : "UNDEFINED"));
2885 pad_name = (AV*)*av_fetch(padlist, 0, FALSE);
2886 pad = (AV*)*av_fetch(padlist, 1, FALSE);
2887 pname = AvARRAY(pad_name);
2888 ppad = AvARRAY(pad);
2890 for (ix = 1; ix <= AvFILL(pad_name); ix++) {
2891 if (SvPOK(pname[ix]))
2892 PerlIO_printf(Perl_debug_log, "\t%4d. 0x%p (%s\"%s\" %ld-%ld)\n",
2894 SvFAKE(pname[ix]) ? "FAKE " : "",
2896 (long)I_32(SvNVX(pname[ix])),
2897 (long)SvIVX(pname[ix]));
2900 #endif /* DEBUG_CLOSURES */
2903 cv_clone2(proto, outside)
2909 AV* protopadlist = CvPADLIST(proto);
2910 AV* protopad_name = (AV*)*av_fetch(protopadlist, 0, FALSE);
2911 AV* protopad = (AV*)*av_fetch(protopadlist, 1, FALSE);
2912 SV** pname = AvARRAY(protopad_name);
2913 SV** ppad = AvARRAY(protopad);
2914 I32 fname = AvFILL(protopad_name);
2915 I32 fpad = AvFILL(protopad);
2919 assert(!CvUNIQUE(proto));
2926 cv = compcv = (CV*)NEWSV(1104,0);
2927 sv_upgrade((SV *)cv, SvTYPE(proto));
2932 CvFILEGV(cv) = CvFILEGV(proto);
2933 CvGV(cv) = (GV*)SvREFCNT_inc(CvGV(proto));
2934 CvSTASH(cv) = CvSTASH(proto);
2935 CvROOT(cv) = CvROOT(proto);
2936 CvSTART(cv) = CvSTART(proto);
2938 CvOUTSIDE(cv) = (CV*)SvREFCNT_inc(outside);
2942 comppadlist = newAV();
2943 AvREAL_off(comppadlist);
2944 av_store(comppadlist, 0, SvREFCNT_inc((SV*)protopad_name));
2945 av_store(comppadlist, 1, (SV*)comppad);
2946 CvPADLIST(cv) = comppadlist;
2947 av_fill(comppad, AvFILL(protopad));
2948 curpad = AvARRAY(comppad);
2950 av = newAV(); /* will be @_ */
2952 av_store(comppad, 0, (SV*)av);
2953 AvFLAGS(av) = AVf_REIFY;
2955 for (ix = fpad; ix > 0; ix--) {
2956 SV* namesv = (ix <= fname) ? pname[ix] : Nullsv;
2957 if (namesv && namesv != &sv_undef) {
2958 char *name = SvPVX(namesv); /* XXX */
2959 if (SvFLAGS(namesv) & SVf_FAKE) { /* lexical from outside? */
2960 I32 off = pad_findlex(name, ix, SvIVX(namesv),
2961 CvOUTSIDE(cv), cxstack_ix);
2963 curpad[ix] = SvREFCNT_inc(ppad[ix]);
2965 croak("panic: cv_clone: %s", name);
2967 else { /* our own lexical */
2970 /* anon code -- we'll come back for it */
2971 sv = SvREFCNT_inc(ppad[ix]);
2973 else if (*name == '@')
2975 else if (*name == '%')
2985 SV* sv = NEWSV(0,0);
2991 /* Now that vars are all in place, clone nested closures. */
2993 for (ix = fpad; ix > 0; ix--) {
2994 SV* namesv = (ix <= fname) ? pname[ix] : Nullsv;
2996 && namesv != &sv_undef
2997 && !(SvFLAGS(namesv) & SVf_FAKE)
2998 && *SvPVX(namesv) == '&'
2999 && CvCLONE(ppad[ix]))
3001 CV *kid = cv_clone2((CV*)ppad[ix], cv);
3002 SvREFCNT_dec(ppad[ix]);
3005 curpad[ix] = (SV*)kid;
3009 #ifdef DEBUG_CLOSURES
3010 PerlIO_printf(Perl_debug_log, "Cloned inside:\n");
3012 PerlIO_printf(Perl_debug_log, " from:\n");
3014 PerlIO_printf(Perl_debug_log, " to:\n");
3026 return cv_clone2(proto, CvOUTSIDE(proto));
3036 if(cv && SvPOK(cv) && !SvCUR(cv)) {
3037 for (o = CvSTART(cv); o; o = o->op_next) {
3038 OPCODE type = o->op_type;
3040 if (type == OP_NEXTSTATE || type == OP_NULL || type == OP_PUSHMARK)
3042 if (type == OP_LEAVESUB || type == OP_RETURN)
3044 if (type != OP_CONST || sv)
3047 sv = ((SVOP*)o)->op_sv;
3054 newSUB(floor,op,proto,block)
3060 char *name = op ? SvPVx(cSVOP->op_sv, na) : Nullch;
3061 GV *gv = gv_fetchpv(name ? name : "__ANON__", GV_ADDMULTI, SVt_PVCV);
3068 if (cv = (name ? GvCV(gv) : Nullcv)) {
3070 /* just a cached method */
3074 else if (CvROOT(cv) || CvXSUB(cv) || GvASSUMECV(gv)) {
3075 /* already defined (or promised) */
3077 SV* const_sv = cv_const_sv(cv);
3078 char *p = proto ? SvPVx(((SVOP*)proto)->op_sv, na) : Nullch;
3080 if((!proto != !SvPOK(cv)) || (p && strNE(SvPV((SV*)cv,na), p))) {
3081 warn("Prototype mismatch: (%s) vs (%s)",
3082 SvPOK(cv) ? SvPV((SV*)cv,na) : "none",
3086 /* just a "sub foo;" when &foo is already defined */
3090 if (const_sv || dowarn) {
3091 line_t oldline = curcop->cop_line;
3092 curcop->cop_line = copline;
3093 warn(const_sv ? "Constant subroutine %s redefined"
3094 : "Subroutine %s redefined",name);
3095 curcop->cop_line = oldline;
3101 if (cv) { /* must reuse cv if autoloaded */
3103 CvFLAGS(cv) = CvFLAGS(compcv);
3104 CvOUTSIDE(cv) = CvOUTSIDE(compcv);
3105 CvOUTSIDE(compcv) = 0;
3106 CvPADLIST(cv) = CvPADLIST(compcv);
3107 CvPADLIST(compcv) = 0;
3108 if (SvREFCNT(compcv) > 1) /* XXX Make closures transit through stub. */
3109 CvOUTSIDE(compcv) = (CV*)SvREFCNT_inc((SV*)cv);
3110 SvREFCNT_dec(compcv);
3120 CvGV(cv) = (GV*)SvREFCNT_inc(gv);
3121 CvFILEGV(cv) = curcop->cop_filegv;
3122 CvSTASH(cv) = curstash;
3125 char *p = SvPVx(((SVOP*)proto)->op_sv, na);
3126 sv_setpv((SV*)cv, p);
3140 av = newAV(); /* Will be @_ */
3142 av_store(comppad, 0, (SV*)av);
3143 AvFLAGS(av) = AVf_REIFY;
3145 for (ix = AvFILL(comppad); ix > 0; ix--) {
3146 if (!SvPADMY(curpad[ix]) && !SvIMMORTAL(curpad[ix]))
3147 SvPADTMP_on(curpad[ix]);
3150 if (AvFILL(comppad_name) < AvFILL(comppad))
3151 av_store(comppad_name, AvFILL(comppad), Nullsv);
3153 CvROOT(cv) = newUNOP(OP_LEAVESUB, 0, scalarseq(block));
3154 CvSTART(cv) = LINKLIST(CvROOT(cv));
3155 CvROOT(cv)->op_next = 0;
3161 if (perldb && curstash != debstash) {
3163 SV *tmpstr = sv_newmortal();
3164 static GV *db_postponed;
3168 sprintf(buf, "%s:%ld",
3169 SvPVX(GvSV(curcop->cop_filegv)), (long)subline);
3170 sv = newSVpv(buf,0);
3172 sprintf(buf,"%ld",(long)curcop->cop_line);
3174 gv_efullname3(tmpstr, gv, Nullch);
3175 hv_store(GvHV(DBsub), SvPVX(tmpstr), SvCUR(tmpstr), sv, 0);
3176 if (!db_postponed) {
3177 db_postponed = gv_fetchpv("DB::postponed", GV_ADDMULTI, SVt_PVHV);
3179 hv = GvHVn(db_postponed);
3180 if (HvFILL(hv) > 0 && hv_exists(hv, SvPVX(tmpstr), SvCUR(tmpstr))
3181 && (cv = GvCV(db_postponed))) {
3186 perl_call_sv((SV*)cv, G_DISCARD);
3190 if ((s = strrchr(name,':')))
3194 if (strEQ(s, "BEGIN") && !error_count) {
3196 SAVESPTR(compiling.cop_filegv);
3197 SAVEI16(compiling.cop_line);
3204 DEBUG_x( dump_sub(gv) );
3205 av_push(beginav, (SV *)cv);
3209 curcop = &compiling;
3212 else if (strEQ(s, "END") && !error_count) {
3215 av_unshift(endav, 1);
3216 av_store(endav, 0, (SV *)cv);
3229 newXSUB(name, ix, subaddr, filename)
3235 CV* cv = newXS(name, (void(*)())subaddr, filename);
3237 CvXSUBANY(cv).any_i32 = ix;
3243 newXS(name, subaddr, filename)
3245 void (*subaddr) _((CV*));
3248 GV *gv = gv_fetchpv(name ? name : "__ANON__", GV_ADDMULTI, SVt_PVCV);
3251 if (cv = (name ? GvCV(gv) : Nullcv)) {
3253 /* just a cached method */
3257 else if (CvROOT(cv) || CvXSUB(cv) || GvASSUMECV(gv)) {
3258 /* already defined (or promised) */
3260 line_t oldline = curcop->cop_line;
3261 curcop->cop_line = copline;
3262 warn("Subroutine %s redefined",name);
3263 curcop->cop_line = oldline;
3270 if (cv) /* must reuse cv if autoloaded */
3273 cv = (CV*)NEWSV(1105,0);
3274 sv_upgrade((SV *)cv, SVt_PVCV);
3281 CvGV(cv) = (GV*)SvREFCNT_inc(gv);
3282 CvFILEGV(cv) = gv_fetchfile(filename);
3283 CvXSUB(cv) = subaddr;
3286 char *s = strrchr(name,':');
3291 if (strEQ(s, "BEGIN")) {
3294 av_push(beginav, (SV *)cv);
3297 else if (strEQ(s, "END")) {
3300 av_unshift(endav, 1);
3301 av_store(endav, 0, (SV *)cv);
3312 newFORM(floor,op,block)
3323 name = SvPVx(cSVOP->op_sv, na);
3326 gv = gv_fetchpv(name,TRUE, SVt_PVFM);
3328 if (cv = GvFORM(gv)) {
3330 line_t oldline = curcop->cop_line;
3332 curcop->cop_line = copline;
3333 warn("Format %s redefined",name);
3334 curcop->cop_line = oldline;
3340 CvGV(cv) = (GV*)SvREFCNT_inc(gv);
3341 CvFILEGV(cv) = curcop->cop_filegv;
3343 for (ix = AvFILL(comppad); ix > 0; ix--) {
3344 if (!SvPADMY(curpad[ix]) && !SvIMMORTAL(curpad[ix]))
3345 SvPADTMP_on(curpad[ix]);
3348 CvROOT(cv) = newUNOP(OP_LEAVEWRITE, 0, scalarseq(block));
3349 CvSTART(cv) = LINKLIST(CvROOT(cv));
3350 CvROOT(cv)->op_next = 0;
3361 return newUNOP(OP_REFGEN, 0,
3362 mod(list(convert(OP_ANONLIST, 0, op)), OP_REFGEN));
3369 return newUNOP(OP_REFGEN, 0,
3370 mod(list(convert(OP_ANONHASH, 0, op)), OP_REFGEN));
3374 newANONSUB(floor, proto, block)
3379 return newUNOP(OP_REFGEN, 0,
3380 newSVOP(OP_ANONCODE, 0, (SV*)newSUB(floor, 0, proto, block)));
3387 switch (o->op_type) {
3389 o->op_type = OP_PADAV;
3390 o->op_ppaddr = ppaddr[OP_PADAV];
3391 return ref(newUNOP(OP_RV2AV, 0, scalar(o)), OP_RV2AV);
3394 o->op_type = OP_RV2AV;
3395 o->op_ppaddr = ppaddr[OP_RV2AV];
3400 warn("oops: oopsAV");
3410 switch (o->op_type) {
3413 o->op_type = OP_PADHV;
3414 o->op_ppaddr = ppaddr[OP_PADHV];
3415 return ref(newUNOP(OP_RV2HV, 0, scalar(o)), OP_RV2HV);
3419 o->op_type = OP_RV2HV;
3420 o->op_ppaddr = ppaddr[OP_RV2HV];
3425 warn("oops: oopsHV");
3435 if (o->op_type == OP_PADANY) {
3436 o->op_type = OP_PADAV;
3437 o->op_ppaddr = ppaddr[OP_PADAV];
3440 return newUNOP(OP_RV2AV, 0, scalar(o));
3448 if (type == OP_MAPSTART)
3449 return newUNOP(OP_NULL, 0, o);
3450 return ref(newUNOP(OP_RV2GV, OPf_REF, o), type);
3457 if (o->op_type == OP_PADANY) {
3458 o->op_type = OP_PADHV;
3459 o->op_ppaddr = ppaddr[OP_PADHV];
3462 return newUNOP(OP_RV2HV, 0, scalar(o));
3469 croak("NOT IMPL LINE %d",__LINE__);
3479 return newUNOP(OP_RV2CV, flags, scalar(o));
3486 if (o->op_type == OP_PADANY) {
3487 o->op_type = OP_PADSV;
3488 o->op_ppaddr = ppaddr[OP_PADSV];
3491 return newUNOP(OP_RV2SV, 0, scalar(o));
3494 /* Check routines. */
3503 name = NEWSV(1106,0);
3504 sv_upgrade(name, SVt_PVNV);
3505 sv_setpvn(name, "&", 1);
3508 ix = pad_alloc(op->op_type, SVs_PADMY);
3509 av_store(comppad_name, ix, name);
3510 av_store(comppad, ix, cSVOP->op_sv);
3511 SvPADMY_on(cSVOP->op_sv);
3512 cSVOP->op_sv = Nullsv;
3513 cSVOP->op_targ = ix;
3521 op->op_private = hints;
3529 if (cUNOP->op_first->op_type == OP_CONCAT)
3530 op->op_flags |= OPf_STACKED;
3538 if (op->op_flags & OPf_KIDS) {
3541 OPCODE type = op->op_type;
3542 op = modkids(ck_fun(op), type);
3543 kid = cUNOP->op_first;
3544 newop = kUNOP->op_first->op_sibling;
3546 (newop->op_sibling ||
3547 !(opargs[newop->op_type] & OA_RETSCALAR) ||
3548 newop->op_type == OP_PADAV || newop->op_type == OP_PADHV ||
3549 newop->op_type == OP_RV2AV || newop->op_type == OP_RV2HV)) {
3553 op_free(kUNOP->op_first);
3554 kUNOP->op_first = newop;
3556 op->op_ppaddr = ppaddr[++op->op_type];
3566 if (op->op_flags & OPf_KIDS) {
3567 OP *kid = cUNOP->op_first;
3568 if (kid->op_type == OP_HSLICE)
3569 op->op_private |= OPpSLICE;
3570 else if (kid->op_type != OP_HELEM)
3571 croak("%s argument is not a HASH element or slice",
3572 op_desc[op->op_type]);
3582 I32 type = op->op_type;
3584 if (op->op_flags & OPf_KIDS) {
3585 if (cLISTOP->op_first->op_type == OP_STUB) {
3587 op = newUNOP(type, OPf_SPECIAL,
3588 newGVOP(OP_GV, 0, gv_fetchpv("main'ARGV", TRUE, SVt_PVAV)));
3599 hints |= HINT_BLOCK_SCOPE;
3600 if (op->op_flags & OPf_KIDS) {
3601 SVOP *kid = (SVOP*)cUNOP->op_first;
3604 op->op_flags &= ~OPf_KIDS;
3607 else if (kid->op_type == OP_LINESEQ) {
3610 kid->op_next = op->op_next;
3611 cUNOP->op_first = 0;
3614 Newz(1101, enter, 1, LOGOP);
3615 enter->op_type = OP_ENTERTRY;
3616 enter->op_ppaddr = ppaddr[OP_ENTERTRY];
3617 enter->op_private = 0;
3619 /* establish postfix order */
3620 enter->op_next = (OP*)enter;
3622 op = prepend_elem(OP_LINESEQ, (OP*)enter, (OP*)kid);
3623 op->op_type = OP_LEAVETRY;
3624 op->op_ppaddr = ppaddr[OP_LEAVETRY];
3625 enter->op_other = op;
3631 op = newUNOP(OP_ENTEREVAL, 0, newSVREF(newGVOP(OP_GV, 0, defgv)));
3633 op->op_targ = (PADOFFSET)hints;
3642 if (op->op_flags & OPf_STACKED) {
3644 kid = cUNOP->op_first->op_sibling;
3645 if (kid->op_type == OP_RV2GV)
3658 if (op->op_flags & OPf_KIDS) {
3659 OP *kid = cUNOP->op_first;
3660 if (kid->op_type != OP_HELEM)
3661 croak("%s argument is not a HASH element", op_desc[op->op_type]);
3671 o = fold_constants(o);
3672 if (o->op_type == OP_CONST)
3681 SVOP *kid = (SVOP*)cUNOP->op_first;
3683 op->op_private |= (hints & HINT_STRICT_REFS);
3684 if (kid->op_type == OP_CONST) {
3689 name = SvPV(kid->op_sv, na);
3690 if ((hints & HINT_STRICT_REFS) && (kid->op_private & OPpCONST_BARE)) {
3691 char *badthing = Nullch;
3692 switch (op->op_type) {
3694 badthing = "a SCALAR";
3697 badthing = "an ARRAY";
3700 badthing = "a HASH";
3705 "Can't use bareword (\"%s\") as %s ref while \"strict refs\" in use",
3708 kid->op_type = OP_GV;
3709 iscv = (op->op_type == OP_RV2CV) * 2;
3710 for (gv = 0; !gv; iscv++) {
3712 * This is a little tricky. We only want to add the symbol if we
3713 * didn't add it in the lexer. Otherwise we get duplicate strict
3714 * warnings. But if we didn't add it in the lexer, we must at
3715 * least pretend like we wanted to add it even if it existed before,
3716 * or we get possible typo warnings. OPpCONST_ENTERED says
3717 * whether the lexer already added THIS instance of this symbol.
3719 gv = gv_fetchpv(name,
3720 iscv | !(kid->op_private & OPpCONST_ENTERED),
3723 : op->op_type == OP_RV2SV
3725 : op->op_type == OP_RV2AV
3727 : op->op_type == OP_RV2HV
3731 SvREFCNT_dec(kid->op_sv);
3732 kid->op_sv = SvREFCNT_inc(gv);
3741 I32 type = op->op_type;
3743 if (op->op_flags & OPf_REF)
3746 if (op->op_flags & OPf_KIDS) {
3747 SVOP *kid = (SVOP*)cUNOP->op_first;
3749 if (kid->op_type == OP_CONST && (kid->op_private & OPpCONST_BARE)) {
3750 OP *newop = newGVOP(type, OPf_REF,
3751 gv_fetchpv(SvPVx(kid->op_sv, na), TRUE, SVt_PVIO));
3758 if (type == OP_FTTTY)
3759 return newGVOP(type, OPf_REF, gv_fetchpv("main'STDIN", TRUE,
3762 return newUNOP(type, 0, newSVREF(newGVOP(OP_GV, 0, defgv)));
3775 int type = op->op_type;
3776 register I32 oa = opargs[type] >> OASHIFT;
3778 if (op->op_flags & OPf_STACKED) {
3779 if ((oa & OA_OPTIONAL) && (oa >> 4) && !((oa >> 4) & OA_OPTIONAL))
3782 return no_fh_allowed(op);
3785 if (op->op_flags & OPf_KIDS) {
3786 tokid = &cLISTOP->op_first;
3787 kid = cLISTOP->op_first;
3788 if (kid->op_type == OP_PUSHMARK ||
3789 kid->op_type == OP_NULL && kid->op_targ == OP_PUSHMARK)
3791 tokid = &kid->op_sibling;
3792 kid = kid->op_sibling;
3794 if (!kid && opargs[type] & OA_DEFGV)
3795 *tokid = kid = newSVREF(newGVOP(OP_GV, 0, defgv));
3799 sibl = kid->op_sibling;
3813 if (kid->op_type == OP_CONST &&
3814 (kid->op_private & OPpCONST_BARE)) {
3815 char *name = SvPVx(((SVOP*)kid)->op_sv, na);
3816 OP *newop = newAVREF(newGVOP(OP_GV, 0,
3817 gv_fetchpv(name, TRUE, SVt_PVAV) ));
3819 warn("Array @%s missing the @ in argument %ld of %s()",
3820 name, (long)numargs, op_desc[type]);
3823 kid->op_sibling = sibl;
3826 else if (kid->op_type != OP_RV2AV && kid->op_type != OP_PADAV)
3827 bad_type(numargs, "array", op_desc[op->op_type], kid);
3831 if (kid->op_type == OP_CONST &&
3832 (kid->op_private & OPpCONST_BARE)) {
3833 char *name = SvPVx(((SVOP*)kid)->op_sv, na);
3834 OP *newop = newHVREF(newGVOP(OP_GV, 0,
3835 gv_fetchpv(name, TRUE, SVt_PVHV) ));
3837 warn("Hash %%%s missing the %% in argument %ld of %s()",
3838 name, (long)numargs, op_desc[type]);
3841 kid->op_sibling = sibl;
3844 else if (kid->op_type != OP_RV2HV && kid->op_type != OP_PADHV)
3845 bad_type(numargs, "hash", op_desc[op->op_type], kid);
3850 OP *newop = newUNOP(OP_NULL, 0, kid);
3851 kid->op_sibling = 0;
3853 newop->op_next = newop;
3855 kid->op_sibling = sibl;
3860 if (kid->op_type != OP_GV) {
3861 if (kid->op_type == OP_CONST &&
3862 (kid->op_private & OPpCONST_BARE)) {
3863 OP *newop = newGVOP(OP_GV, 0,
3864 gv_fetchpv(SvPVx(((SVOP*)kid)->op_sv, na), TRUE,
3870 kid->op_sibling = 0;
3871 kid = newUNOP(OP_RV2GV, 0, scalar(kid));
3873 kid->op_sibling = sibl;
3879 mod(scalar(kid), type);
3883 tokid = &kid->op_sibling;
3884 kid = kid->op_sibling;
3886 op->op_private |= numargs;
3888 return too_many_arguments(op,op_desc[op->op_type]);
3891 else if (opargs[type] & OA_DEFGV) {
3893 return newUNOP(type, 0, newSVREF(newGVOP(OP_GV, 0, defgv)));
3897 while (oa & OA_OPTIONAL)
3899 if (oa && oa != OA_LIST)
3900 return too_few_arguments(op,op_desc[op->op_type]);
3909 GV *gv = gv_fetchpv("glob", FALSE, SVt_PVCV);
3911 if (gv && GvIMPORTED_CV(gv)) {
3912 op->op_type = OP_LIST;
3913 op->op_ppaddr = ppaddr[OP_LIST];
3914 op = newUNOP(OP_ENTERSUB, OPf_STACKED,
3915 append_elem(OP_LIST, op,
3916 scalar(newUNOP(OP_RV2CV, 0,
3917 newGVOP(OP_GV, 0, gv)))));
3920 if ((op->op_flags & OPf_KIDS) && !cLISTOP->op_first->op_sibling)
3921 append_elem(OP_GLOB, op, newSVREF(newGVOP(OP_GV, 0, defgv)));
3922 gv = newGVgen("main");
3924 append_elem(OP_GLOB, op, newGVOP(OP_GV, 0, gv));
3935 OPCODE type = op->op_type == OP_GREPSTART ? OP_GREPWHILE : OP_MAPWHILE;
3937 op->op_ppaddr = ppaddr[OP_GREPSTART];
3938 Newz(1101, gwop, 1, LOGOP);
3940 if (op->op_flags & OPf_STACKED) {
3943 kid = cLISTOP->op_first->op_sibling;
3944 for (k = cLISTOP->op_first->op_sibling->op_next; k; k = k->op_next) {
3947 kid->op_next = (OP*)gwop;
3948 op->op_flags &= ~OPf_STACKED;
3950 kid = cLISTOP->op_first->op_sibling;
3951 if (type == OP_MAPWHILE)
3958 kid = cLISTOP->op_first->op_sibling;
3959 if (kid->op_type != OP_NULL)
3960 croak("panic: ck_grep");
3961 kid = kUNOP->op_first;
3963 gwop->op_type = type;
3964 gwop->op_ppaddr = ppaddr[type];
3965 gwop->op_first = listkids(op);
3966 gwop->op_flags |= OPf_KIDS;
3967 gwop->op_private = 1;
3968 gwop->op_other = LINKLIST(kid);
3969 gwop->op_targ = pad_alloc(type, SVs_PADTMP);
3970 kid->op_next = (OP*)gwop;
3972 kid = cLISTOP->op_first->op_sibling;
3973 if (!kid || !kid->op_sibling)
3974 return too_few_arguments(op,op_desc[op->op_type]);
3975 for (kid = kid->op_sibling; kid; kid = kid->op_sibling)
3976 mod(kid, OP_GREPSTART);
3985 if (op->op_flags & OPf_KIDS) {
3986 OP *kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
3987 if (kid && kid->op_type == OP_CONST)
3988 fbm_compile(((SVOP*)kid)->op_sv);
3997 /* XXX length optimization goes here */
4005 OPCODE type = op->op_type;
4006 return modkids(ck_fun(op), type);
4013 OPCODE type = op->op_type;
4014 return refkids(ck_fun(op), type);
4023 kid = cLISTOP->op_first;
4025 op = force_list(op);
4026 kid = cLISTOP->op_first;
4028 if (kid->op_type == OP_PUSHMARK)
4029 kid = kid->op_sibling;
4030 if (kid && op->op_flags & OPf_STACKED)
4031 kid = kid->op_sibling;
4032 else if (kid && !kid->op_sibling) { /* print HANDLE; */
4033 if (kid->op_type == OP_CONST && kid->op_private & OPpCONST_BARE) {
4034 op->op_flags |= OPf_STACKED; /* make it a filehandle */
4035 kid = newUNOP(OP_RV2GV, OPf_REF, scalar(kid));
4036 cLISTOP->op_first->op_sibling = kid;
4037 cLISTOP->op_last = kid;
4038 kid = kid->op_sibling;
4043 append_elem(op->op_type, op, newSVREF(newGVOP(OP_GV, 0, defgv)) );
4049 if (hints & HINT_LOCALE)
4050 op->op_private |= OPpLOCALE;
4064 if (hints & HINT_LOCALE)
4065 op->op_private |= OPpLOCALE;
4077 if (hints & HINT_LOCALE)
4078 op->op_private |= OPpLOCALE;
4088 cPMOP->op_pmflags |= PMf_RUNTIME;
4089 cPMOP->op_pmpermflags |= PMf_RUNTIME;
4104 if (cBINOP->op_first->op_flags & OPf_PARENS) {
4105 op->op_private |= OPpREPEAT_DOLIST;
4106 cBINOP->op_first = force_list(cBINOP->op_first);
4117 if (op->op_flags & OPf_KIDS) { /* Shall we supply missing .pm? */
4118 SVOP *kid = (SVOP*)cUNOP->op_first;
4120 if (kid->op_type == OP_CONST && (kid->op_private & OPpCONST_BARE)) {
4122 for (s = SvPVX(kid->op_sv); *s; s++) {
4123 if (*s == ':' && s[1] == ':') {
4125 Move(s+2, s+1, strlen(s+2)+1, char);
4126 --SvCUR(kid->op_sv);
4129 sv_catpvn(kid->op_sv, ".pm", 3);
4139 croak("NOT IMPL LINE %d",__LINE__);
4149 if (op->op_flags & OPf_KIDS) {
4150 kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4151 if (kid && kid->op_sibling) {
4152 op->op_type = OP_SSELECT;
4153 op->op_ppaddr = ppaddr[OP_SSELECT];
4155 return fold_constants(op);
4159 kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4160 if (kid && kid->op_type == OP_RV2GV)
4161 kid->op_private &= ~HINT_STRICT_REFS;
4169 I32 type = op->op_type;
4171 if (!(op->op_flags & OPf_KIDS)) {
4173 return newUNOP(type, 0,
4174 scalar(newUNOP(OP_RV2AV, 0,
4175 scalar(newGVOP(OP_GV, 0, subline
4177 : gv_fetchpv("ARGV", TRUE, SVt_PVAV) )))));
4179 return scalar(modkids(ck_fun(op), type));
4188 if (hints & HINT_LOCALE)
4189 op->op_private |= OPpLOCALE;
4192 if (op->op_flags & OPf_STACKED) {
4193 OP *kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4195 kid = kUNOP->op_first; /* get past rv2gv */
4197 if (kid->op_type == OP_SCOPE || kid->op_type == OP_LEAVE) {
4199 if (kid->op_type == OP_SCOPE) {
4203 else if (kid->op_type == OP_LEAVE) {
4204 if (op->op_type == OP_SORT) {
4205 null(kid); /* wipe out leave */
4208 for (k = kLISTOP->op_first->op_next; k; k = k->op_next) {
4209 if (k->op_next == kid)
4214 kid->op_next = 0; /* just disconnect the leave */
4215 k = kLISTOP->op_first;
4219 kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4220 null(kid); /* wipe out rv2gv */
4221 if (op->op_type == OP_SORT)
4225 op->op_flags |= OPf_SPECIAL;
4239 if (op->op_flags & OPf_STACKED)
4240 return no_fh_allowed(op);
4242 kid = cLISTOP->op_first;
4243 if (kid->op_type != OP_NULL)
4244 croak("panic: ck_split");
4245 kid = kid->op_sibling;
4246 op_free(cLISTOP->op_first);
4247 cLISTOP->op_first = kid;
4249 cLISTOP->op_first = kid = newSVOP(OP_CONST, 0, newSVpv(" ", 1));
4250 cLISTOP->op_last = kid; /* There was only one element previously */
4253 if (kid->op_type != OP_MATCH) {
4254 OP *sibl = kid->op_sibling;
4255 kid->op_sibling = 0;
4256 kid = pmruntime( newPMOP(OP_MATCH, OPf_SPECIAL), kid, Nullop);
4257 if (cLISTOP->op_first == cLISTOP->op_last)
4258 cLISTOP->op_last = kid;
4259 cLISTOP->op_first = kid;
4260 kid->op_sibling = sibl;
4263 if (pm->op_pmshort && !(pm->op_pmflags & PMf_ALL)) {
4264 SvREFCNT_dec(pm->op_pmshort); /* can't use substring to optimize */
4268 kid->op_type = OP_PUSHRE;
4269 kid->op_ppaddr = ppaddr[OP_PUSHRE];
4272 if (!kid->op_sibling)
4273 append_elem(OP_SPLIT, op, newSVREF(newGVOP(OP_GV, 0, defgv)) );
4275 kid = kid->op_sibling;
4278 if (!kid->op_sibling)
4279 append_elem(OP_SPLIT, op, newSVOP(OP_CONST, 0, newSViv(0)));
4281 kid = kid->op_sibling;
4284 if (kid->op_sibling)
4285 return too_many_arguments(op,op_desc[op->op_type]);
4294 OP *prev = ((cUNOP->op_first->op_sibling)
4295 ? cUNOP : ((UNOP*)cUNOP->op_first))->op_first;
4296 OP *o = prev->op_sibling;
4303 for (cvop = o; cvop->op_sibling; cvop = cvop->op_sibling) ;
4304 if (cvop->op_type == OP_RV2CV) {
4306 op->op_private |= (cvop->op_private & OPpENTERSUB_AMPER);
4307 null(cvop); /* disable rv2cv */
4308 tmpop = (SVOP*)((UNOP*)cvop)->op_first;
4309 if (tmpop->op_type == OP_GV) {
4310 cv = GvCVu(tmpop->op_sv);
4311 if (cv && SvPOK(cv) && !(op->op_private & OPpENTERSUB_AMPER))
4312 proto = SvPV((SV*)cv,na);
4315 op->op_private |= (hints & HINT_STRICT_REFS);
4316 if (perldb && curstash != debstash)
4317 op->op_private |= OPpENTERSUB_DB;
4322 return too_many_arguments(op, CvNAME(cv));
4340 if (o->op_type != OP_REFGEN && o->op_type != OP_UNDEF)
4341 bad_type(arg, "block", CvNAME(cv), o);
4346 if (o->op_type == OP_RV2GV)
4350 o = newUNOP(OP_RV2GV, 0, kid);
4351 o->op_sibling = kid->op_sibling;
4352 kid->op_sibling = 0;
4353 prev->op_sibling = o;
4361 if (o->op_type != OP_RV2GV)
4362 bad_type(arg, "symbol", CvNAME(cv), o);
4365 if (o->op_type != OP_RV2CV)
4366 bad_type(arg, "sub", CvNAME(cv), o);
4369 if (o->op_type != OP_RV2SV && o->op_type != OP_PADSV)
4370 bad_type(arg, "scalar", CvNAME(cv), o);
4373 if (o->op_type != OP_RV2AV && o->op_type != OP_PADAV)
4374 bad_type(arg, "array", CvNAME(cv), o);
4377 if (o->op_type != OP_RV2HV && o->op_type != OP_PADHV)
4378 bad_type(arg, "hash", CvNAME(cv), o);
4382 o = newUNOP(OP_REFGEN, 0, kid);
4383 o->op_sibling = kid->op_sibling;
4384 kid->op_sibling = 0;
4385 prev->op_sibling = o;
4396 croak("Malformed prototype for %s: %s",
4397 CvNAME(cv),SvPV((SV*)cv,na));
4402 mod(o, OP_ENTERSUB);
4406 if (proto && !optional && *proto == '$')
4407 return too_few_arguments(op, CvNAME(cv));
4415 SvREADONLY_on(cSVOP->op_sv);
4423 if (op->op_flags & OPf_KIDS) {
4424 SVOP *kid = (SVOP*)cUNOP->op_first;
4426 if (kid->op_type == OP_NULL)
4427 kid = (SVOP*)kid->op_sibling;
4429 kid->op_type == OP_CONST && (kid->op_private & OPpCONST_BARE))
4430 op->op_flags |= OPf_SPECIAL;
4435 /* A peephole optimizer. We visit the ops in the order they're to execute. */
4441 register OP* oldop = 0;
4442 if (!o || o->op_seq)
4447 for (; o; o = o->op_next) {
4453 switch (o->op_type) {
4456 curcop = ((COP*)o); /* for warnings */
4457 o->op_seq = op_seqmax++;
4468 if (o->op_next->op_type == OP_STRINGIFY)
4470 o->op_seq = op_seqmax++;
4473 if ((o->op_flags & (OPf_KNOW|OPf_LIST)) != (OPf_KNOW|OPf_LIST)) {
4474 o->op_seq = op_seqmax++;
4475 break; /* Scalar stub must produce undef. List stub is noop */
4479 if (o->op_targ == OP_NEXTSTATE || o->op_targ == OP_DBSTATE)
4480 curcop = ((COP*)op);
4486 if (oldop && o->op_next) {
4487 oldop->op_next = o->op_next;
4490 o->op_seq = op_seqmax++;
4494 if (o->op_next->op_type == OP_RV2SV) {
4495 if (!(o->op_next->op_private & OPpDEREF)) {
4497 o->op_private |= o->op_next->op_private & OPpLVAL_INTRO;
4498 o->op_next = o->op_next->op_next;
4499 o->op_type = OP_GVSV;
4500 o->op_ppaddr = ppaddr[OP_GVSV];
4503 else if (o->op_next->op_type == OP_RV2AV) {
4504 OP* pop = o->op_next->op_next;
4506 if (pop->op_type == OP_CONST &&
4507 (op = pop->op_next) &&
4508 pop->op_next->op_type == OP_AELEM &&
4509 !(pop->op_next->op_private & (OPpDEREF|OPpLVAL_INTRO)) &&
4510 (i = SvIV(((SVOP*)pop)->op_sv) - compiling.cop_arybase)
4514 SvREFCNT_dec(((SVOP*)pop)->op_sv);
4518 o->op_flags |= pop->op_next->op_flags & OPf_MOD;
4519 o->op_next = pop->op_next->op_next;
4520 o->op_type = OP_AELEMFAST;
4521 o->op_ppaddr = ppaddr[OP_AELEMFAST];
4522 o->op_private = (U8)i;
4523 GvAVn(((GVOP*)o)->op_gv);
4526 o->op_seq = op_seqmax++;
4533 o->op_seq = op_seqmax++;
4534 peep(cLOGOP->op_other);
4538 o->op_seq = op_seqmax++;
4539 peep(cCONDOP->op_true);
4540 peep(cCONDOP->op_false);
4544 o->op_seq = op_seqmax++;
4545 peep(cLOOP->op_redoop);
4546 peep(cLOOP->op_nextop);
4547 peep(cLOOP->op_lastop);
4552 o->op_seq = op_seqmax++;
4553 peep(cPMOP->op_pmreplstart);
4557 o->op_seq = op_seqmax++;
4558 if (dowarn && o->op_next && o->op_next->op_type == OP_NEXTSTATE) {
4559 if (o->op_next->op_sibling &&
4560 o->op_next->op_sibling->op_type != OP_DIE) {
4561 line_t oldline = curcop->cop_line;
4563 curcop->cop_line = ((COP*)o->op_next)->cop_line;
4564 warn("Statement unlikely to be reached");
4565 warn("(Maybe you meant system() when you said exec()?)\n");
4566 curcop->cop_line = oldline;
4571 o->op_seq = op_seqmax++;