3 * Copyright (c) 1991-1994, Larry Wall
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
11 * "You see: Mr. Drogo, he married poor Miss Primula Brandybuck. She was
12 * our Mr. Bilbo's first cousin on the mother's side (her mother being the
13 * youngest of the Old Took's daughters); and Mr. Drogo was his second
14 * cousin. So Mr. Frodo is his first *and* second cousin, once removed
15 * either way, as the saying is, if you follow me." --the Gaffer
21 #define USE_OP_MASK /* Turned on by default in 5.002beta1h */
25 * In the following definition, the ", (OP *) op" is just to make the compiler
26 * think the expression is of the right type: croak actually does a Siglongjmp.
28 #define CHECKOP(type,op) \
29 ((op_mask && op_mask[type]) \
30 ? ( op_free((OP*)op), \
31 croak("%s trapped by operation mask", op_desc[type]), \
33 : (*check[type])((OP*)op))
35 #define CHECKOP(type,op) (*check[type])(op)
36 #endif /* USE_OP_MASK */
38 static I32 list_assignment _((OP *op));
39 static OP *bad_type _((I32 n, char *t, char *name, OP *kid));
40 static OP *modkids _((OP *op, I32 type));
41 static OP *no_fh_allowed _((OP *op));
42 static OP *scalarboolean _((OP *op));
43 static OP *too_few_arguments _((OP *op, char* name));
44 static OP *too_many_arguments _((OP *op, char* name));
45 static void null _((OP* op));
46 static PADOFFSET pad_findlex _((char* name, PADOFFSET newoff, U32 seq,
47 CV* startcv, I32 cx_ix));
53 SV* tmpsv = sv_newmortal();
54 gv_efullname3(tmpsv, CvGV(cv), Nullch);
55 return SvPV(tmpsv,na);
62 sprintf(tokenbuf,"Missing comma after first argument to %s function",
63 op_desc[op->op_type]);
69 too_few_arguments(op, name)
73 sprintf(tokenbuf,"Not enough arguments for %s", name);
79 too_many_arguments(op, name)
83 sprintf(tokenbuf,"Too many arguments for %s", name);
89 bad_type(n, t, name, kid)
95 sprintf(tokenbuf, "Type of arg %d to %s must be %s (not %s)",
96 (int) n, name, t, op_desc[kid->op_type]);
105 int type = op->op_type;
106 if (type != OP_AELEM && type != OP_HELEM) {
107 sprintf(tokenbuf, "Can't use subscript on %s", op_desc[type]);
109 if (type == OP_ENTERSUB || type == OP_RV2HV || type == OP_PADHV)
110 warn("(Did you mean $ or @ instead of %c?)\n",
111 type == OP_ENTERSUB ? '&' : '%');
115 /* "register" allocation */
124 if (!(isALPHA(name[1]) || name[1] == '_' && (int)strlen(name) > 2)) {
125 if (!isPRINT(name[1]))
126 sprintf(name+1, "^%c", toCTRL(name[1])); /* XXX tokenbuf, really */
127 croak("Can't use global %s in \"my\"",name);
129 if (AvFILL(comppad_name) >= 0) {
130 SV **svp = AvARRAY(comppad_name);
131 for (off = AvFILL(comppad_name); off > comppad_name_floor; off--) {
134 && SvIVX(sv) == 999999999 /* var is in open scope */
135 && strEQ(name, SvPVX(sv)))
137 warn("\"my\" variable %s masks earlier declaration in same scope", name);
142 off = pad_alloc(OP_PADSV, SVs_PADMY);
144 sv_upgrade(sv, SVt_PVNV);
146 av_store(comppad_name, off, sv);
147 SvNVX(sv) = (double)999999999;
148 SvIVX(sv) = 0; /* Not yet introduced--see newSTATEOP */
149 if (!min_intro_pending)
150 min_intro_pending = off;
151 max_intro_pending = off;
153 av_store(comppad, off, (SV*)newAV());
154 else if (*name == '%')
155 av_store(comppad, off, (SV*)newHV());
156 SvPADMY_on(curpad[off]);
161 #ifndef CAN_PROTOTYPE
162 pad_findlex(name, newoff, seq, startcv, cx_ix)
169 pad_findlex(char *name, PADOFFSET newoff, U32 seq, CV* startcv, I32 cx_ix)
176 register CONTEXT *cx;
179 for (cv = startcv; cv; cv = CvOUTSIDE(cv)) {
180 AV *curlist = CvPADLIST(cv);
181 SV **svp = av_fetch(curlist, 0, FALSE);
184 if (!svp || *svp == &sv_undef)
187 svp = AvARRAY(curname);
188 for (off = AvFILL(curname); off > 0; off--) {
189 if ((sv = svp[off]) &&
193 seq > I_32(SvNVX(sv)) &&
194 strEQ(SvPVX(sv), name))
203 return 0; /* don't clone from inactive stack frame */
206 oldpad = (AV*)*av_fetch(curlist, depth, FALSE);
207 oldsv = *av_fetch(oldpad, off, TRUE);
208 if (!newoff) { /* Not a mere clone operation. */
209 SV *sv = NEWSV(1103,0);
210 newoff = pad_alloc(OP_PADSV, SVs_PADMY);
211 sv_upgrade(sv, SVt_PVNV);
213 av_store(comppad_name, newoff, sv);
214 SvNVX(sv) = (double)curcop->cop_seq;
215 SvIVX(sv) = 999999999; /* A ref, intro immediately */
216 SvFAKE_on(sv); /* A ref, not a real var */
217 if (CvANON(compcv) || SvTYPE(compcv) == SVt_PVFM) {
218 /* "It's closures all the way down." */
223 bcv && bcv != cv && !CvCLONE(bcv);
224 bcv = CvOUTSIDE(bcv)) {
228 if (dowarn && !CvUNIQUE(cv))
230 "Variable \"%s\" may be unavailable",
237 else if (!CvUNIQUE(compcv)) {
238 if (dowarn && !CvUNIQUE(cv))
239 warn("Variable \"%s\" will not stay shared", name);
242 av_store(comppad, newoff, SvREFCNT_inc(oldsv));
248 /* Nothing in current lexical context--try eval's context, if any.
249 * This is necessary to let the perldb get at lexically scoped variables.
250 * XXX This will also probably interact badly with eval tree caching.
254 for (i = cx_ix; i >= 0; i--) {
256 switch (cx->cx_type) {
258 if (i == 0 && saweval) {
259 seq = cxstack[saweval].blk_oldcop->cop_seq;
260 return pad_findlex(name, newoff, seq, main_cv, 0);
264 switch (cx->blk_eval.old_op_type) {
269 /* require must have its own scope */
277 if (debstash && CvSTASH(cv) == debstash) { /* ignore DB'* scope */
278 saweval = i; /* so we know where we were called from */
281 seq = cxstack[saweval].blk_oldcop->cop_seq;
282 return pad_findlex(name, newoff, seq, cv, i-1);
295 SV **svp = AvARRAY(comppad_name);
296 U32 seq = cop_seqmax;
298 /* The one we're looking for is probably just before comppad_name_fill. */
299 for (off = AvFILL(comppad_name); off > 0; off--) {
300 if ((sv = svp[off]) &&
303 seq > I_32(SvNVX(sv)) &&
304 strEQ(SvPVX(sv), name))
306 return (PADOFFSET)off;
310 /* See if it's in a nested scope */
311 off = pad_findlex(name, 0, seq, CvOUTSIDE(compcv), cxstack_ix);
323 SV **svp = AvARRAY(comppad_name);
325 if (min_intro_pending && fill < min_intro_pending) {
326 for (off = max_intro_pending; off >= min_intro_pending; off--) {
327 if ((sv = svp[off]) && sv != &sv_undef)
328 warn("%s never introduced", SvPVX(sv));
331 /* "Deintroduce" my variables that are leaving with this scope. */
332 for (off = AvFILL(comppad_name); off > fill; off--) {
333 if ((sv = svp[off]) && sv != &sv_undef && SvIVX(sv) == 999999999)
334 SvIVX(sv) = cop_seqmax;
339 pad_alloc(optype,tmptype)
346 if (AvARRAY(comppad) != curpad)
347 croak("panic: pad_alloc");
348 if (pad_reset_pending)
350 if (tmptype & SVs_PADMY) {
352 sv = *av_fetch(comppad, AvFILL(comppad) + 1, TRUE);
353 } while (SvPADBUSY(sv)); /* need a fresh one */
354 retval = AvFILL(comppad);
357 SV **names = AvARRAY(comppad_name);
358 SSize_t names_fill = AvFILL(comppad_name);
361 * "foreach" index vars temporarily become aliases to non-"my"
362 * values. Thus we must skip, not just pad values that are
363 * marked as current pad values, but also those with names.
365 if (++padix <= names_fill &&
366 (sv = names[padix]) && sv != &sv_undef)
368 sv = *av_fetch(comppad, padix, TRUE);
369 if (!(SvFLAGS(sv) & (SVs_PADTMP|SVs_PADMY)))
374 SvFLAGS(sv) |= tmptype;
375 curpad = AvARRAY(comppad);
376 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad alloc %ld for %s\n", (long) retval, op_name[optype]));
377 return (PADOFFSET)retval;
381 #ifndef CAN_PROTOTYPE
386 #endif /* CAN_PROTOTYPE */
389 croak("panic: pad_sv po");
390 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad sv %d\n", po));
391 return curpad[po]; /* eventually we'll turn this into a macro */
395 #ifndef CAN_PROTOTYPE
399 pad_free(PADOFFSET po)
400 #endif /* CAN_PROTOTYPE */
404 if (AvARRAY(comppad) != curpad)
405 croak("panic: pad_free curpad");
407 croak("panic: pad_free po");
408 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad free %d\n", po));
409 if (curpad[po] && !SvIMMORTAL(curpad[po]))
410 SvPADTMP_off(curpad[po]);
416 #ifndef CAN_PROTOTYPE
420 pad_swipe(PADOFFSET po)
421 #endif /* CAN_PROTOTYPE */
423 if (AvARRAY(comppad) != curpad)
424 croak("panic: pad_swipe curpad");
426 croak("panic: pad_swipe po");
427 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad swipe %d\n", po));
428 SvPADTMP_off(curpad[po]);
429 curpad[po] = NEWSV(1107,0);
430 SvPADTMP_on(curpad[po]);
440 if (AvARRAY(comppad) != curpad)
441 croak("panic: pad_reset curpad");
442 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad reset\n"));
443 if (!tainting) { /* Can't mix tainted and non-tainted temporaries. */
444 for (po = AvMAX(comppad); po > padix_floor; po--) {
445 if (curpad[po] && !SvIMMORTAL(curpad[po]))
446 SvPADTMP_off(curpad[po]);
450 pad_reset_pending = FALSE;
459 register OP *kid, *nextkid;
461 if (!op || op->op_seq == (U16)-1)
464 if (op->op_flags & OPf_KIDS) {
465 for (kid = cUNOP->op_first; kid; kid = nextkid) {
466 nextkid = kid->op_sibling; /* Get before next freeing kid */
471 switch (op->op_type) {
473 op->op_targ = 0; /* Was holding old type, if any. */
476 op->op_targ = 0; /* Was holding hints. */
479 if (!(op->op_flags & OPf_REF) || (check[op->op_type] != ck_ftst))
485 SvREFCNT_dec(cGVOP->op_gv);
489 Safefree(cCOP->cop_label);
490 SvREFCNT_dec(cCOP->cop_filegv);
493 SvREFCNT_dec(cSVOP->op_sv);
499 if (op->op_flags & (OPf_SPECIAL|OPf_STACKED|OPf_KIDS))
503 Safefree(cPVOP->op_pv);
506 op_free(cPMOP->op_pmreplroot);
510 pregfree(cPMOP->op_pmregexp);
511 SvREFCNT_dec(cPMOP->op_pmshort);
516 pad_free(op->op_targ);
525 if (op->op_type != OP_NULL && op->op_targ > 0)
526 pad_free(op->op_targ);
527 op->op_targ = op->op_type;
528 op->op_type = OP_NULL;
529 op->op_ppaddr = ppaddr[OP_NULL];
532 /* Contextualizers */
534 #define LINKLIST(o) ((o)->op_next ? (o)->op_next : linklist((OP*)o))
545 /* establish postfix order */
546 if (cUNOP->op_first) {
547 op->op_next = LINKLIST(cUNOP->op_first);
548 for (kid = cUNOP->op_first; kid; kid = kid->op_sibling) {
550 kid->op_next = LINKLIST(kid->op_sibling);
566 if (op && op->op_flags & OPf_KIDS) {
567 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
578 op->op_type == OP_SASSIGN && cBINOP->op_first->op_type == OP_CONST) {
579 line_t oldline = curcop->cop_line;
581 if (copline != NOLINE)
582 curcop->cop_line = copline;
583 warn("Found = in conditional, should be ==");
584 curcop->cop_line = oldline;
595 /* assumes no premature commitment */
596 if (!op || (op->op_flags & OPf_KNOW) || op->op_type == OP_RETURN
600 op->op_flags &= ~OPf_LIST;
601 op->op_flags |= OPf_KNOW;
603 switch (op->op_type) {
605 if (op->op_private & OPpREPEAT_DOLIST)
606 null(((LISTOP*)cBINOP->op_first)->op_first);
607 scalar(cBINOP->op_first);
612 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
616 if ((kid = ((LISTOP*)op)->op_first) && kid->op_type == OP_PUSHRE) {
617 if (!kPMOP->op_pmreplroot)
618 deprecate("implicit split to @_");
625 if (op->op_flags & OPf_KIDS) {
626 for (kid = cUNOP->op_first; kid; kid = kid->op_sibling)
632 scalar(cLISTOP->op_first);
637 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling) {
657 if (!op || error_count)
659 if (op->op_flags & OPf_LIST)
662 op->op_flags |= OPf_KNOW;
664 switch (op->op_type) {
666 if (!(opargs[op->op_type] & OA_FOLDCONST))
670 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 @_");
821 op->op_private |= OPpLEAVE_VOID;
824 if (useless && dowarn)
825 warn("Useless use of %s in void context", useless);
834 if (op && op->op_flags & OPf_KIDS) {
835 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
847 /* assumes no premature commitment */
848 if (!op || (op->op_flags & OPf_KNOW) || op->op_type == OP_RETURN
852 op->op_flags |= (OPf_KNOW | OPf_LIST);
854 switch (op->op_type) {
857 list(cBINOP->op_first);
862 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
869 if (!(op->op_flags & OPf_KIDS))
871 if (!op->op_next && cUNOP->op_first->op_type == OP_FLOP) {
872 list(cBINOP->op_first);
873 return gen_constant_list(op);
880 list(cLISTOP->op_first);
884 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling) {
903 if (op->op_type == OP_LINESEQ ||
904 op->op_type == OP_SCOPE ||
905 op->op_type == OP_LEAVE ||
906 op->op_type == OP_LEAVETRY)
908 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling) {
909 if (kid->op_sibling) {
915 op->op_flags &= ~OPf_PARENS;
916 if (hints & HINT_BLOCK_SCOPE)
917 op->op_flags |= OPf_PARENS;
920 op = newOP(OP_STUB, 0);
930 if (op && op->op_flags & OPf_KIDS) {
931 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
947 if (!op || error_count)
950 switch (op->op_type) {
952 if (!(op->op_private & (OPpCONST_ARYBASE)))
954 if (eval_start && eval_start->op_type == OP_CONST) {
955 compiling.cop_arybase = (I32)SvIV(((SVOP*)eval_start)->op_sv);
959 SAVEI32(compiling.cop_arybase);
960 compiling.cop_arybase = 0;
962 else if (type == OP_REFGEN)
965 croak("That use of $[ is unsupported");
968 if (op->op_flags & OPf_PARENS)
972 if ((type == OP_UNDEF || type == OP_REFGEN) &&
973 !(op->op_flags & OPf_STACKED)) {
974 op->op_type = OP_RV2CV; /* entersub => rv2cv */
975 op->op_ppaddr = ppaddr[OP_RV2CV];
976 assert(cUNOP->op_first->op_type == OP_NULL);
977 null(((LISTOP*)cUNOP->op_first)->op_first); /* disable pushmark */
983 /* grep, foreach, subcalls, refgen */
984 if (type == OP_GREPSTART || type == OP_ENTERSUB || type == OP_REFGEN)
986 sprintf(tokenbuf, "Can't modify %s in %s",
987 op_desc[op->op_type],
988 type ? op_desc[type] : "local");
1003 case OP_RIGHT_SHIFT:
1012 if (!(op->op_flags & OPf_STACKED))
1018 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
1024 if (type == OP_REFGEN && op->op_flags & OPf_PARENS) {
1026 return op; /* Treat \(@foo) like ordinary list. */
1030 ref(cUNOP->op_first, op->op_type);
1042 if (!type && cUNOP->op_first->op_type != OP_GV)
1043 croak("Can't localize a reference");
1044 ref(cUNOP->op_first, op->op_type);
1057 if (type == OP_REFGEN && op->op_flags & OPf_PARENS)
1058 return op; /* Treat \(@foo) like ordinary list. */
1063 croak("Can't localize lexical variable %s",
1064 SvPV(*av_fetch(comppad_name, op->op_targ, 4), na));
1071 if (type != OP_SASSIGN)
1077 pad_free(op->op_targ);
1078 op->op_targ = pad_alloc(op->op_type, SVs_PADMY);
1079 assert(SvTYPE(PAD_SV(op->op_targ)) == SVt_NULL);
1080 if (op->op_flags & OPf_KIDS)
1081 mod(cBINOP->op_first->op_sibling, type);
1086 ref(cBINOP->op_first, op->op_type);
1093 if (op->op_flags & OPf_KIDS)
1094 mod(cLISTOP->op_last, type);
1098 if (!(op->op_flags & OPf_KIDS))
1100 if (op->op_targ != OP_LIST) {
1101 mod(cBINOP->op_first, type);
1106 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
1110 op->op_flags |= OPf_MOD;
1112 if (type == OP_AASSIGN || type == OP_SASSIGN)
1113 op->op_flags |= OPf_SPECIAL|OPf_REF;
1115 op->op_private |= OPpLVAL_INTRO;
1116 op->op_flags &= ~OPf_SPECIAL;
1118 else if (type != OP_GREPSTART && type != OP_ENTERSUB)
1119 op->op_flags |= OPf_REF;
1129 if (op && op->op_flags & OPf_KIDS) {
1130 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
1143 if (!op || error_count)
1146 switch (op->op_type) {
1148 if ((type == OP_DEFINED) &&
1149 !(op->op_flags & OPf_STACKED)) {
1150 op->op_type = OP_RV2CV; /* entersub => rv2cv */
1151 op->op_ppaddr = ppaddr[OP_RV2CV];
1152 assert(cUNOP->op_first->op_type == OP_NULL);
1153 null(((LISTOP*)cUNOP->op_first)->op_first); /* disable pushmark */
1154 op->op_flags |= OPf_SPECIAL;
1159 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
1163 ref(cUNOP->op_first, op->op_type);
1166 if (type == OP_RV2SV || type == OP_RV2AV || type == OP_RV2HV) {
1167 op->op_private |= (type == OP_RV2AV ? OPpDEREF_AV
1168 : type == OP_RV2HV ? OPpDEREF_HV
1170 op->op_flags |= OPf_MOD;
1176 op->op_flags |= OPf_REF;
1179 ref(cUNOP->op_first, op->op_type);
1184 op->op_flags |= OPf_REF;
1189 if (!(op->op_flags & OPf_KIDS))
1191 ref(cBINOP->op_first, type);
1195 ref(cBINOP->op_first, op->op_type);
1196 if (type == OP_RV2SV || type == OP_RV2AV || type == OP_RV2HV) {
1197 op->op_private |= (type == OP_RV2AV ? OPpDEREF_AV
1198 : type == OP_RV2HV ? OPpDEREF_HV
1200 op->op_flags |= OPf_MOD;
1208 if (!(op->op_flags & OPf_KIDS))
1210 ref(cLISTOP->op_last, type);
1226 if (!op || error_count)
1230 if (type == OP_LIST) {
1231 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
1234 else if (type != OP_PADSV &&
1237 type != OP_PUSHMARK)
1239 sprintf(tokenbuf, "Can't declare %s in my", op_desc[op->op_type]);
1243 op->op_flags |= OPf_MOD;
1244 op->op_private |= OPpLVAL_INTRO;
1253 o->op_flags |= OPf_PARENS;
1258 bind_match(type, left, right)
1265 if (right->op_type == OP_MATCH ||
1266 right->op_type == OP_SUBST ||
1267 right->op_type == OP_TRANS) {
1268 right->op_flags |= OPf_STACKED;
1269 if (right->op_type != OP_MATCH)
1270 left = mod(left, right->op_type);
1271 if (right->op_type == OP_TRANS)
1272 op = newBINOP(OP_NULL, OPf_STACKED, scalar(left), right);
1274 op = prepend_elem(right->op_type, scalar(left), right);
1276 return newUNOP(OP_NOT, 0, scalar(op));
1280 return bind_match(type, left,
1281 pmruntime(newPMOP(OP_MATCH, 0), right, Nullop));
1290 /* XXX need to optimize away NOT NOT here? Or do we let optimizer do it? */
1291 return newUNOP(OP_NOT, OPf_SPECIAL, scalar(op));
1299 if (o->op_flags & OPf_PARENS || perldb || tainting) {
1300 o = prepend_elem(OP_LINESEQ, newOP(OP_ENTER, 0), o);
1301 o->op_type = OP_LEAVE;
1302 o->op_ppaddr = ppaddr[OP_LEAVE];
1305 if (o->op_type == OP_LINESEQ) {
1307 o->op_type = OP_SCOPE;
1308 o->op_ppaddr = ppaddr[OP_SCOPE];
1309 kid = ((LISTOP*)o)->op_first;
1310 if (kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE){
1311 SvREFCNT_dec(((COP*)kid)->cop_filegv);
1316 o = newLISTOP(OP_SCOPE, 0, o, Nullop);
1326 int retval = savestack_ix;
1327 SAVEI32(comppad_name_floor);
1329 if ((comppad_name_fill = AvFILL(comppad_name)) > 0)
1330 comppad_name_floor = comppad_name_fill;
1332 comppad_name_floor = 0;
1334 SAVEI32(min_intro_pending);
1335 SAVEI32(max_intro_pending);
1336 min_intro_pending = 0;
1337 SAVEI32(comppad_name_fill);
1338 SAVEI32(padix_floor);
1339 padix_floor = padix;
1340 pad_reset_pending = FALSE;
1342 hints &= ~HINT_BLOCK_SCOPE;
1347 block_end(floor, seq)
1351 int needblockscope = hints & HINT_BLOCK_SCOPE;
1352 OP* retval = scalarseq(seq);
1354 pad_reset_pending = FALSE;
1356 hints |= HINT_BLOCK_SCOPE; /* propagate out */
1357 pad_leavemy(comppad_name_fill);
1367 eval_root = newUNOP(OP_LEAVEEVAL, ((in_eval & 4) ? OPf_SPECIAL : 0), op);
1368 eval_start = linklist(eval_root);
1369 eval_root->op_next = 0;
1375 main_root = scope(sawparens(scalarvoid(op)));
1376 curcop = &compiling;
1377 main_start = LINKLIST(main_root);
1378 main_root->op_next = 0;
1382 /* Register with debugger */
1384 CV *cv = perl_get_cv("DB::postponed", FALSE);
1388 XPUSHs((SV*)compiling.cop_filegv);
1390 perl_call_sv((SV*)cv, G_DISCARD);
1401 if (o->op_flags & OPf_PARENS)
1405 if (dowarn && bufptr > oldbufptr && bufptr[-1] == ',') {
1407 for (s = bufptr; *s && (isALNUM(*s) || strchr("@$%, ",*s)); s++) ;
1408 if (*s == ';' || *s == '=')
1409 warn("Parens missing around \"%s\" list", lex ? "my" : "local");
1416 return mod(o, OP_NULL); /* a bit kludgey */
1423 if (o->op_type == OP_LIST) {
1424 o = convert(OP_JOIN, 0,
1425 prepend_elem(OP_LIST,
1426 newSVREF(newGVOP(OP_GV, 0, gv_fetchpv(";", TRUE, SVt_PV))),
1437 I32 type = o->op_type;
1440 if (opargs[type] & OA_RETSCALAR)
1442 if (opargs[type] & OA_TARGET)
1443 o->op_targ = pad_alloc(type, SVs_PADTMP);
1445 if ((opargs[type] & OA_OTHERINT) && (hints & HINT_INTEGER))
1446 o->op_ppaddr = ppaddr[type = ++(o->op_type)];
1448 if (!(opargs[type] & OA_FOLDCONST))
1452 goto nope; /* Don't try to run w/ errors */
1454 for (curop = LINKLIST(o); curop != o; curop = LINKLIST(curop)) {
1455 if (curop->op_type != OP_CONST &&
1456 curop->op_type != OP_LIST &&
1457 curop->op_type != OP_SCALAR &&
1458 curop->op_type != OP_NULL &&
1459 curop->op_type != OP_PUSHMARK) {
1464 curop = LINKLIST(o);
1469 if (o->op_targ && sv == PAD_SV(o->op_targ)) /* grab pad temp? */
1470 pad_swipe(o->op_targ);
1471 else if (SvTEMP(sv)) { /* grab mortal temp? */
1472 (void)SvREFCNT_inc(sv);
1476 if (type == OP_RV2GV)
1477 return newGVOP(OP_GV, 0, (GV*)sv);
1479 if ((SvFLAGS(sv) & (SVf_IOK|SVf_NOK|SVf_POK)) == SVf_NOK) {
1481 if ((double)iv == SvNV(sv)) { /* can we smush double to int */
1486 SvIOK_off(sv); /* undo SvIV() damage */
1488 return newSVOP(OP_CONST, 0, sv);
1492 if (!(opargs[type] & OA_OTHERINT))
1495 if (!(hints & HINT_INTEGER)) {
1496 if (type == OP_DIVIDE || !(o->op_flags & OPf_KIDS))
1499 for (curop = ((UNOP*)o)->op_first; curop; curop = curop->op_sibling) {
1500 if (curop->op_type == OP_CONST) {
1501 if (SvIOK(((SVOP*)curop)->op_sv))
1505 if (opargs[curop->op_type] & OA_RETINTEGER)
1509 o->op_ppaddr = ppaddr[++(o->op_type)];
1516 gen_constant_list(o)
1520 I32 oldtmps_floor = tmps_floor;
1524 return o; /* Don't attempt to run with errors */
1526 op = curop = LINKLIST(o);
1532 tmps_floor = oldtmps_floor;
1534 o->op_type = OP_RV2AV;
1535 o->op_ppaddr = ppaddr[OP_RV2AV];
1536 curop = ((UNOP*)o)->op_first;
1537 ((UNOP*)o)->op_first = newSVOP(OP_CONST, 0, SvREFCNT_inc(*stack_sp--));
1544 convert(type, flags, op)
1552 if (!op || op->op_type != OP_LIST)
1553 op = newLISTOP(OP_LIST, 0, op, Nullop);
1555 op->op_flags &= ~(OPf_KNOW|OPf_LIST);
1557 if (!(opargs[type] & OA_MARK))
1558 null(cLISTOP->op_first);
1561 op->op_ppaddr = ppaddr[type];
1562 op->op_flags |= flags;
1564 op = CHECKOP(type, op);
1565 if (op->op_type != type)
1568 if (cLISTOP->op_children < 7) {
1569 /* XXX do we really need to do this if we're done appending?? */
1570 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
1572 cLISTOP->op_last = last; /* in case check substituted last arg */
1575 return fold_constants(op);
1578 /* List constructors */
1581 append_elem(type, first, last)
1592 if (first->op_type != type || type==OP_LIST && first->op_flags & OPf_PARENS)
1593 return newLISTOP(type, 0, first, last);
1595 if (first->op_flags & OPf_KIDS)
1596 ((LISTOP*)first)->op_last->op_sibling = last;
1598 first->op_flags |= OPf_KIDS;
1599 ((LISTOP*)first)->op_first = last;
1601 ((LISTOP*)first)->op_last = last;
1602 ((LISTOP*)first)->op_children++;
1607 append_list(type, first, last)
1618 if (first->op_type != type)
1619 return prepend_elem(type, (OP*)first, (OP*)last);
1621 if (last->op_type != type)
1622 return append_elem(type, (OP*)first, (OP*)last);
1624 first->op_last->op_sibling = last->op_first;
1625 first->op_last = last->op_last;
1626 first->op_children += last->op_children;
1627 if (first->op_children)
1628 last->op_flags |= OPf_KIDS;
1635 prepend_elem(type, first, last)
1646 if (last->op_type == type) {
1647 if (type == OP_LIST) { /* already a PUSHMARK there */
1648 first->op_sibling = ((LISTOP*)last)->op_first->op_sibling;
1649 ((LISTOP*)last)->op_first->op_sibling = first;
1652 if (!(last->op_flags & OPf_KIDS)) {
1653 ((LISTOP*)last)->op_last = first;
1654 last->op_flags |= OPf_KIDS;
1656 first->op_sibling = ((LISTOP*)last)->op_first;
1657 ((LISTOP*)last)->op_first = first;
1659 ((LISTOP*)last)->op_children++;
1663 return newLISTOP(type, 0, first, last);
1671 return newOP(OP_STUB, 0);
1678 if (!op || op->op_type != OP_LIST)
1679 op = newLISTOP(OP_LIST, 0, op, Nullop);
1685 newLISTOP(type, flags, first, last)
1693 Newz(1101, listop, 1, LISTOP);
1695 listop->op_type = type;
1696 listop->op_ppaddr = ppaddr[type];
1697 listop->op_children = (first != 0) + (last != 0);
1698 listop->op_flags = flags;
1702 else if (!first && last)
1705 first->op_sibling = last;
1706 listop->op_first = first;
1707 listop->op_last = last;
1708 if (type == OP_LIST) {
1710 pushop = newOP(OP_PUSHMARK, 0);
1711 pushop->op_sibling = first;
1712 listop->op_first = pushop;
1713 listop->op_flags |= OPf_KIDS;
1715 listop->op_last = pushop;
1717 else if (listop->op_children)
1718 listop->op_flags |= OPf_KIDS;
1729 Newz(1101, op, 1, OP);
1731 op->op_ppaddr = ppaddr[type];
1732 op->op_flags = flags;
1735 op->op_private = 0 + (flags >> 8);
1736 if (opargs[type] & OA_RETSCALAR)
1738 if (opargs[type] & OA_TARGET)
1739 op->op_targ = pad_alloc(type, SVs_PADTMP);
1740 return CHECKOP(type, op);
1744 newUNOP(type, flags, first)
1752 first = newOP(OP_STUB, 0);
1753 if (opargs[type] & OA_MARK)
1754 first = force_list(first);
1756 Newz(1101, unop, 1, UNOP);
1757 unop->op_type = type;
1758 unop->op_ppaddr = ppaddr[type];
1759 unop->op_first = first;
1760 unop->op_flags = flags | OPf_KIDS;
1761 unop->op_private = 1 | (flags >> 8);
1763 unop = (UNOP*) CHECKOP(type, unop);
1767 return fold_constants((OP *) unop);
1771 newBINOP(type, flags, first, last)
1778 Newz(1101, binop, 1, BINOP);
1781 first = newOP(OP_NULL, 0);
1783 binop->op_type = type;
1784 binop->op_ppaddr = ppaddr[type];
1785 binop->op_first = first;
1786 binop->op_flags = flags | OPf_KIDS;
1789 binop->op_private = 1 | (flags >> 8);
1792 binop->op_private = 2 | (flags >> 8);
1793 first->op_sibling = last;
1796 binop = (BINOP*)CHECKOP(type, binop);
1800 binop->op_last = last = binop->op_first->op_sibling;
1802 return fold_constants((OP *)binop);
1806 pmtrans(op, expr, repl)
1811 SV *tstr = ((SVOP*)expr)->op_sv;
1812 SV *rstr = ((SVOP*)repl)->op_sv;
1815 register U8 *t = (U8*)SvPV(tstr, tlen);
1816 register U8 *r = (U8*)SvPV(rstr, rlen);
1821 register short *tbl;
1823 tbl = (short*)cPVOP->op_pv;
1824 complement = op->op_private & OPpTRANS_COMPLEMENT;
1825 delete = op->op_private & OPpTRANS_DELETE;
1826 /* squash = op->op_private & OPpTRANS_SQUASH; */
1829 Zero(tbl, 256, short);
1830 for (i = 0; i < tlen; i++)
1832 for (i = 0, j = 0; i < 256; i++) {
1848 if (!rlen && !delete) {
1851 for (i = 0; i < 256; i++)
1853 for (i = 0, j = 0; i < tlen; i++,j++) {
1856 if (tbl[t[i]] == -1)
1862 if (tbl[t[i]] == -1)
1873 newPMOP(type, flags)
1879 Newz(1101, pmop, 1, PMOP);
1880 pmop->op_type = type;
1881 pmop->op_ppaddr = ppaddr[type];
1882 pmop->op_flags = flags;
1883 pmop->op_private = 0 | (flags >> 8);
1885 if (hints & HINT_LOCALE)
1886 pmop->op_pmpermflags = (pmop->op_pmflags |= PMf_LOCALE);
1888 /* link into pm list */
1889 if (type != OP_TRANS && curstash) {
1890 pmop->op_pmnext = HvPMROOT(curstash);
1891 HvPMROOT(curstash) = pmop;
1898 pmruntime(op, expr, repl)
1906 if (op->op_type == OP_TRANS)
1907 return pmtrans(op, expr, repl);
1911 if (expr->op_type == OP_CONST) {
1913 SV *pat = ((SVOP*)expr)->op_sv;
1914 char *p = SvPV(pat, plen);
1915 if ((op->op_flags & OPf_SPECIAL) && strEQ(p, " ")) {
1916 sv_setpvn(pat, "\\s+", 3);
1917 p = SvPV(pat, plen);
1918 pm->op_pmflags |= PMf_SKIPWHITE;
1920 pm->op_pmregexp = pregcomp(p, p + plen, pm);
1921 if (strEQ("\\s+", pm->op_pmregexp->precomp))
1922 pm->op_pmflags |= PMf_WHITE;
1927 if (pm->op_pmflags & PMf_KEEP)
1928 expr = newUNOP(OP_REGCMAYBE,0,expr);
1930 Newz(1101, rcop, 1, LOGOP);
1931 rcop->op_type = OP_REGCOMP;
1932 rcop->op_ppaddr = ppaddr[OP_REGCOMP];
1933 rcop->op_first = scalar(expr);
1934 rcop->op_flags |= OPf_KIDS;
1935 rcop->op_private = 1;
1936 rcop->op_other = op;
1938 /* establish postfix order */
1939 if (pm->op_pmflags & PMf_KEEP) {
1941 rcop->op_next = expr;
1942 ((UNOP*)expr)->op_first->op_next = (OP*)rcop;
1945 rcop->op_next = LINKLIST(expr);
1946 expr->op_next = (OP*)rcop;
1949 prepend_elem(op->op_type, scalar((OP*)rcop), op);
1954 if (pm->op_pmflags & PMf_EVAL)
1956 else if (repl->op_type == OP_CONST)
1960 for (curop = LINKLIST(repl); curop!=repl; curop = LINKLIST(curop)) {
1961 if (opargs[curop->op_type] & OA_DANGEROUS) {
1962 if (curop->op_type == OP_GV) {
1963 GV *gv = ((GVOP*)curop)->op_gv;
1964 if (strchr("&`'123456789+", *GvENAME(gv)))
1967 else if (curop->op_type == OP_RV2CV)
1969 else if (curop->op_type == OP_RV2SV ||
1970 curop->op_type == OP_RV2AV ||
1971 curop->op_type == OP_RV2HV ||
1972 curop->op_type == OP_RV2GV) {
1973 if (lastop && lastop->op_type != OP_GV) /*funny deref?*/
1976 else if (curop->op_type == OP_PADSV ||
1977 curop->op_type == OP_PADAV ||
1978 curop->op_type == OP_PADHV ||
1979 curop->op_type == OP_PADANY) {
1988 if (curop == repl) {
1989 pm->op_pmflags |= PMf_CONST; /* const for long enough */
1990 pm->op_pmpermflags |= PMf_CONST; /* const for long enough */
1991 prepend_elem(op->op_type, scalar(repl), op);
1994 Newz(1101, rcop, 1, LOGOP);
1995 rcop->op_type = OP_SUBSTCONT;
1996 rcop->op_ppaddr = ppaddr[OP_SUBSTCONT];
1997 rcop->op_first = scalar(repl);
1998 rcop->op_flags |= OPf_KIDS;
1999 rcop->op_private = 1;
2000 rcop->op_other = op;
2002 /* establish postfix order */
2003 rcop->op_next = LINKLIST(repl);
2004 repl->op_next = (OP*)rcop;
2006 pm->op_pmreplroot = scalar((OP*)rcop);
2007 pm->op_pmreplstart = LINKLIST(rcop);
2016 newSVOP(type, flags, sv)
2022 Newz(1101, svop, 1, SVOP);
2023 svop->op_type = type;
2024 svop->op_ppaddr = ppaddr[type];
2026 svop->op_next = (OP*)svop;
2027 svop->op_flags = flags;
2028 if (opargs[type] & OA_RETSCALAR)
2030 if (opargs[type] & OA_TARGET)
2031 svop->op_targ = pad_alloc(type, SVs_PADTMP);
2032 return CHECKOP(type, svop);
2036 newGVOP(type, flags, gv)
2042 Newz(1101, gvop, 1, GVOP);
2043 gvop->op_type = type;
2044 gvop->op_ppaddr = ppaddr[type];
2045 gvop->op_gv = (GV*)SvREFCNT_inc(gv);
2046 gvop->op_next = (OP*)gvop;
2047 gvop->op_flags = flags;
2048 if (opargs[type] & OA_RETSCALAR)
2050 if (opargs[type] & OA_TARGET)
2051 gvop->op_targ = pad_alloc(type, SVs_PADTMP);
2052 return CHECKOP(type, gvop);
2056 newPVOP(type, flags, pv)
2062 Newz(1101, pvop, 1, PVOP);
2063 pvop->op_type = type;
2064 pvop->op_ppaddr = ppaddr[type];
2066 pvop->op_next = (OP*)pvop;
2067 pvop->op_flags = flags;
2068 if (opargs[type] & OA_RETSCALAR)
2070 if (opargs[type] & OA_TARGET)
2071 pvop->op_targ = pad_alloc(type, SVs_PADTMP);
2072 return CHECKOP(type, pvop);
2081 save_hptr(&curstash);
2082 save_item(curstname);
2087 name = SvPV(sv, len);
2088 curstash = gv_stashpvn(name,len,TRUE);
2089 sv_setpvn(curstname, name, len);
2093 sv_setpv(curstname,"<none>");
2101 utilize(aver, floor, version, id, arg)
2114 if (id->op_type != OP_CONST)
2115 croak("Module name must be constant");
2119 if(version != Nullop) {
2120 SV *vesv = ((SVOP*)version)->op_sv;
2122 if (arg == Nullop && !SvNIOK(vesv)) {
2129 if (version->op_type != OP_CONST || !SvNIOK(vesv))
2130 croak("Version number must be constant number");
2132 /* Make copy of id so we don't free it twice */
2133 pack = newSVOP(OP_CONST, 0, newSVsv(((SVOP*)id)->op_sv));
2135 /* Fake up a method call to VERSION */
2136 meth = newSVOP(OP_CONST, 0, newSVpv("VERSION", 7));
2137 veop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL,
2138 append_elem(OP_LIST,
2139 prepend_elem(OP_LIST, pack, list(version)),
2140 newUNOP(OP_METHOD, 0, meth)));
2144 /* Fake up an import/unimport */
2145 if (arg && arg->op_type == OP_STUB)
2146 imop = arg; /* no import on explicit () */
2147 else if(SvNIOK(((SVOP*)id)->op_sv)) {
2148 imop = Nullop; /* use 5.0; */
2151 /* Make copy of id so we don't free it twice */
2152 pack = newSVOP(OP_CONST, 0, newSVsv(((SVOP*)id)->op_sv));
2153 meth = newSVOP(OP_CONST, 0,
2155 ? newSVpv("import", 6)
2156 : newSVpv("unimport", 8)
2158 imop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL,
2159 append_elem(OP_LIST,
2160 prepend_elem(OP_LIST, pack, list(arg)),
2161 newUNOP(OP_METHOD, 0, meth)));
2164 /* Fake up a require */
2165 rqop = newUNOP(OP_REQUIRE, 0, id);
2167 /* Fake up the BEGIN {}, which does its thing immediately. */
2169 newSVOP(OP_CONST, 0, newSVpv("BEGIN", 5)),
2171 append_elem(OP_LINESEQ,
2172 append_elem(OP_LINESEQ,
2173 newSTATEOP(0, Nullch, rqop),
2174 newSTATEOP(0, Nullch, veop)),
2175 newSTATEOP(0, Nullch, imop) ));
2182 newSLICEOP(flags, subscript, listval)
2187 return newBINOP(OP_LSLICE, flags,
2188 list(force_list(subscript)),
2189 list(force_list(listval)) );
2199 if (op->op_type == OP_NULL && op->op_flags & OPf_KIDS)
2200 op = cUNOP->op_first;
2202 if (op->op_type == OP_COND_EXPR) {
2203 I32 t = list_assignment(cCONDOP->op_first->op_sibling);
2204 I32 f = list_assignment(cCONDOP->op_first->op_sibling->op_sibling);
2209 yyerror("Assignment to both a list and a scalar");
2213 if (op->op_type == OP_LIST || op->op_flags & OPf_PARENS ||
2214 op->op_type == OP_RV2AV || op->op_type == OP_RV2HV ||
2215 op->op_type == OP_ASLICE || op->op_type == OP_HSLICE)
2218 if (op->op_type == OP_PADAV || op->op_type == OP_PADHV)
2221 if (op->op_type == OP_RV2SV)
2228 newASSIGNOP(flags, left, optype, right)
2237 if (optype == OP_ANDASSIGN || optype == OP_ORASSIGN) {
2238 return newLOGOP(optype, 0,
2239 mod(scalar(left), optype),
2240 newUNOP(OP_SASSIGN, 0, scalar(right)));
2243 return newBINOP(optype, OPf_STACKED,
2244 mod(scalar(left), optype), scalar(right));
2248 if (list_assignment(left)) {
2250 eval_start = right; /* Grandfathering $[ assignment here. Bletch.*/
2251 left = mod(left, OP_AASSIGN);
2259 op = newBINOP(OP_AASSIGN, flags,
2260 list(force_list(right)),
2261 list(force_list(left)) );
2262 op->op_private = 0 | (flags >> 8);
2263 if (!(left->op_private & OPpLVAL_INTRO)) {
2264 static int generation = 100;
2268 for (curop = LINKLIST(op); curop != op; curop = LINKLIST(curop)) {
2269 if (opargs[curop->op_type] & OA_DANGEROUS) {
2270 if (curop->op_type == OP_GV) {
2271 GV *gv = ((GVOP*)curop)->op_gv;
2272 if (gv == defgv || SvCUR(gv) == generation)
2274 SvCUR(gv) = generation;
2276 else if (curop->op_type == OP_PADSV ||
2277 curop->op_type == OP_PADAV ||
2278 curop->op_type == OP_PADHV ||
2279 curop->op_type == OP_PADANY) {
2280 SV **svp = AvARRAY(comppad_name);
2281 SV *sv = svp[curop->op_targ];
2282 if (SvCUR(sv) == generation)
2284 SvCUR(sv) = generation; /* (SvCUR not used any more) */
2286 else if (curop->op_type == OP_RV2CV)
2288 else if (curop->op_type == OP_RV2SV ||
2289 curop->op_type == OP_RV2AV ||
2290 curop->op_type == OP_RV2HV ||
2291 curop->op_type == OP_RV2GV) {
2292 if (lastop->op_type != OP_GV) /* funny deref? */
2301 op->op_private = OPpASSIGN_COMMON;
2303 if (right && right->op_type == OP_SPLIT) {
2305 if ((tmpop = ((LISTOP*)right)->op_first) &&
2306 tmpop->op_type == OP_PUSHRE)
2308 PMOP *pm = (PMOP*)tmpop;
2309 if (left->op_type == OP_RV2AV &&
2310 !(left->op_private & OPpLVAL_INTRO) &&
2311 !(op->op_private & OPpASSIGN_COMMON) )
2313 tmpop = ((UNOP*)left)->op_first;
2314 if (tmpop->op_type == OP_GV && !pm->op_pmreplroot) {
2315 pm->op_pmreplroot = (OP*)((GVOP*)tmpop)->op_gv;
2316 pm->op_pmflags |= PMf_ONCE;
2317 tmpop = ((UNOP*)op)->op_first; /* to list (nulled) */
2318 tmpop = ((UNOP*)tmpop)->op_first; /* to pushmark */
2319 tmpop->op_sibling = Nullop; /* don't free split */
2320 right->op_next = tmpop->op_next; /* fix starting loc */
2321 op_free(op); /* blow off assign */
2322 right->op_flags &= ~(OPf_KNOW|OPf_LIST);
2323 /* "I don't know and I don't care." */
2328 if (modcount < 10000 &&
2329 ((LISTOP*)right)->op_last->op_type == OP_CONST)
2331 SV *sv = ((SVOP*)((LISTOP*)right)->op_last)->op_sv;
2333 sv_setiv(sv, modcount+1);
2341 right = newOP(OP_UNDEF, 0);
2342 if (right->op_type == OP_READLINE) {
2343 right->op_flags |= OPf_STACKED;
2344 return newBINOP(OP_NULL, flags, mod(scalar(left), OP_SASSIGN), scalar(right));
2347 eval_start = right; /* Grandfathering $[ assignment here. Bletch.*/
2348 op = newBINOP(OP_SASSIGN, flags,
2349 scalar(right), mod(scalar(left), OP_SASSIGN) );
2361 newSTATEOP(flags, label, op)
2366 U32 seq = intro_my();
2369 Newz(1101, cop, 1, COP);
2370 if (perldb && curcop->cop_line && curstash != debstash) {
2371 cop->op_type = OP_DBSTATE;
2372 cop->op_ppaddr = ppaddr[ OP_DBSTATE ];
2375 cop->op_type = OP_NEXTSTATE;
2376 cop->op_ppaddr = ppaddr[ OP_NEXTSTATE ];
2378 cop->op_flags = flags;
2379 cop->op_private = 0 | (flags >> 8);
2381 cop->op_private |= NATIVE_HINTS;
2383 cop->op_next = (OP*)cop;
2386 cop->cop_label = label;
2387 hints |= HINT_BLOCK_SCOPE;
2390 cop->cop_arybase = curcop->cop_arybase;
2392 if (copline == NOLINE)
2393 cop->cop_line = curcop->cop_line;
2395 cop->cop_line = copline;
2398 cop->cop_filegv = (GV*)SvREFCNT_inc(curcop->cop_filegv);
2399 cop->cop_stash = curstash;
2401 if (perldb && curstash != debstash) {
2402 SV **svp = av_fetch(GvAV(curcop->cop_filegv),(I32)cop->cop_line, FALSE);
2403 if (svp && *svp != &sv_undef && !SvIOK(*svp)) {
2404 (void)SvIOK_on(*svp);
2406 SvSTASH(*svp) = (HV*)cop;
2410 return prepend_elem(OP_LINESEQ, (OP*)cop, op);
2413 /* "Introduce" my variables to visible status. */
2421 if (! min_intro_pending)
2424 svp = AvARRAY(comppad_name);
2425 for (i = min_intro_pending; i <= max_intro_pending; i++) {
2426 if ((sv = svp[i]) && sv != &sv_undef && !SvIVX(sv)) {
2427 SvIVX(sv) = 999999999; /* Don't know scope end yet. */
2428 SvNVX(sv) = (double)cop_seqmax;
2431 min_intro_pending = 0;
2432 comppad_name_fill = max_intro_pending; /* Needn't search higher */
2433 return cop_seqmax++;
2437 newLOGOP(type, flags, first, other)
2446 if (type == OP_XOR) /* Not short circuit, but here by precedence. */
2447 return newBINOP(type, flags, scalar(first), scalar(other));
2449 scalarboolean(first);
2450 /* optimize "!a && b" to "a || b", and "!a || b" to "a && b" */
2451 if (first->op_type == OP_NOT && (first->op_flags & OPf_SPECIAL)) {
2452 if (type == OP_AND || type == OP_OR) {
2458 first = cUNOP->op_first;
2460 first->op_next = op->op_next;
2461 cUNOP->op_first = Nullop;
2465 if (first->op_type == OP_CONST) {
2466 if (dowarn && (first->op_private & OPpCONST_BARE))
2467 warn("Probable precedence problem on %s", op_desc[type]);
2468 if ((type == OP_AND) == (SvTRUE(((SVOP*)first)->op_sv))) {
2477 else if (first->op_type == OP_WANTARRAY) {
2483 else if (dowarn && (first->op_flags & OPf_KIDS)) {
2484 OP *k1 = ((UNOP*)first)->op_first;
2485 OP *k2 = k1->op_sibling;
2487 switch (first->op_type)
2490 if (k2 && k2->op_type == OP_READLINE
2491 && (k2->op_flags & OPf_STACKED)
2492 && (k1->op_type == OP_RV2SV || k1->op_type == OP_PADSV))
2493 warnop = k2->op_type;
2497 if (k1->op_type == OP_READDIR || k1->op_type == OP_GLOB)
2498 warnop = k1->op_type;
2502 line_t oldline = curcop->cop_line;
2503 curcop->cop_line = copline;
2504 warn("Value of %s construct can be \"0\"; test with defined()",
2506 curcop->cop_line = oldline;
2513 if (type == OP_ANDASSIGN || type == OP_ORASSIGN)
2514 other->op_private |= OPpASSIGN_BACKWARDS; /* other is an OP_SASSIGN */
2516 Newz(1101, logop, 1, LOGOP);
2518 logop->op_type = type;
2519 logop->op_ppaddr = ppaddr[type];
2520 logop->op_first = first;
2521 logop->op_flags = flags | OPf_KIDS;
2522 logop->op_other = LINKLIST(other);
2523 logop->op_private = 1 | (flags >> 8);
2525 /* establish postfix order */
2526 logop->op_next = LINKLIST(first);
2527 first->op_next = (OP*)logop;
2528 first->op_sibling = other;
2530 op = newUNOP(OP_NULL, 0, (OP*)logop);
2531 other->op_next = op;
2537 newCONDOP(flags, first, trueop, falseop)
2547 return newLOGOP(OP_AND, 0, first, trueop);
2549 return newLOGOP(OP_OR, 0, first, falseop);
2551 scalarboolean(first);
2552 if (first->op_type == OP_CONST) {
2553 if (SvTRUE(((SVOP*)first)->op_sv)) {
2564 else if (first->op_type == OP_WANTARRAY) {
2568 Newz(1101, condop, 1, CONDOP);
2570 condop->op_type = OP_COND_EXPR;
2571 condop->op_ppaddr = ppaddr[OP_COND_EXPR];
2572 condop->op_first = first;
2573 condop->op_flags = flags | OPf_KIDS;
2574 condop->op_true = LINKLIST(trueop);
2575 condop->op_false = LINKLIST(falseop);
2576 condop->op_private = 1 | (flags >> 8);
2578 /* establish postfix order */
2579 condop->op_next = LINKLIST(first);
2580 first->op_next = (OP*)condop;
2582 first->op_sibling = trueop;
2583 trueop->op_sibling = falseop;
2584 op = newUNOP(OP_NULL, 0, (OP*)condop);
2586 trueop->op_next = op;
2587 falseop->op_next = op;
2593 newRANGE(flags, left, right)
2603 Newz(1101, condop, 1, CONDOP);
2605 condop->op_type = OP_RANGE;
2606 condop->op_ppaddr = ppaddr[OP_RANGE];
2607 condop->op_first = left;
2608 condop->op_flags = OPf_KIDS;
2609 condop->op_true = LINKLIST(left);
2610 condop->op_false = LINKLIST(right);
2611 condop->op_private = 1 | (flags >> 8);
2613 left->op_sibling = right;
2615 condop->op_next = (OP*)condop;
2616 flip = newUNOP(OP_FLIP, flags, (OP*)condop);
2617 flop = newUNOP(OP_FLOP, 0, flip);
2618 op = newUNOP(OP_NULL, 0, flop);
2621 left->op_next = flip;
2622 right->op_next = flop;
2624 condop->op_targ = pad_alloc(OP_RANGE, SVs_PADMY);
2625 sv_upgrade(PAD_SV(condop->op_targ), SVt_PVNV);
2626 flip->op_targ = pad_alloc(OP_RANGE, SVs_PADMY);
2627 sv_upgrade(PAD_SV(flip->op_targ), SVt_PVNV);
2629 flip->op_private = left->op_type == OP_CONST ? OPpFLIP_LINENUM : 0;
2630 flop->op_private = right->op_type == OP_CONST ? OPpFLIP_LINENUM : 0;
2633 if (!flip->op_private || !flop->op_private)
2634 linklist(op); /* blow off optimizer unless constant */
2640 newLOOPOP(flags, debuggable, expr, block)
2648 int once = block && block->op_flags & OPf_SPECIAL &&
2649 (block->op_type == OP_ENTERSUB || block->op_type == OP_NULL);
2652 if (once && expr->op_type == OP_CONST && !SvTRUE(((SVOP*)expr)->op_sv))
2653 return block; /* do {} while 0 does once */
2654 if (expr->op_type == OP_READLINE || expr->op_type == OP_GLOB) {
2655 expr = newUNOP(OP_DEFINED, 0,
2656 newASSIGNOP(0, newSVREF(newGVOP(OP_GV, 0, defgv)), 0, expr) );
2660 listop = append_elem(OP_LINESEQ, block, newOP(OP_UNSTACK, 0));
2661 op = newLOGOP(OP_AND, 0, expr, listop);
2663 ((LISTOP*)listop)->op_last->op_next = LINKLIST(op);
2665 if (once && op != listop)
2666 op->op_next = ((LOGOP*)cUNOP->op_first)->op_other;
2669 op = newUNOP(OP_NULL, 0, op); /* or do {} while 1 loses outer block */
2671 op->op_flags |= flags;
2673 op->op_flags |= OPf_SPECIAL; /* suppress POPBLOCK curpm restoration*/
2678 newWHILEOP(flags, debuggable, loop, expr, block, cont)
2692 if (expr && (expr->op_type == OP_READLINE || expr->op_type == OP_GLOB)) {
2693 expr = newUNOP(OP_DEFINED, 0,
2694 newASSIGNOP(0, newSVREF(newGVOP(OP_GV, 0, defgv)), 0, expr) );
2698 block = newOP(OP_NULL, 0);
2701 next = LINKLIST(cont);
2703 cont = append_elem(OP_LINESEQ, cont, newOP(OP_UNSTACK, 0));
2705 listop = append_list(OP_LINESEQ, (LISTOP*)block, (LISTOP*)cont);
2706 redo = LINKLIST(listop);
2709 op = newLOGOP(OP_AND, 0, expr, scalar(listop));
2710 if (op == expr && op->op_type == OP_CONST && !SvTRUE(cSVOP->op_sv)) {
2711 op_free(expr); /* oops, it's a while (0) */
2713 return Nullop; /* (listop already freed by newLOGOP) */
2715 ((LISTOP*)listop)->op_last->op_next = condop =
2716 (op == listop ? redo : LINKLIST(op));
2724 Newz(1101,loop,1,LOOP);
2725 loop->op_type = OP_ENTERLOOP;
2726 loop->op_ppaddr = ppaddr[OP_ENTERLOOP];
2727 loop->op_private = 0;
2728 loop->op_next = (OP*)loop;
2731 op = newBINOP(OP_LEAVELOOP, 0, (OP*)loop, op);
2733 loop->op_redoop = redo;
2734 loop->op_lastop = op;
2737 loop->op_nextop = next;
2739 loop->op_nextop = op;
2741 op->op_flags |= flags;
2742 op->op_private |= (flags >> 8);
2747 #ifndef CAN_PROTOTYPE
2748 newFOROP(flags,label,forline,sv,expr,block,cont)
2757 newFOROP(I32 flags,char *label,line_t forline,OP *sv,OP *expr,OP *block,OP *cont)
2758 #endif /* CAN_PROTOTYPE */
2766 if (sv->op_type == OP_RV2SV) { /* symbol table variable */
2767 sv->op_type = OP_RV2GV;
2768 sv->op_ppaddr = ppaddr[OP_RV2GV];
2770 else if (sv->op_type == OP_PADSV) { /* private variable */
2771 padoff = sv->op_targ;
2776 croak("Can't use %s for loop variable", op_desc[sv->op_type]);
2779 sv = newGVOP(OP_GV, 0, defgv);
2781 if (expr->op_type == OP_RV2AV || expr->op_type == OP_PADAV) {
2782 expr = scalar(ref(expr, OP_ITER));
2783 iterflags |= OPf_STACKED;
2785 loop = (LOOP*)list(convert(OP_ENTERITER, iterflags,
2786 append_elem(OP_LIST, mod(force_list(expr), OP_GREPSTART),
2788 assert(!loop->op_next);
2789 Renew(loop, 1, LOOP);
2790 loop->op_targ = padoff;
2791 return newSTATEOP(0, label, newWHILEOP(flags, 1, loop,
2792 newOP(OP_ITER, 0), block, cont));
2796 newLOOPEX(type, label)
2801 if (type != OP_GOTO || label->op_type == OP_CONST) {
2802 op = newPVOP(type, 0, savepv(
2803 label->op_type == OP_CONST
2804 ? SvPVx(((SVOP*)label)->op_sv, na)
2809 if (label->op_type == OP_ENTERSUB)
2810 label = newUNOP(OP_REFGEN, 0, mod(label, OP_REFGEN));
2811 op = newUNOP(type, OPf_STACKED, label);
2813 hints |= HINT_BLOCK_SCOPE;
2821 if (!CvXSUB(cv) && CvROOT(cv)) {
2823 croak("Can't undef active subroutine");
2830 op_free(CvROOT(cv));
2831 CvROOT(cv) = Nullop;
2835 SvREFCNT_dec(CvGV(cv));
2837 SvREFCNT_dec(CvOUTSIDE(cv));
2838 CvOUTSIDE(cv) = Nullcv;
2839 if (CvPADLIST(cv)) {
2840 /* may be during global destruction */
2841 if (SvREFCNT(CvPADLIST(cv))) {
2842 I32 i = AvFILL(CvPADLIST(cv));
2844 SV** svp = av_fetch(CvPADLIST(cv), i--, FALSE);
2848 SvREFCNT_dec((SV*)CvPADLIST(cv));
2850 CvPADLIST(cv) = Nullav;
2854 #ifdef DEBUG_CLOSURES
2859 CV *outside = CvOUTSIDE(cv);
2860 AV* padlist = CvPADLIST(cv);
2867 PerlIO_printf(Perl_debug_log, "\tCV=0x%p (%s), OUTSIDE=0x%p (%s)\n",
2869 (CvANON(cv) ? "ANON"
2870 : (cv == main_cv) ? "MAIN"
2871 : CvUNIQUE(outside) ? "UNIQUE"
2872 : CvGV(cv) ? GvNAME(CvGV(cv)) : "UNDEFINED"),
2875 : CvANON(outside) ? "ANON"
2876 : (outside == main_cv) ? "MAIN"
2877 : CvUNIQUE(outside) ? "UNIQUE"
2878 : CvGV(outside) ? GvNAME(CvGV(outside)) : "UNDEFINED"));
2883 pad_name = (AV*)*av_fetch(padlist, 0, FALSE);
2884 pad = (AV*)*av_fetch(padlist, 1, FALSE);
2885 pname = AvARRAY(pad_name);
2886 ppad = AvARRAY(pad);
2888 for (ix = 1; ix <= AvFILL(pad); ix++) {
2889 if (SvPOK(pname[ix]))
2890 PerlIO_printf(Perl_debug_log, "\t%4d. 0x%p (%s\"%s\" %ld-%ld)\n",
2892 SvFAKE(pname[ix]) ? "FAKE " : "",
2894 (long)I_32(SvNVX(pname[ix])),
2895 (long)SvIVX(pname[ix]));
2898 #endif /* DEBUG_CLOSURES */
2901 cv_clone2(proto, outside)
2907 AV* protopadlist = CvPADLIST(proto);
2908 AV* protopad_name = (AV*)*av_fetch(protopadlist, 0, FALSE);
2909 AV* protopad = (AV*)*av_fetch(protopadlist, 1, FALSE);
2910 SV** pname = AvARRAY(protopad_name);
2911 SV** ppad = AvARRAY(protopad);
2915 assert(!CvUNIQUE(proto));
2922 cv = compcv = (CV*)NEWSV(1104,0);
2923 sv_upgrade((SV *)cv, SvTYPE(proto));
2928 CvFILEGV(cv) = CvFILEGV(proto);
2929 CvGV(cv) = (GV*)SvREFCNT_inc(CvGV(proto));
2930 CvSTASH(cv) = CvSTASH(proto);
2931 CvROOT(cv) = CvROOT(proto);
2932 CvSTART(cv) = CvSTART(proto);
2934 CvOUTSIDE(cv) = (CV*)SvREFCNT_inc(outside);
2938 comppadlist = newAV();
2939 AvREAL_off(comppadlist);
2940 av_store(comppadlist, 0, SvREFCNT_inc((SV*)protopad_name));
2941 av_store(comppadlist, 1, (SV*)comppad);
2942 CvPADLIST(cv) = comppadlist;
2943 av_fill(comppad, AvFILL(protopad));
2944 curpad = AvARRAY(comppad);
2946 av = newAV(); /* will be @_ */
2948 av_store(comppad, 0, (SV*)av);
2949 AvFLAGS(av) = AVf_REIFY;
2951 for (ix = AvFILL(protopad); ix > 0; ix--) {
2953 if (pname[ix] != &sv_undef) {
2954 char *name = SvPVX(pname[ix]); /* XXX */
2955 if (SvFLAGS(pname[ix]) & SVf_FAKE) { /* lexical from outside? */
2956 I32 off = pad_findlex(name, ix, SvIVX(pname[ix]),
2957 CvOUTSIDE(cv), cxstack_ix);
2959 curpad[ix] = SvREFCNT_inc(ppad[ix]);
2961 croak("panic: cv_clone: %s", name);
2963 else { /* our own lexical */
2965 /* anon code -- we'll come back for it */
2966 sv = SvREFCNT_inc(ppad[ix]);
2968 else if (*name == '@')
2970 else if (*name == '%')
2986 /* Now that vars are all in place, clone nested closures. */
2988 for (ix = AvFILL(protopad); ix > 0; ix--) {
2989 if (pname[ix] != &sv_undef
2990 && !(SvFLAGS(pname[ix]) & SVf_FAKE)
2991 && *SvPVX(pname[ix]) == '&'
2992 && CvCLONE(ppad[ix]))
2994 CV *kid = cv_clone2((CV*)ppad[ix], cv);
2995 SvREFCNT_dec(ppad[ix]);
2998 curpad[ix] = (SV*)kid;
3002 #ifdef DEBUG_CLOSURES
3003 PerlIO_printf(Perl_debug_log, "Cloned inside:\n");
3005 PerlIO_printf(Perl_debug_log, " from:\n");
3007 PerlIO_printf(Perl_debug_log, " to:\n");
3019 return cv_clone2(proto, CvOUTSIDE(proto));
3029 if(cv && SvPOK(cv) && !SvCUR(cv)) {
3030 for (o = CvSTART(cv); o; o = o->op_next) {
3031 OPCODE type = o->op_type;
3033 if (type == OP_NEXTSTATE || type == OP_NULL || type == OP_PUSHMARK)
3035 if (type == OP_LEAVESUB || type == OP_RETURN)
3037 if (type != OP_CONST || sv)
3040 sv = ((SVOP*)o)->op_sv;
3047 newSUB(floor,op,proto,block)
3053 char *name = op ? SvPVx(cSVOP->op_sv, na) : Nullch;
3054 GV *gv = gv_fetchpv(name ? name : "__ANON__", GV_ADDMULTI, SVt_PVCV);
3061 if (cv = (name ? GvCV(gv) : Nullcv)) {
3063 /* just a cached method */
3067 else if (CvROOT(cv) || CvXSUB(cv) || GvASSUMECV(gv)) {
3068 /* already defined (or promised) */
3070 SV* const_sv = cv_const_sv(cv);
3071 char *p = proto ? SvPVx(((SVOP*)proto)->op_sv, na) : Nullch;
3073 if((!proto != !SvPOK(cv)) || (p && strNE(SvPV((SV*)cv,na), p))) {
3074 warn("Prototype mismatch: (%s) vs (%s)",
3075 SvPOK(cv) ? SvPV((SV*)cv,na) : "none",
3078 if (const_sv || dowarn) {
3079 line_t oldline = curcop->cop_line;
3080 curcop->cop_line = copline;
3081 warn(const_sv ? "Constant subroutine %s redefined"
3082 : "Subroutine %s redefined",name);
3083 curcop->cop_line = oldline;
3089 if (cv) { /* must reuse cv if autoloaded */
3091 CvFLAGS(cv) = CvFLAGS(compcv);
3092 CvOUTSIDE(cv) = CvOUTSIDE(compcv);
3093 CvOUTSIDE(compcv) = 0;
3094 CvPADLIST(cv) = CvPADLIST(compcv);
3095 CvPADLIST(compcv) = 0;
3096 if (SvREFCNT(compcv) > 1) /* XXX Make closures transit through stub. */
3097 CvOUTSIDE(compcv) = (CV*)SvREFCNT_inc((SV*)cv);
3098 SvREFCNT_dec(compcv);
3108 CvGV(cv) = (GV*)SvREFCNT_inc(gv);
3109 CvFILEGV(cv) = curcop->cop_filegv;
3110 CvSTASH(cv) = curstash;
3113 char *p = SvPVx(((SVOP*)proto)->op_sv, na);
3114 sv_setpv((SV*)cv, p);
3128 av = newAV(); /* Will be @_ */
3130 av_store(comppad, 0, (SV*)av);
3131 AvFLAGS(av) = AVf_REIFY;
3133 for (ix = AvFILL(comppad); ix > 0; ix--) {
3134 if (!SvPADMY(curpad[ix]) && !SvIMMORTAL(curpad[ix]))
3135 SvPADTMP_on(curpad[ix]);
3138 if (AvFILL(comppad_name) < AvFILL(comppad))
3139 av_store(comppad_name, AvFILL(comppad), Nullsv);
3141 CvROOT(cv) = newUNOP(OP_LEAVESUB, 0, scalarseq(block));
3142 CvSTART(cv) = LINKLIST(CvROOT(cv));
3143 CvROOT(cv)->op_next = 0;
3149 if (perldb && curstash != debstash) {
3151 SV *tmpstr = sv_newmortal();
3152 static GV *db_postponed;
3156 sprintf(buf, "%s:%ld",
3157 SvPVX(GvSV(curcop->cop_filegv)), (long)subline);
3158 sv = newSVpv(buf,0);
3160 sprintf(buf,"%ld",(long)curcop->cop_line);
3162 gv_efullname3(tmpstr, gv, Nullch);
3163 hv_store(GvHV(DBsub), SvPVX(tmpstr), SvCUR(tmpstr), sv, 0);
3164 if (!db_postponed) {
3165 db_postponed = gv_fetchpv("DB::postponed", TRUE, SVt_PVHV);
3167 hv = GvHVn(db_postponed);
3168 if (HvFILL(hv) >= 0 && hv_exists(hv, SvPVX(tmpstr), SvCUR(tmpstr))
3169 && (cv = GvCV(db_postponed))) {
3174 perl_call_sv((SV*)cv, G_DISCARD);
3178 if ((s = strrchr(name,':')))
3182 if (strEQ(s, "BEGIN") && !error_count) {
3184 SAVESPTR(compiling.cop_filegv);
3185 SAVEI16(compiling.cop_line);
3192 DEBUG_x( dump_sub(gv) );
3193 av_push(beginav, (SV *)cv);
3197 curcop = &compiling;
3200 else if (strEQ(s, "END") && !error_count) {
3203 av_unshift(endav, 1);
3204 av_store(endav, 0, (SV *)cv);
3216 newXSUB(name, ix, subaddr, filename)
3222 CV* cv = newXS(name, (void(*)())subaddr, filename);
3224 CvXSUBANY(cv).any_i32 = ix;
3230 newXS(name, subaddr, filename)
3232 void (*subaddr) _((CV*));
3235 GV *gv = gv_fetchpv(name ? name : "__ANON__", GV_ADDMULTI, SVt_PVCV);
3238 if (cv = (name ? GvCV(gv) : Nullcv)) {
3240 /* just a cached method */
3244 else if (CvROOT(cv) || CvXSUB(cv) || GvASSUMECV(gv)) {
3245 /* already defined (or promised) */
3247 line_t oldline = curcop->cop_line;
3248 curcop->cop_line = copline;
3249 warn("Subroutine %s redefined",name);
3250 curcop->cop_line = oldline;
3257 if (cv) /* must reuse cv if autoloaded */
3260 cv = (CV*)NEWSV(1105,0);
3261 sv_upgrade((SV *)cv, SVt_PVCV);
3268 CvGV(cv) = (GV*)SvREFCNT_inc(gv);
3269 CvFILEGV(cv) = gv_fetchfile(filename);
3270 CvXSUB(cv) = subaddr;
3273 char *s = strrchr(name,':');
3278 if (strEQ(s, "BEGIN")) {
3281 av_push(beginav, (SV *)cv);
3284 else if (strEQ(s, "END")) {
3287 av_unshift(endav, 1);
3288 av_store(endav, 0, (SV *)cv);
3299 newFORM(floor,op,block)
3310 name = SvPVx(cSVOP->op_sv, na);
3313 gv = gv_fetchpv(name,TRUE, SVt_PVFM);
3315 if (cv = GvFORM(gv)) {
3317 line_t oldline = curcop->cop_line;
3319 curcop->cop_line = copline;
3320 warn("Format %s redefined",name);
3321 curcop->cop_line = oldline;
3327 CvGV(cv) = (GV*)SvREFCNT_inc(gv);
3328 CvFILEGV(cv) = curcop->cop_filegv;
3330 for (ix = AvFILL(comppad); ix > 0; ix--) {
3331 if (!SvPADMY(curpad[ix]) && !SvIMMORTAL(curpad[ix]))
3332 SvPADTMP_on(curpad[ix]);
3335 CvROOT(cv) = newUNOP(OP_LEAVEWRITE, 0, scalarseq(block));
3336 CvSTART(cv) = LINKLIST(CvROOT(cv));
3337 CvROOT(cv)->op_next = 0;
3348 return newUNOP(OP_REFGEN, 0,
3349 mod(list(convert(OP_ANONLIST, 0, op)), OP_REFGEN));
3356 return newUNOP(OP_REFGEN, 0,
3357 mod(list(convert(OP_ANONHASH, 0, op)), OP_REFGEN));
3361 newANONSUB(floor, proto, block)
3366 return newUNOP(OP_REFGEN, 0,
3367 newSVOP(OP_ANONCODE, 0, (SV*)newSUB(floor, 0, proto, block)));
3374 switch (o->op_type) {
3376 o->op_type = OP_PADAV;
3377 o->op_ppaddr = ppaddr[OP_PADAV];
3378 return ref(newUNOP(OP_RV2AV, 0, scalar(o)), OP_RV2AV);
3381 o->op_type = OP_RV2AV;
3382 o->op_ppaddr = ppaddr[OP_RV2AV];
3387 warn("oops: oopsAV");
3397 switch (o->op_type) {
3400 o->op_type = OP_PADHV;
3401 o->op_ppaddr = ppaddr[OP_PADHV];
3402 return ref(newUNOP(OP_RV2HV, 0, scalar(o)), OP_RV2HV);
3406 o->op_type = OP_RV2HV;
3407 o->op_ppaddr = ppaddr[OP_RV2HV];
3412 warn("oops: oopsHV");
3422 if (o->op_type == OP_PADANY) {
3423 o->op_type = OP_PADAV;
3424 o->op_ppaddr = ppaddr[OP_PADAV];
3427 return newUNOP(OP_RV2AV, 0, scalar(o));
3435 if (type == OP_MAPSTART)
3436 return newUNOP(OP_NULL, 0, o);
3437 return ref(newUNOP(OP_RV2GV, OPf_REF, o), type);
3444 if (o->op_type == OP_PADANY) {
3445 o->op_type = OP_PADHV;
3446 o->op_ppaddr = ppaddr[OP_PADHV];
3449 return newUNOP(OP_RV2HV, 0, scalar(o));
3456 croak("NOT IMPL LINE %d",__LINE__);
3466 return newUNOP(OP_RV2CV, flags, scalar(o));
3473 if (o->op_type == OP_PADANY) {
3474 o->op_type = OP_PADSV;
3475 o->op_ppaddr = ppaddr[OP_PADSV];
3478 return newUNOP(OP_RV2SV, 0, scalar(o));
3481 /* Check routines. */
3490 name = NEWSV(1106,0);
3491 sv_upgrade(name, SVt_PVNV);
3492 sv_setpvn(name, "&", 1);
3495 ix = pad_alloc(op->op_type, SVs_PADMY);
3496 av_store(comppad_name, ix, name);
3497 av_store(comppad, ix, cSVOP->op_sv);
3498 SvPADMY_on(cSVOP->op_sv);
3499 cSVOP->op_sv = Nullsv;
3500 cSVOP->op_targ = ix;
3508 op->op_private = hints;
3516 if (cUNOP->op_first->op_type == OP_CONCAT)
3517 op->op_flags |= OPf_STACKED;
3525 if (op->op_flags & OPf_KIDS) {
3528 OPCODE type = op->op_type;
3529 op = modkids(ck_fun(op), type);
3530 kid = cUNOP->op_first;
3531 newop = kUNOP->op_first->op_sibling;
3533 (newop->op_sibling ||
3534 !(opargs[newop->op_type] & OA_RETSCALAR) ||
3535 newop->op_type == OP_PADAV || newop->op_type == OP_PADHV ||
3536 newop->op_type == OP_RV2AV || newop->op_type == OP_RV2HV)) {
3540 op_free(kUNOP->op_first);
3541 kUNOP->op_first = newop;
3543 op->op_ppaddr = ppaddr[++op->op_type];
3553 if (op->op_flags & OPf_KIDS) {
3554 OP *kid = cUNOP->op_first;
3555 if (kid->op_type == OP_HSLICE)
3556 op->op_private |= OPpSLICE;
3557 else if (kid->op_type != OP_HELEM)
3558 croak("%s argument is not a HASH element or slice",
3559 op_desc[op->op_type]);
3569 I32 type = op->op_type;
3571 if (op->op_flags & OPf_KIDS) {
3572 if (cLISTOP->op_first->op_type == OP_STUB) {
3574 op = newUNOP(type, OPf_SPECIAL,
3575 newGVOP(OP_GV, 0, gv_fetchpv("main'ARGV", TRUE, SVt_PVAV)));
3586 hints |= HINT_BLOCK_SCOPE;
3587 if (op->op_flags & OPf_KIDS) {
3588 SVOP *kid = (SVOP*)cUNOP->op_first;
3591 op->op_flags &= ~OPf_KIDS;
3594 else if (kid->op_type == OP_LINESEQ) {
3597 kid->op_next = op->op_next;
3598 cUNOP->op_first = 0;
3601 Newz(1101, enter, 1, LOGOP);
3602 enter->op_type = OP_ENTERTRY;
3603 enter->op_ppaddr = ppaddr[OP_ENTERTRY];
3604 enter->op_private = 0;
3606 /* establish postfix order */
3607 enter->op_next = (OP*)enter;
3609 op = prepend_elem(OP_LINESEQ, (OP*)enter, (OP*)kid);
3610 op->op_type = OP_LEAVETRY;
3611 op->op_ppaddr = ppaddr[OP_LEAVETRY];
3612 enter->op_other = op;
3618 op = newUNOP(OP_ENTEREVAL, 0, newSVREF(newGVOP(OP_GV, 0, defgv)));
3620 op->op_targ = (PADOFFSET)hints;
3629 if (op->op_flags & OPf_STACKED) {
3631 kid = cUNOP->op_first->op_sibling;
3632 if (kid->op_type == OP_RV2GV)
3645 if (op->op_flags & OPf_KIDS) {
3646 OP *kid = cUNOP->op_first;
3647 if (kid->op_type != OP_HELEM)
3648 croak("%s argument is not a HASH element", op_desc[op->op_type]);
3658 o = fold_constants(o);
3659 if (o->op_type == OP_CONST)
3668 SVOP *kid = (SVOP*)cUNOP->op_first;
3670 op->op_private |= (hints & HINT_STRICT_REFS);
3671 if (kid->op_type == OP_CONST) {
3676 name = SvPV(kid->op_sv, na);
3677 if ((hints & HINT_STRICT_REFS) && (kid->op_private & OPpCONST_BARE)) {
3678 char *badthing = Nullch;
3679 switch (op->op_type) {
3681 badthing = "a SCALAR";
3684 badthing = "an ARRAY";
3687 badthing = "a HASH";
3692 "Can't use bareword (\"%s\") as %s ref while \"strict refs\" in use",
3695 kid->op_type = OP_GV;
3696 iscv = (op->op_type == OP_RV2CV) * 2;
3697 for (gv = 0; !gv; iscv++) {
3699 * This is a little tricky. We only want to add the symbol if we
3700 * didn't add it in the lexer. Otherwise we get duplicate strict
3701 * warnings. But if we didn't add it in the lexer, we must at
3702 * least pretend like we wanted to add it even if it existed before,
3703 * or we get possible typo warnings. OPpCONST_ENTERED says
3704 * whether the lexer already added THIS instance of this symbol.
3706 gv = gv_fetchpv(name,
3707 iscv | !(kid->op_private & OPpCONST_ENTERED),
3710 : op->op_type == OP_RV2SV
3712 : op->op_type == OP_RV2AV
3714 : op->op_type == OP_RV2HV
3718 SvREFCNT_dec(kid->op_sv);
3719 kid->op_sv = SvREFCNT_inc(gv);
3728 I32 type = op->op_type;
3730 if (op->op_flags & OPf_REF)
3733 if (op->op_flags & OPf_KIDS) {
3734 SVOP *kid = (SVOP*)cUNOP->op_first;
3736 if (kid->op_type == OP_CONST && (kid->op_private & OPpCONST_BARE)) {
3737 OP *newop = newGVOP(type, OPf_REF,
3738 gv_fetchpv(SvPVx(kid->op_sv, na), TRUE, SVt_PVIO));
3745 if (type == OP_FTTTY)
3746 return newGVOP(type, OPf_REF, gv_fetchpv("main'STDIN", TRUE,
3749 return newUNOP(type, 0, newSVREF(newGVOP(OP_GV, 0, defgv)));
3762 int type = op->op_type;
3763 register I32 oa = opargs[type] >> OASHIFT;
3765 if (op->op_flags & OPf_STACKED) {
3766 if ((oa & OA_OPTIONAL) && (oa >> 4) && !((oa >> 4) & OA_OPTIONAL))
3769 return no_fh_allowed(op);
3772 if (op->op_flags & OPf_KIDS) {
3773 tokid = &cLISTOP->op_first;
3774 kid = cLISTOP->op_first;
3775 if (kid->op_type == OP_PUSHMARK ||
3776 kid->op_type == OP_NULL && kid->op_targ == OP_PUSHMARK)
3778 tokid = &kid->op_sibling;
3779 kid = kid->op_sibling;
3781 if (!kid && opargs[type] & OA_DEFGV)
3782 *tokid = kid = newSVREF(newGVOP(OP_GV, 0, defgv));
3786 sibl = kid->op_sibling;
3800 if (kid->op_type == OP_CONST &&
3801 (kid->op_private & OPpCONST_BARE)) {
3802 char *name = SvPVx(((SVOP*)kid)->op_sv, na);
3803 OP *newop = newAVREF(newGVOP(OP_GV, 0,
3804 gv_fetchpv(name, TRUE, SVt_PVAV) ));
3806 warn("Array @%s missing the @ in argument %ld of %s()",
3807 name, (long)numargs, op_desc[type]);
3810 kid->op_sibling = sibl;
3813 else if (kid->op_type != OP_RV2AV && kid->op_type != OP_PADAV)
3814 bad_type(numargs, "array", op_desc[op->op_type], kid);
3818 if (kid->op_type == OP_CONST &&
3819 (kid->op_private & OPpCONST_BARE)) {
3820 char *name = SvPVx(((SVOP*)kid)->op_sv, na);
3821 OP *newop = newHVREF(newGVOP(OP_GV, 0,
3822 gv_fetchpv(name, TRUE, SVt_PVHV) ));
3824 warn("Hash %%%s missing the %% in argument %ld of %s()",
3825 name, (long)numargs, op_desc[type]);
3828 kid->op_sibling = sibl;
3831 else if (kid->op_type != OP_RV2HV && kid->op_type != OP_PADHV)
3832 bad_type(numargs, "hash", op_desc[op->op_type], kid);
3837 OP *newop = newUNOP(OP_NULL, 0, kid);
3838 kid->op_sibling = 0;
3840 newop->op_next = newop;
3842 kid->op_sibling = sibl;
3847 if (kid->op_type != OP_GV) {
3848 if (kid->op_type == OP_CONST &&
3849 (kid->op_private & OPpCONST_BARE)) {
3850 OP *newop = newGVOP(OP_GV, 0,
3851 gv_fetchpv(SvPVx(((SVOP*)kid)->op_sv, na), TRUE,
3857 kid->op_sibling = 0;
3858 kid = newUNOP(OP_RV2GV, 0, scalar(kid));
3860 kid->op_sibling = sibl;
3866 mod(scalar(kid), type);
3870 tokid = &kid->op_sibling;
3871 kid = kid->op_sibling;
3873 op->op_private |= numargs;
3875 return too_many_arguments(op,op_desc[op->op_type]);
3878 else if (opargs[type] & OA_DEFGV) {
3880 return newUNOP(type, 0, newSVREF(newGVOP(OP_GV, 0, defgv)));
3884 while (oa & OA_OPTIONAL)
3886 if (oa && oa != OA_LIST)
3887 return too_few_arguments(op,op_desc[op->op_type]);
3896 GV *gv = gv_fetchpv("glob", FALSE, SVt_PVCV);
3898 if (gv && GvIMPORTED_CV(gv)) {
3899 op->op_type = OP_LIST;
3900 op->op_ppaddr = ppaddr[OP_LIST];
3901 op = newUNOP(OP_ENTERSUB, OPf_STACKED,
3902 append_elem(OP_LIST, op,
3903 scalar(newUNOP(OP_RV2CV, 0,
3904 newGVOP(OP_GV, 0, gv)))));
3907 if ((op->op_flags & OPf_KIDS) && !cLISTOP->op_first->op_sibling)
3908 append_elem(OP_GLOB, op, newSVREF(newGVOP(OP_GV, 0, defgv)));
3909 gv = newGVgen("main");
3911 append_elem(OP_GLOB, op, newGVOP(OP_GV, 0, gv));
3922 OPCODE type = op->op_type == OP_GREPSTART ? OP_GREPWHILE : OP_MAPWHILE;
3924 op->op_ppaddr = ppaddr[OP_GREPSTART];
3925 Newz(1101, gwop, 1, LOGOP);
3927 if (op->op_flags & OPf_STACKED) {
3930 kid = cLISTOP->op_first->op_sibling;
3931 for (k = cLISTOP->op_first->op_sibling->op_next; k; k = k->op_next) {
3934 kid->op_next = (OP*)gwop;
3935 op->op_flags &= ~OPf_STACKED;
3937 kid = cLISTOP->op_first->op_sibling;
3938 if (type == OP_MAPWHILE)
3945 kid = cLISTOP->op_first->op_sibling;
3946 if (kid->op_type != OP_NULL)
3947 croak("panic: ck_grep");
3948 kid = kUNOP->op_first;
3950 gwop->op_type = type;
3951 gwop->op_ppaddr = ppaddr[type];
3952 gwop->op_first = listkids(op);
3953 gwop->op_flags |= OPf_KIDS;
3954 gwop->op_private = 1;
3955 gwop->op_other = LINKLIST(kid);
3956 gwop->op_targ = pad_alloc(type, SVs_PADTMP);
3957 kid->op_next = (OP*)gwop;
3959 kid = cLISTOP->op_first->op_sibling;
3960 if (!kid || !kid->op_sibling)
3961 return too_few_arguments(op,op_desc[op->op_type]);
3962 for (kid = kid->op_sibling; kid; kid = kid->op_sibling)
3963 mod(kid, OP_GREPSTART);
3972 if (op->op_flags & OPf_KIDS) {
3973 OP *kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
3974 if (kid && kid->op_type == OP_CONST)
3975 fbm_compile(((SVOP*)kid)->op_sv);
3984 /* XXX length optimization goes here */
3992 OPCODE type = op->op_type;
3993 return modkids(ck_fun(op), type);
4000 OPCODE type = op->op_type;
4001 return refkids(ck_fun(op), type);
4010 kid = cLISTOP->op_first;
4012 op = force_list(op);
4013 kid = cLISTOP->op_first;
4015 if (kid->op_type == OP_PUSHMARK)
4016 kid = kid->op_sibling;
4017 if (kid && op->op_flags & OPf_STACKED)
4018 kid = kid->op_sibling;
4019 else if (kid && !kid->op_sibling) { /* print HANDLE; */
4020 if (kid->op_type == OP_CONST && kid->op_private & OPpCONST_BARE) {
4021 op->op_flags |= OPf_STACKED; /* make it a filehandle */
4022 kid = newUNOP(OP_RV2GV, OPf_REF, scalar(kid));
4023 cLISTOP->op_first->op_sibling = kid;
4024 cLISTOP->op_last = kid;
4025 kid = kid->op_sibling;
4030 append_elem(op->op_type, op, newSVREF(newGVOP(OP_GV, 0, defgv)) );
4036 if (hints & HINT_LOCALE)
4037 op->op_private |= OPpLOCALE;
4051 if (hints & HINT_LOCALE)
4052 op->op_private |= OPpLOCALE;
4064 if (hints & HINT_LOCALE)
4065 op->op_private |= OPpLOCALE;
4075 cPMOP->op_pmflags |= PMf_RUNTIME;
4076 cPMOP->op_pmpermflags |= PMf_RUNTIME;
4091 if (cBINOP->op_first->op_flags & OPf_PARENS) {
4092 op->op_private |= OPpREPEAT_DOLIST;
4093 cBINOP->op_first = force_list(cBINOP->op_first);
4104 if (op->op_flags & OPf_KIDS) { /* Shall we supply missing .pm? */
4105 SVOP *kid = (SVOP*)cUNOP->op_first;
4107 if (kid->op_type == OP_CONST && (kid->op_private & OPpCONST_BARE)) {
4109 for (s = SvPVX(kid->op_sv); *s; s++) {
4110 if (*s == ':' && s[1] == ':') {
4112 Move(s+2, s+1, strlen(s+2)+1, char);
4113 --SvCUR(kid->op_sv);
4116 sv_catpvn(kid->op_sv, ".pm", 3);
4126 croak("NOT IMPL LINE %d",__LINE__);
4136 if (op->op_flags & OPf_KIDS) {
4137 kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4138 if (kid && kid->op_sibling) {
4139 op->op_type = OP_SSELECT;
4140 op->op_ppaddr = ppaddr[OP_SSELECT];
4142 return fold_constants(op);
4146 kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4147 if (kid && kid->op_type == OP_RV2GV)
4148 kid->op_private &= ~HINT_STRICT_REFS;
4156 I32 type = op->op_type;
4158 if (!(op->op_flags & OPf_KIDS)) {
4160 return newUNOP(type, 0,
4161 scalar(newUNOP(OP_RV2AV, 0,
4162 scalar(newGVOP(OP_GV, 0, subline
4164 : gv_fetchpv("ARGV", TRUE, SVt_PVAV) )))));
4166 return scalar(modkids(ck_fun(op), type));
4175 if (hints & HINT_LOCALE)
4176 op->op_private |= OPpLOCALE;
4179 if (op->op_flags & OPf_STACKED) {
4180 OP *kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4182 kid = kUNOP->op_first; /* get past rv2gv */
4184 if (kid->op_type == OP_SCOPE || kid->op_type == OP_LEAVE) {
4186 if (kid->op_type == OP_SCOPE) {
4190 else if (kid->op_type == OP_LEAVE) {
4191 if (op->op_type == OP_SORT) {
4192 null(kid); /* wipe out leave */
4195 for (k = kLISTOP->op_first->op_next; k; k = k->op_next) {
4196 if (k->op_next == kid)
4201 kid->op_next = 0; /* just disconnect the leave */
4202 k = kLISTOP->op_first;
4206 kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4207 null(kid); /* wipe out rv2gv */
4208 if (op->op_type == OP_SORT)
4212 op->op_flags |= OPf_SPECIAL;
4226 if (op->op_flags & OPf_STACKED)
4227 return no_fh_allowed(op);
4229 kid = cLISTOP->op_first;
4230 if (kid->op_type != OP_NULL)
4231 croak("panic: ck_split");
4232 kid = kid->op_sibling;
4233 op_free(cLISTOP->op_first);
4234 cLISTOP->op_first = kid;
4236 cLISTOP->op_first = kid = newSVOP(OP_CONST, 0, newSVpv(" ", 1));
4237 cLISTOP->op_last = kid; /* There was only one element previously */
4240 if (kid->op_type != OP_MATCH) {
4241 OP *sibl = kid->op_sibling;
4242 kid->op_sibling = 0;
4243 kid = pmruntime( newPMOP(OP_MATCH, OPf_SPECIAL), kid, Nullop);
4244 if (cLISTOP->op_first == cLISTOP->op_last)
4245 cLISTOP->op_last = kid;
4246 cLISTOP->op_first = kid;
4247 kid->op_sibling = sibl;
4250 if (pm->op_pmshort && !(pm->op_pmflags & PMf_ALL)) {
4251 SvREFCNT_dec(pm->op_pmshort); /* can't use substring to optimize */
4255 kid->op_type = OP_PUSHRE;
4256 kid->op_ppaddr = ppaddr[OP_PUSHRE];
4259 if (!kid->op_sibling)
4260 append_elem(OP_SPLIT, op, newSVREF(newGVOP(OP_GV, 0, defgv)) );
4262 kid = kid->op_sibling;
4265 if (!kid->op_sibling)
4266 append_elem(OP_SPLIT, op, newSVOP(OP_CONST, 0, newSViv(0)));
4268 kid = kid->op_sibling;
4271 if (kid->op_sibling)
4272 return too_many_arguments(op,op_desc[op->op_type]);
4281 OP *prev = ((cUNOP->op_first->op_sibling)
4282 ? cUNOP : ((UNOP*)cUNOP->op_first))->op_first;
4283 OP *o = prev->op_sibling;
4290 for (cvop = o; cvop->op_sibling; cvop = cvop->op_sibling) ;
4291 if (cvop->op_type == OP_RV2CV) {
4293 op->op_private |= (cvop->op_private & OPpENTERSUB_AMPER);
4294 null(cvop); /* disable rv2cv */
4295 tmpop = (SVOP*)((UNOP*)cvop)->op_first;
4296 if (tmpop->op_type == OP_GV) {
4297 cv = GvCVu(tmpop->op_sv);
4298 if (cv && SvPOK(cv) && !(op->op_private & OPpENTERSUB_AMPER))
4299 proto = SvPV((SV*)cv,na);
4302 op->op_private |= (hints & HINT_STRICT_REFS);
4303 if (perldb && curstash != debstash)
4304 op->op_private |= OPpENTERSUB_DB;
4309 return too_many_arguments(op, CvNAME(cv));
4327 if (o->op_type != OP_REFGEN && o->op_type != OP_UNDEF)
4328 bad_type(arg, "block", CvNAME(cv), o);
4333 if (o->op_type == OP_RV2GV)
4337 o = newUNOP(OP_RV2GV, 0, kid);
4338 o->op_sibling = kid->op_sibling;
4339 kid->op_sibling = 0;
4340 prev->op_sibling = o;
4348 if (o->op_type != OP_RV2GV)
4349 bad_type(arg, "symbol", CvNAME(cv), o);
4352 if (o->op_type != OP_RV2CV)
4353 bad_type(arg, "sub", CvNAME(cv), o);
4356 if (o->op_type != OP_RV2SV && o->op_type != OP_PADSV)
4357 bad_type(arg, "scalar", CvNAME(cv), o);
4360 if (o->op_type != OP_RV2AV && o->op_type != OP_PADAV)
4361 bad_type(arg, "array", CvNAME(cv), o);
4364 if (o->op_type != OP_RV2HV && o->op_type != OP_PADHV)
4365 bad_type(arg, "hash", CvNAME(cv), o);
4369 o = newUNOP(OP_REFGEN, 0, kid);
4370 o->op_sibling = kid->op_sibling;
4371 kid->op_sibling = 0;
4372 prev->op_sibling = o;
4383 croak("Malformed prototype for %s: %s",
4384 CvNAME(cv),SvPV((SV*)cv,na));
4389 mod(o, OP_ENTERSUB);
4393 if (proto && !optional && *proto == '$')
4394 return too_few_arguments(op, CvNAME(cv));
4402 SvREADONLY_on(cSVOP->op_sv);
4410 if (op->op_flags & OPf_KIDS) {
4411 SVOP *kid = (SVOP*)cUNOP->op_first;
4413 if (kid->op_type == OP_NULL)
4414 kid = (SVOP*)kid->op_sibling;
4416 kid->op_type == OP_CONST && (kid->op_private & OPpCONST_BARE))
4417 op->op_flags |= OPf_SPECIAL;
4422 /* A peephole optimizer. We visit the ops in the order they're to execute. */
4428 register OP* oldop = 0;
4429 if (!o || o->op_seq)
4434 for (; o; o = o->op_next) {
4440 switch (o->op_type) {
4443 curcop = ((COP*)o); /* for warnings */
4444 o->op_seq = op_seqmax++;
4455 if (o->op_next->op_type == OP_STRINGIFY)
4457 o->op_seq = op_seqmax++;
4460 if ((o->op_flags & (OPf_KNOW|OPf_LIST)) != (OPf_KNOW|OPf_LIST)) {
4461 o->op_seq = op_seqmax++;
4462 break; /* Scalar stub must produce undef. List stub is noop */
4466 if (o->op_targ == OP_NEXTSTATE || o->op_targ == OP_DBSTATE)
4467 curcop = ((COP*)op);
4473 if (oldop && o->op_next) {
4474 oldop->op_next = o->op_next;
4477 o->op_seq = op_seqmax++;
4481 if (o->op_next->op_type == OP_RV2SV) {
4482 if (!(o->op_next->op_private & OPpDEREF)) {
4484 o->op_private |= o->op_next->op_private & OPpLVAL_INTRO;
4485 o->op_next = o->op_next->op_next;
4486 o->op_type = OP_GVSV;
4487 o->op_ppaddr = ppaddr[OP_GVSV];
4490 else if (o->op_next->op_type == OP_RV2AV) {
4491 OP* pop = o->op_next->op_next;
4493 if (pop->op_type == OP_CONST &&
4494 (op = pop->op_next) &&
4495 pop->op_next->op_type == OP_AELEM &&
4496 !(pop->op_next->op_private & (OPpDEREF|OPpLVAL_INTRO)) &&
4497 (i = SvIV(((SVOP*)pop)->op_sv) - compiling.cop_arybase)
4501 SvREFCNT_dec(((SVOP*)pop)->op_sv);
4505 o->op_flags |= pop->op_next->op_flags & OPf_MOD;
4506 o->op_next = pop->op_next->op_next;
4507 o->op_type = OP_AELEMFAST;
4508 o->op_ppaddr = ppaddr[OP_AELEMFAST];
4509 o->op_private = (U8)i;
4510 GvAVn(((GVOP*)o)->op_gv);
4513 o->op_seq = op_seqmax++;
4520 o->op_seq = op_seqmax++;
4521 peep(cLOGOP->op_other);
4525 o->op_seq = op_seqmax++;
4526 peep(cCONDOP->op_true);
4527 peep(cCONDOP->op_false);
4531 o->op_seq = op_seqmax++;
4532 peep(cLOOP->op_redoop);
4533 peep(cLOOP->op_nextop);
4534 peep(cLOOP->op_lastop);
4539 o->op_seq = op_seqmax++;
4540 peep(cPMOP->op_pmreplstart);
4544 o->op_seq = op_seqmax++;
4545 if (dowarn && o->op_next && o->op_next->op_type == OP_NEXTSTATE) {
4546 if (o->op_next->op_sibling &&
4547 o->op_next->op_sibling->op_type != OP_DIE) {
4548 line_t oldline = curcop->cop_line;
4550 curcop->cop_line = ((COP*)o->op_next)->cop_line;
4551 warn("Statement unlikely to be reached");
4552 warn("(Maybe you meant system() when you said exec()?)\n");
4553 curcop->cop_line = oldline;
4558 o->op_seq = op_seqmax++;