3 * Copyright (c) 1991-1994, Larry Wall
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
11 * "You see: Mr. Drogo, he married poor Miss Primula Brandybuck. She was
12 * our Mr. Bilbo's first cousin on the mother's side (her mother being the
13 * youngest of the Old Took's daughters); and Mr. Drogo was his second
14 * cousin. So Mr. Frodo is his first *and* second cousin, once removed
15 * either way, as the saying is, if you follow me." --the Gaffer
21 #define USE_OP_MASK /* Turned on by default in 5.002beta1h */
25 * In the following definition, the ", (OP *) op" is just to make the compiler
26 * think the expression is of the right type: croak actually does a Siglongjmp.
28 #define CHECKOP(type,op) \
29 ((op_mask && op_mask[type]) \
30 ? ( op_free((OP*)op), \
31 croak("%s trapped by operation mask", op_desc[type]), \
33 : (*check[type])((OP*)op))
35 #define CHECKOP(type,op) (*check[type])(op)
36 #endif /* USE_OP_MASK */
38 static I32 list_assignment _((OP *op));
39 static OP *bad_type _((I32 n, char *t, char *name, OP *kid));
40 static OP *modkids _((OP *op, I32 type));
41 static OP *no_fh_allowed _((OP *op));
42 static OP *scalarboolean _((OP *op));
43 static OP *too_few_arguments _((OP *op, char* name));
44 static OP *too_many_arguments _((OP *op, char* name));
45 static void null _((OP* op));
46 static PADOFFSET pad_findlex _((char* name, PADOFFSET newoff, U32 seq,
47 CV* startcv, I32 cx_ix));
53 SV* tmpsv = sv_newmortal();
54 gv_efullname3(tmpsv, CvGV(cv), Nullch);
55 return SvPV(tmpsv,na);
62 sprintf(tokenbuf,"Missing comma after first argument to %s function",
63 op_desc[op->op_type]);
69 too_few_arguments(op, name)
73 sprintf(tokenbuf,"Not enough arguments for %s", name);
79 too_many_arguments(op, name)
83 sprintf(tokenbuf,"Too many arguments for %s", name);
89 bad_type(n, t, name, kid)
95 sprintf(tokenbuf, "Type of arg %d to %s must be %s (not %s)",
96 (int) n, name, t, op_desc[kid->op_type]);
105 int type = op->op_type;
106 if (type != OP_AELEM && type != OP_HELEM) {
107 sprintf(tokenbuf, "Can't use subscript on %s", op_desc[type]);
109 if (type == OP_ENTERSUB || type == OP_RV2HV || type == OP_PADHV)
110 warn("(Did you mean $ or @ instead of %c?)\n",
111 type == OP_ENTERSUB ? '&' : '%');
115 /* "register" allocation */
124 if (!(isALPHA(name[1]) || name[1] == '_' && (int)strlen(name) > 2)) {
125 if (!isPRINT(name[1]))
126 sprintf(name+1, "^%c", toCTRL(name[1])); /* XXX tokenbuf, really */
127 croak("Can't use global %s in \"my\"",name);
129 if (AvFILL(comppad_name) >= 0) {
130 SV **svp = AvARRAY(comppad_name);
131 for (off = AvFILL(comppad_name); off > comppad_name_floor; off--) {
134 && SvIVX(sv) == 999999999 /* var is in open scope */
135 && strEQ(name, SvPVX(sv)))
137 warn("\"my\" variable %s masks earlier declaration in same scope", name);
142 off = pad_alloc(OP_PADSV, SVs_PADMY);
144 sv_upgrade(sv, SVt_PVNV);
146 av_store(comppad_name, off, sv);
147 SvNVX(sv) = (double)999999999;
148 SvIVX(sv) = 0; /* Not yet introduced--see newSTATEOP */
149 if (!min_intro_pending)
150 min_intro_pending = off;
151 max_intro_pending = off;
153 av_store(comppad, off, (SV*)newAV());
154 else if (*name == '%')
155 av_store(comppad, off, (SV*)newHV());
156 SvPADMY_on(curpad[off]);
161 #ifndef CAN_PROTOTYPE
162 pad_findlex(name, newoff, seq, startcv, cx_ix)
169 pad_findlex(char *name, PADOFFSET newoff, U32 seq, CV* startcv, I32 cx_ix)
176 register CONTEXT *cx;
179 for (cv = startcv; cv; cv = CvOUTSIDE(cv)) {
180 AV* curlist = CvPADLIST(cv);
181 SV** svp = av_fetch(curlist, 0, FALSE);
183 if (!svp || *svp == &sv_undef)
186 svp = AvARRAY(curname);
187 for (off = AvFILL(curname); off > 0; off--) {
188 if ((sv = svp[off]) &&
191 seq > I_32(SvNVX(sv)) &&
192 strEQ(SvPVX(sv), name))
200 if (newoff && !CvUNIQUE(cv))
201 return 0; /* don't clone inactive sub's stack frame */
204 oldpad = (AV*)*av_fetch(curlist, depth, FALSE);
205 oldsv = *av_fetch(oldpad, off, TRUE);
206 if (!newoff) { /* Not a mere clone operation. */
207 SV *sv = NEWSV(1103,0);
208 newoff = pad_alloc(OP_PADSV, SVs_PADMY);
209 sv_upgrade(sv, SVt_PVNV);
211 av_store(comppad_name, newoff, sv);
212 SvNVX(sv) = (double)curcop->cop_seq;
213 SvIVX(sv) = 999999999; /* A ref, intro immediately */
214 SvFLAGS(sv) |= SVf_FAKE;
215 if (CvANON(compcv) || CvFORMAT(compcv)) {
216 /* "It's closures all the way down." */
221 bcv && bcv != cv && !CvCLONE(bcv);
222 bcv = CvOUTSIDE(bcv)) {
228 "Variable \"%s\" may be unavailable",
235 else if (!CvUNIQUE(compcv)) {
236 if (dowarn && !CvUNIQUE(cv))
237 warn("Variable \"%s\" will not stay shared", name);
240 av_store(comppad, newoff, SvREFCNT_inc(oldsv));
246 /* Nothing in current lexical context--try eval's context, if any.
247 * This is necessary to let the perldb get at lexically scoped variables.
248 * XXX This will also probably interact badly with eval tree caching.
252 for (i = cx_ix; i >= 0; i--) {
254 switch (cx->cx_type) {
256 if (i == 0 && saweval) {
257 seq = cxstack[saweval].blk_oldcop->cop_seq;
258 return pad_findlex(name, newoff, seq, main_cv, 0);
262 switch (cx->blk_eval.old_op_type) {
267 /* require must have its own scope */
275 if (debstash && CvSTASH(cv) == debstash) { /* ignore DB'* scope */
276 saweval = i; /* so we know where we were called from */
279 seq = cxstack[saweval].blk_oldcop->cop_seq;
280 return pad_findlex(name, newoff, seq, cv, i-1);
293 SV **svp = AvARRAY(comppad_name);
294 U32 seq = cop_seqmax;
296 /* The one we're looking for is probably just before comppad_name_fill. */
297 for (off = AvFILL(comppad_name); off > 0; off--) {
298 if ((sv = svp[off]) &&
301 seq > I_32(SvNVX(sv)) &&
302 strEQ(SvPVX(sv), name))
304 return (PADOFFSET)off;
308 /* See if it's in a nested scope */
309 off = pad_findlex(name, 0, seq, CvOUTSIDE(compcv), cxstack_ix);
321 SV **svp = AvARRAY(comppad_name);
323 if (min_intro_pending && fill < min_intro_pending) {
324 for (off = max_intro_pending; off >= min_intro_pending; off--) {
325 if ((sv = svp[off]) && sv != &sv_undef)
326 warn("%s never introduced", SvPVX(sv));
329 /* "Deintroduce" my variables that are leaving with this scope. */
330 for (off = AvFILL(comppad_name); off > fill; off--) {
331 if ((sv = svp[off]) && sv != &sv_undef && SvIVX(sv) == 999999999)
332 SvIVX(sv) = cop_seqmax;
337 pad_alloc(optype,tmptype)
344 if (AvARRAY(comppad) != curpad)
345 croak("panic: pad_alloc");
346 if (pad_reset_pending)
348 if (tmptype & SVs_PADMY) {
350 sv = *av_fetch(comppad, AvFILL(comppad) + 1, TRUE);
351 } while (SvPADBUSY(sv)); /* need a fresh one */
352 retval = AvFILL(comppad);
355 SV **names = AvARRAY(comppad_name);
356 SSize_t names_fill = AvFILL(comppad_name);
359 * "foreach" index vars temporarily become aliases to non-"my"
360 * values. Thus we must skip, not just pad values that are
361 * marked as current pad values, but also those with names.
363 if (++padix <= names_fill &&
364 (sv = names[padix]) && sv != &sv_undef)
366 sv = *av_fetch(comppad, padix, TRUE);
367 if (!(SvFLAGS(sv) & (SVs_PADTMP|SVs_PADMY)))
372 SvFLAGS(sv) |= tmptype;
373 curpad = AvARRAY(comppad);
374 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad alloc %ld for %s\n", (long) retval, op_name[optype]));
375 return (PADOFFSET)retval;
379 #ifndef CAN_PROTOTYPE
384 #endif /* CAN_PROTOTYPE */
387 croak("panic: pad_sv po");
388 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad sv %d\n", po));
389 return curpad[po]; /* eventually we'll turn this into a macro */
393 #ifndef CAN_PROTOTYPE
397 pad_free(PADOFFSET po)
398 #endif /* CAN_PROTOTYPE */
402 if (AvARRAY(comppad) != curpad)
403 croak("panic: pad_free curpad");
405 croak("panic: pad_free po");
406 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad free %d\n", po));
407 if (curpad[po] && curpad[po] != &sv_undef)
408 SvPADTMP_off(curpad[po]);
414 #ifndef CAN_PROTOTYPE
418 pad_swipe(PADOFFSET po)
419 #endif /* CAN_PROTOTYPE */
421 if (AvARRAY(comppad) != curpad)
422 croak("panic: pad_swipe curpad");
424 croak("panic: pad_swipe po");
425 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad swipe %d\n", po));
426 SvPADTMP_off(curpad[po]);
427 curpad[po] = NEWSV(1107,0);
428 SvPADTMP_on(curpad[po]);
438 if (AvARRAY(comppad) != curpad)
439 croak("panic: pad_reset curpad");
440 DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad reset\n"));
441 if (!tainting) { /* Can't mix tainted and non-tainted temporaries. */
442 for (po = AvMAX(comppad); po > padix_floor; po--) {
443 if (curpad[po] && curpad[po] != &sv_undef)
444 SvPADTMP_off(curpad[po]);
448 pad_reset_pending = FALSE;
457 register OP *kid, *nextkid;
459 if (!op || op->op_seq == (U16)-1)
462 if (op->op_flags & OPf_KIDS) {
463 for (kid = cUNOP->op_first; kid; kid = nextkid) {
464 nextkid = kid->op_sibling; /* Get before next freeing kid */
469 switch (op->op_type) {
471 op->op_targ = 0; /* Was holding old type, if any. */
474 op->op_targ = 0; /* Was holding hints. */
477 if (!(op->op_flags & OPf_REF) || (check[op->op_type] != ck_ftst))
483 SvREFCNT_dec(cGVOP->op_gv);
487 Safefree(cCOP->cop_label);
488 SvREFCNT_dec(cCOP->cop_filegv);
491 SvREFCNT_dec(cSVOP->op_sv);
497 if (op->op_flags & (OPf_SPECIAL|OPf_STACKED|OPf_KIDS))
501 Safefree(cPVOP->op_pv);
504 op_free(cPMOP->op_pmreplroot);
508 pregfree(cPMOP->op_pmregexp);
509 SvREFCNT_dec(cPMOP->op_pmshort);
514 pad_free(op->op_targ);
523 if (op->op_type != OP_NULL && op->op_targ > 0)
524 pad_free(op->op_targ);
525 op->op_targ = op->op_type;
526 op->op_type = OP_NULL;
527 op->op_ppaddr = ppaddr[OP_NULL];
530 /* Contextualizers */
532 #define LINKLIST(o) ((o)->op_next ? (o)->op_next : linklist((OP*)o))
543 /* establish postfix order */
544 if (cUNOP->op_first) {
545 op->op_next = LINKLIST(cUNOP->op_first);
546 for (kid = cUNOP->op_first; kid; kid = kid->op_sibling) {
548 kid->op_next = LINKLIST(kid->op_sibling);
564 if (op && op->op_flags & OPf_KIDS) {
565 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
576 op->op_type == OP_SASSIGN && cBINOP->op_first->op_type == OP_CONST) {
577 line_t oldline = curcop->cop_line;
579 if (copline != NOLINE)
580 curcop->cop_line = copline;
581 warn("Found = in conditional, should be ==");
582 curcop->cop_line = oldline;
593 /* assumes no premature commitment */
594 if (!op || (op->op_flags & OPf_KNOW) || op->op_type == OP_RETURN
598 op->op_flags &= ~OPf_LIST;
599 op->op_flags |= OPf_KNOW;
601 switch (op->op_type) {
603 if (op->op_private & OPpREPEAT_DOLIST)
604 null(((LISTOP*)cBINOP->op_first)->op_first);
605 scalar(cBINOP->op_first);
610 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
614 if ((kid = ((LISTOP*)op)->op_first) && kid->op_type == OP_PUSHRE) {
615 if (!kPMOP->op_pmreplroot)
616 deprecate("implicit split to @_");
623 if (op->op_flags & OPf_KIDS) {
624 for (kid = cUNOP->op_first; kid; kid = kid->op_sibling)
630 scalar(cLISTOP->op_first);
635 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling) {
655 if (!op || error_count)
657 if (op->op_flags & OPf_LIST)
660 op->op_flags |= OPf_KNOW;
662 switch (op->op_type) {
664 if (!(opargs[op->op_type] & OA_FOLDCONST))
668 if (op->op_flags & OPf_STACKED)
741 if (!(op->op_private & OPpLVAL_INTRO))
742 useless = op_desc[op->op_type];
749 if (!(op->op_private & OPpLVAL_INTRO) &&
750 (!op->op_sibling || op->op_sibling->op_type != OP_READLINE))
751 useless = "a variable";
756 curcop = ((COP*)op); /* for warning below */
762 useless = "a constant";
763 if (SvNIOK(sv) && (SvNV(sv) == 0.0 || SvNV(sv) == 1.0))
765 else if (SvPOK(sv)) {
766 if (strnEQ(SvPVX(sv), "di", 2) ||
767 strnEQ(SvPVX(sv), "ds", 2) ||
768 strnEQ(SvPVX(sv), "ig", 2))
772 null(op); /* don't execute a constant */
773 SvREFCNT_dec(sv); /* don't even remember it */
777 op->op_type = OP_PREINC; /* pre-increment is faster */
778 op->op_ppaddr = ppaddr[OP_PREINC];
782 op->op_type = OP_PREDEC; /* pre-decrement is faster */
783 op->op_ppaddr = ppaddr[OP_PREDEC];
789 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
793 if (op->op_targ == OP_NEXTSTATE || op->op_targ == OP_DBSTATE)
794 curcop = ((COP*)op); /* for warning below */
795 if (op->op_flags & OPf_STACKED)
800 if (!(op->op_flags & OPf_KIDS))
806 op->op_private |= OPpLEAVE_VOID;
809 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
813 if ((kid = ((LISTOP*)op)->op_first) && kid->op_type == OP_PUSHRE) {
814 if (!kPMOP->op_pmreplroot)
815 deprecate("implicit split to @_");
819 op->op_private |= OPpLEAVE_VOID;
822 if (useless && dowarn)
823 warn("Useless use of %s in void context", useless);
832 if (op && op->op_flags & OPf_KIDS) {
833 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
845 /* assumes no premature commitment */
846 if (!op || (op->op_flags & OPf_KNOW) || op->op_type == OP_RETURN
850 op->op_flags |= (OPf_KNOW | OPf_LIST);
852 switch (op->op_type) {
855 list(cBINOP->op_first);
860 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
867 if (!(op->op_flags & OPf_KIDS))
869 if (!op->op_next && cUNOP->op_first->op_type == OP_FLOP) {
870 list(cBINOP->op_first);
871 return gen_constant_list(op);
878 list(cLISTOP->op_first);
882 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling) {
901 if (op->op_type == OP_LINESEQ ||
902 op->op_type == OP_SCOPE ||
903 op->op_type == OP_LEAVE ||
904 op->op_type == OP_LEAVETRY)
906 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling) {
907 if (kid->op_sibling) {
913 op->op_flags &= ~OPf_PARENS;
914 if (hints & HINT_BLOCK_SCOPE)
915 op->op_flags |= OPf_PARENS;
918 op = newOP(OP_STUB, 0);
928 if (op && op->op_flags & OPf_KIDS) {
929 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
945 if (!op || error_count)
948 switch (op->op_type) {
950 if (!(op->op_private & (OPpCONST_ARYBASE)))
952 if (eval_start && eval_start->op_type == OP_CONST) {
953 compiling.cop_arybase = (I32)SvIV(((SVOP*)eval_start)->op_sv);
957 SAVEI32(compiling.cop_arybase);
958 compiling.cop_arybase = 0;
960 else if (type == OP_REFGEN)
963 croak("That use of $[ is unsupported");
966 if (op->op_flags & OPf_PARENS)
970 if ((type == OP_UNDEF || type == OP_REFGEN) &&
971 !(op->op_flags & OPf_STACKED)) {
972 op->op_type = OP_RV2CV; /* entersub => rv2cv */
973 op->op_ppaddr = ppaddr[OP_RV2CV];
974 assert(cUNOP->op_first->op_type == OP_NULL);
975 null(((LISTOP*)cUNOP->op_first)->op_first); /* disable pushmark */
981 /* grep, foreach, subcalls, refgen */
982 if (type == OP_GREPSTART || type == OP_ENTERSUB || type == OP_REFGEN)
984 sprintf(tokenbuf, "Can't modify %s in %s",
985 op_desc[op->op_type],
986 type ? op_desc[type] : "local");
1001 case OP_RIGHT_SHIFT:
1010 if (!(op->op_flags & OPf_STACKED))
1016 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
1022 if (type == OP_REFGEN && op->op_flags & OPf_PARENS) {
1024 return op; /* Treat \(@foo) like ordinary list. */
1028 ref(cUNOP->op_first, op->op_type);
1040 if (!type && cUNOP->op_first->op_type != OP_GV)
1041 croak("Can't localize a reference");
1042 ref(cUNOP->op_first, op->op_type);
1055 if (type == OP_REFGEN && op->op_flags & OPf_PARENS)
1056 return op; /* Treat \(@foo) like ordinary list. */
1061 croak("Can't localize lexical variable %s",
1062 SvPV(*av_fetch(comppad_name, op->op_targ, 4), na));
1069 if (type != OP_SASSIGN)
1075 pad_free(op->op_targ);
1076 op->op_targ = pad_alloc(op->op_type, SVs_PADMY);
1077 assert(SvTYPE(PAD_SV(op->op_targ)) == SVt_NULL);
1078 if (op->op_flags & OPf_KIDS)
1079 mod(cBINOP->op_first->op_sibling, type);
1084 ref(cBINOP->op_first, op->op_type);
1091 if (op->op_flags & OPf_KIDS)
1092 mod(cLISTOP->op_last, type);
1096 if (!(op->op_flags & OPf_KIDS))
1098 if (op->op_targ != OP_LIST) {
1099 mod(cBINOP->op_first, type);
1104 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
1108 op->op_flags |= OPf_MOD;
1110 if (type == OP_AASSIGN || type == OP_SASSIGN)
1111 op->op_flags |= OPf_SPECIAL|OPf_REF;
1113 op->op_private |= OPpLVAL_INTRO;
1114 op->op_flags &= ~OPf_SPECIAL;
1116 else if (type != OP_GREPSTART && type != OP_ENTERSUB)
1117 op->op_flags |= OPf_REF;
1127 if (op && op->op_flags & OPf_KIDS) {
1128 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
1141 if (!op || error_count)
1144 switch (op->op_type) {
1146 if ((type == OP_DEFINED) &&
1147 !(op->op_flags & OPf_STACKED)) {
1148 op->op_type = OP_RV2CV; /* entersub => rv2cv */
1149 op->op_ppaddr = ppaddr[OP_RV2CV];
1150 assert(cUNOP->op_first->op_type == OP_NULL);
1151 null(((LISTOP*)cUNOP->op_first)->op_first); /* disable pushmark */
1152 op->op_flags |= OPf_SPECIAL;
1157 for (kid = cUNOP->op_first->op_sibling; kid; kid = kid->op_sibling)
1161 ref(cUNOP->op_first, op->op_type);
1164 if (type == OP_RV2SV || type == OP_RV2AV || type == OP_RV2HV) {
1165 op->op_private |= (type == OP_RV2AV ? OPpDEREF_AV
1166 : type == OP_RV2HV ? OPpDEREF_HV
1168 op->op_flags |= OPf_MOD;
1174 op->op_flags |= OPf_REF;
1177 ref(cUNOP->op_first, op->op_type);
1182 op->op_flags |= OPf_REF;
1187 if (!(op->op_flags & OPf_KIDS))
1189 ref(cBINOP->op_first, type);
1193 ref(cBINOP->op_first, op->op_type);
1194 if (type == OP_RV2SV || type == OP_RV2AV || type == OP_RV2HV) {
1195 op->op_private |= (type == OP_RV2AV ? OPpDEREF_AV
1196 : type == OP_RV2HV ? OPpDEREF_HV
1198 op->op_flags |= OPf_MOD;
1206 if (!(op->op_flags & OPf_KIDS))
1208 ref(cLISTOP->op_last, type);
1224 if (!op || error_count)
1228 if (type == OP_LIST) {
1229 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
1232 else if (type != OP_PADSV &&
1235 type != OP_PUSHMARK)
1237 sprintf(tokenbuf, "Can't declare %s in my", op_desc[op->op_type]);
1241 op->op_flags |= OPf_MOD;
1242 op->op_private |= OPpLVAL_INTRO;
1251 o->op_flags |= OPf_PARENS;
1256 bind_match(type, left, right)
1263 if (right->op_type == OP_MATCH ||
1264 right->op_type == OP_SUBST ||
1265 right->op_type == OP_TRANS) {
1266 right->op_flags |= OPf_STACKED;
1267 if (right->op_type != OP_MATCH)
1268 left = mod(left, right->op_type);
1269 if (right->op_type == OP_TRANS)
1270 op = newBINOP(OP_NULL, OPf_STACKED, scalar(left), right);
1272 op = prepend_elem(right->op_type, scalar(left), right);
1274 return newUNOP(OP_NOT, 0, scalar(op));
1278 return bind_match(type, left,
1279 pmruntime(newPMOP(OP_MATCH, 0), right, Nullop));
1288 /* XXX need to optimize away NOT NOT here? Or do we let optimizer do it? */
1289 return newUNOP(OP_NOT, OPf_SPECIAL, scalar(op));
1297 if (o->op_flags & OPf_PARENS || perldb || tainting) {
1298 o = prepend_elem(OP_LINESEQ, newOP(OP_ENTER, 0), o);
1299 o->op_type = OP_LEAVE;
1300 o->op_ppaddr = ppaddr[OP_LEAVE];
1303 if (o->op_type == OP_LINESEQ) {
1305 o->op_type = OP_SCOPE;
1306 o->op_ppaddr = ppaddr[OP_SCOPE];
1307 kid = ((LISTOP*)o)->op_first;
1308 if (kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE){
1309 SvREFCNT_dec(((COP*)kid)->cop_filegv);
1314 o = newLISTOP(OP_SCOPE, 0, o, Nullop);
1324 int retval = savestack_ix;
1325 SAVEI32(comppad_name_floor);
1327 if ((comppad_name_fill = AvFILL(comppad_name)) > 0)
1328 comppad_name_floor = comppad_name_fill;
1330 comppad_name_floor = 0;
1332 SAVEI32(min_intro_pending);
1333 SAVEI32(max_intro_pending);
1334 min_intro_pending = 0;
1335 SAVEI32(comppad_name_fill);
1336 SAVEI32(padix_floor);
1337 padix_floor = padix;
1338 pad_reset_pending = FALSE;
1340 hints &= ~HINT_BLOCK_SCOPE;
1345 block_end(floor, seq)
1349 int needblockscope = hints & HINT_BLOCK_SCOPE;
1350 OP* retval = scalarseq(seq);
1352 pad_reset_pending = FALSE;
1354 hints |= HINT_BLOCK_SCOPE; /* propagate out */
1355 pad_leavemy(comppad_name_fill);
1365 eval_root = newUNOP(OP_LEAVEEVAL, ((in_eval & 4) ? OPf_SPECIAL : 0), op);
1366 eval_start = linklist(eval_root);
1367 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;
1390 if (o->op_flags & OPf_PARENS)
1394 if (dowarn && bufptr > oldbufptr && bufptr[-1] == ',') {
1396 for (s = bufptr; *s && (isALNUM(*s) || strchr("@$%, ",*s)); s++) ;
1397 if (*s == ';' || *s == '=')
1398 warn("Parens missing around \"%s\" list", lex ? "my" : "local");
1405 return mod(o, OP_NULL); /* a bit kludgey */
1412 if (o->op_type == OP_LIST) {
1413 o = convert(OP_JOIN, 0,
1414 prepend_elem(OP_LIST,
1415 newSVREF(newGVOP(OP_GV, 0, gv_fetchpv(";", TRUE, SVt_PV))),
1426 I32 type = o->op_type;
1429 if (opargs[type] & OA_RETSCALAR)
1431 if (opargs[type] & OA_TARGET)
1432 o->op_targ = pad_alloc(type, SVs_PADTMP);
1434 if ((opargs[type] & OA_OTHERINT) && (hints & HINT_INTEGER))
1435 o->op_ppaddr = ppaddr[type = ++(o->op_type)];
1437 if (!(opargs[type] & OA_FOLDCONST))
1441 goto nope; /* Don't try to run w/ errors */
1443 for (curop = LINKLIST(o); curop != o; curop = LINKLIST(curop)) {
1444 if (curop->op_type != OP_CONST &&
1445 curop->op_type != OP_LIST &&
1446 curop->op_type != OP_SCALAR &&
1447 curop->op_type != OP_NULL &&
1448 curop->op_type != OP_PUSHMARK) {
1453 curop = LINKLIST(o);
1458 if (o->op_targ && sv == PAD_SV(o->op_targ)) /* grab pad temp? */
1459 pad_swipe(o->op_targ);
1460 else if (SvTEMP(sv)) { /* grab mortal temp? */
1461 (void)SvREFCNT_inc(sv);
1465 if (type == OP_RV2GV)
1466 return newGVOP(OP_GV, 0, (GV*)sv);
1468 if ((SvFLAGS(sv) & (SVf_IOK|SVf_NOK|SVf_POK)) == SVf_NOK) {
1470 if ((double)iv == SvNV(sv)) { /* can we smush double to int */
1475 SvIOK_off(sv); /* undo SvIV() damage */
1477 return newSVOP(OP_CONST, 0, sv);
1481 if (!(opargs[type] & OA_OTHERINT))
1484 if (!(hints & HINT_INTEGER)) {
1485 if (type == OP_DIVIDE || !(o->op_flags & OPf_KIDS))
1488 for (curop = ((UNOP*)o)->op_first; curop; curop = curop->op_sibling) {
1489 if (curop->op_type == OP_CONST) {
1490 if (SvIOK(((SVOP*)curop)->op_sv))
1494 if (opargs[curop->op_type] & OA_RETINTEGER)
1498 o->op_ppaddr = ppaddr[++(o->op_type)];
1505 gen_constant_list(o)
1509 I32 oldtmps_floor = tmps_floor;
1513 return o; /* Don't attempt to run with errors */
1515 op = curop = LINKLIST(o);
1521 tmps_floor = oldtmps_floor;
1523 o->op_type = OP_RV2AV;
1524 o->op_ppaddr = ppaddr[OP_RV2AV];
1525 curop = ((UNOP*)o)->op_first;
1526 ((UNOP*)o)->op_first = newSVOP(OP_CONST, 0, SvREFCNT_inc(*stack_sp--));
1533 convert(type, flags, op)
1541 if (!op || op->op_type != OP_LIST)
1542 op = newLISTOP(OP_LIST, 0, op, Nullop);
1544 op->op_flags &= ~(OPf_KNOW|OPf_LIST);
1546 if (!(opargs[type] & OA_MARK))
1547 null(cLISTOP->op_first);
1550 op->op_ppaddr = ppaddr[type];
1551 op->op_flags |= flags;
1553 op = CHECKOP(type, op);
1554 if (op->op_type != type)
1557 if (cLISTOP->op_children < 7) {
1558 /* XXX do we really need to do this if we're done appending?? */
1559 for (kid = cLISTOP->op_first; kid; kid = kid->op_sibling)
1561 cLISTOP->op_last = last; /* in case check substituted last arg */
1564 return fold_constants(op);
1567 /* List constructors */
1570 append_elem(type, first, last)
1581 if (first->op_type != type || type==OP_LIST && first->op_flags & OPf_PARENS)
1582 return newLISTOP(type, 0, first, last);
1584 if (first->op_flags & OPf_KIDS)
1585 ((LISTOP*)first)->op_last->op_sibling = last;
1587 first->op_flags |= OPf_KIDS;
1588 ((LISTOP*)first)->op_first = last;
1590 ((LISTOP*)first)->op_last = last;
1591 ((LISTOP*)first)->op_children++;
1596 append_list(type, first, last)
1607 if (first->op_type != type)
1608 return prepend_elem(type, (OP*)first, (OP*)last);
1610 if (last->op_type != type)
1611 return append_elem(type, (OP*)first, (OP*)last);
1613 first->op_last->op_sibling = last->op_first;
1614 first->op_last = last->op_last;
1615 first->op_children += last->op_children;
1616 if (first->op_children)
1617 last->op_flags |= OPf_KIDS;
1624 prepend_elem(type, first, last)
1635 if (last->op_type == type) {
1636 if (type == OP_LIST) { /* already a PUSHMARK there */
1637 first->op_sibling = ((LISTOP*)last)->op_first->op_sibling;
1638 ((LISTOP*)last)->op_first->op_sibling = first;
1641 if (!(last->op_flags & OPf_KIDS)) {
1642 ((LISTOP*)last)->op_last = first;
1643 last->op_flags |= OPf_KIDS;
1645 first->op_sibling = ((LISTOP*)last)->op_first;
1646 ((LISTOP*)last)->op_first = first;
1648 ((LISTOP*)last)->op_children++;
1652 return newLISTOP(type, 0, first, last);
1660 return newOP(OP_STUB, 0);
1667 if (!op || op->op_type != OP_LIST)
1668 op = newLISTOP(OP_LIST, 0, op, Nullop);
1674 newLISTOP(type, flags, first, last)
1682 Newz(1101, listop, 1, LISTOP);
1684 listop->op_type = type;
1685 listop->op_ppaddr = ppaddr[type];
1686 listop->op_children = (first != 0) + (last != 0);
1687 listop->op_flags = flags;
1691 else if (!first && last)
1694 first->op_sibling = last;
1695 listop->op_first = first;
1696 listop->op_last = last;
1697 if (type == OP_LIST) {
1699 pushop = newOP(OP_PUSHMARK, 0);
1700 pushop->op_sibling = first;
1701 listop->op_first = pushop;
1702 listop->op_flags |= OPf_KIDS;
1704 listop->op_last = pushop;
1706 else if (listop->op_children)
1707 listop->op_flags |= OPf_KIDS;
1718 Newz(1101, op, 1, OP);
1720 op->op_ppaddr = ppaddr[type];
1721 op->op_flags = flags;
1724 op->op_private = 0 + (flags >> 8);
1725 if (opargs[type] & OA_RETSCALAR)
1727 if (opargs[type] & OA_TARGET)
1728 op->op_targ = pad_alloc(type, SVs_PADTMP);
1729 return CHECKOP(type, op);
1733 newUNOP(type, flags, first)
1741 first = newOP(OP_STUB, 0);
1742 if (opargs[type] & OA_MARK)
1743 first = force_list(first);
1745 Newz(1101, unop, 1, UNOP);
1746 unop->op_type = type;
1747 unop->op_ppaddr = ppaddr[type];
1748 unop->op_first = first;
1749 unop->op_flags = flags | OPf_KIDS;
1750 unop->op_private = 1 | (flags >> 8);
1752 unop = (UNOP*) CHECKOP(type, unop);
1756 return fold_constants((OP *) unop);
1760 newBINOP(type, flags, first, last)
1767 Newz(1101, binop, 1, BINOP);
1770 first = newOP(OP_NULL, 0);
1772 binop->op_type = type;
1773 binop->op_ppaddr = ppaddr[type];
1774 binop->op_first = first;
1775 binop->op_flags = flags | OPf_KIDS;
1778 binop->op_private = 1 | (flags >> 8);
1781 binop->op_private = 2 | (flags >> 8);
1782 first->op_sibling = last;
1785 binop = (BINOP*)CHECKOP(type, binop);
1789 binop->op_last = last = binop->op_first->op_sibling;
1791 return fold_constants((OP *)binop);
1795 pmtrans(op, expr, repl)
1800 SV *tstr = ((SVOP*)expr)->op_sv;
1801 SV *rstr = ((SVOP*)repl)->op_sv;
1804 register U8 *t = (U8*)SvPV(tstr, tlen);
1805 register U8 *r = (U8*)SvPV(rstr, rlen);
1810 register short *tbl;
1812 tbl = (short*)cPVOP->op_pv;
1813 complement = op->op_private & OPpTRANS_COMPLEMENT;
1814 delete = op->op_private & OPpTRANS_DELETE;
1815 /* squash = op->op_private & OPpTRANS_SQUASH; */
1818 Zero(tbl, 256, short);
1819 for (i = 0; i < tlen; i++)
1821 for (i = 0, j = 0; i < 256; i++) {
1837 if (!rlen && !delete) {
1840 for (i = 0; i < 256; i++)
1842 for (i = 0, j = 0; i < tlen; i++,j++) {
1845 if (tbl[t[i]] == -1)
1851 if (tbl[t[i]] == -1)
1862 newPMOP(type, flags)
1868 Newz(1101, pmop, 1, PMOP);
1869 pmop->op_type = type;
1870 pmop->op_ppaddr = ppaddr[type];
1871 pmop->op_flags = flags;
1872 pmop->op_private = 0 | (flags >> 8);
1874 if (hints & HINT_LOCALE)
1875 pmop->op_pmpermflags = (pmop->op_pmflags |= PMf_LOCALE);
1877 /* link into pm list */
1878 if (type != OP_TRANS && curstash) {
1879 pmop->op_pmnext = HvPMROOT(curstash);
1880 HvPMROOT(curstash) = pmop;
1887 pmruntime(op, expr, repl)
1895 if (op->op_type == OP_TRANS)
1896 return pmtrans(op, expr, repl);
1900 if (expr->op_type == OP_CONST) {
1902 SV *pat = ((SVOP*)expr)->op_sv;
1903 char *p = SvPV(pat, plen);
1904 if ((op->op_flags & OPf_SPECIAL) && strEQ(p, " ")) {
1905 sv_setpvn(pat, "\\s+", 3);
1906 p = SvPV(pat, plen);
1907 pm->op_pmflags |= PMf_SKIPWHITE;
1909 pm->op_pmregexp = pregcomp(p, p + plen, pm);
1910 if (strEQ("\\s+", pm->op_pmregexp->precomp))
1911 pm->op_pmflags |= PMf_WHITE;
1916 if (pm->op_pmflags & PMf_KEEP)
1917 expr = newUNOP(OP_REGCMAYBE,0,expr);
1919 Newz(1101, rcop, 1, LOGOP);
1920 rcop->op_type = OP_REGCOMP;
1921 rcop->op_ppaddr = ppaddr[OP_REGCOMP];
1922 rcop->op_first = scalar(expr);
1923 rcop->op_flags |= OPf_KIDS;
1924 rcop->op_private = 1;
1925 rcop->op_other = op;
1927 /* establish postfix order */
1928 if (pm->op_pmflags & PMf_KEEP) {
1930 rcop->op_next = expr;
1931 ((UNOP*)expr)->op_first->op_next = (OP*)rcop;
1934 rcop->op_next = LINKLIST(expr);
1935 expr->op_next = (OP*)rcop;
1938 prepend_elem(op->op_type, scalar((OP*)rcop), op);
1943 if (pm->op_pmflags & PMf_EVAL)
1945 else if (repl->op_type == OP_CONST)
1949 for (curop = LINKLIST(repl); curop!=repl; curop = LINKLIST(curop)) {
1950 if (opargs[curop->op_type] & OA_DANGEROUS) {
1951 if (curop->op_type == OP_GV) {
1952 GV *gv = ((GVOP*)curop)->op_gv;
1953 if (strchr("&`'123456789+", *GvENAME(gv)))
1956 else if (curop->op_type == OP_RV2CV)
1958 else if (curop->op_type == OP_RV2SV ||
1959 curop->op_type == OP_RV2AV ||
1960 curop->op_type == OP_RV2HV ||
1961 curop->op_type == OP_RV2GV) {
1962 if (lastop && lastop->op_type != OP_GV) /*funny deref?*/
1965 else if (curop->op_type == OP_PADSV ||
1966 curop->op_type == OP_PADAV ||
1967 curop->op_type == OP_PADHV ||
1968 curop->op_type == OP_PADANY) {
1977 if (curop == repl) {
1978 pm->op_pmflags |= PMf_CONST; /* const for long enough */
1979 pm->op_pmpermflags |= PMf_CONST; /* const for long enough */
1980 prepend_elem(op->op_type, scalar(repl), op);
1983 Newz(1101, rcop, 1, LOGOP);
1984 rcop->op_type = OP_SUBSTCONT;
1985 rcop->op_ppaddr = ppaddr[OP_SUBSTCONT];
1986 rcop->op_first = scalar(repl);
1987 rcop->op_flags |= OPf_KIDS;
1988 rcop->op_private = 1;
1989 rcop->op_other = op;
1991 /* establish postfix order */
1992 rcop->op_next = LINKLIST(repl);
1993 repl->op_next = (OP*)rcop;
1995 pm->op_pmreplroot = scalar((OP*)rcop);
1996 pm->op_pmreplstart = LINKLIST(rcop);
2005 newSVOP(type, flags, sv)
2011 Newz(1101, svop, 1, SVOP);
2012 svop->op_type = type;
2013 svop->op_ppaddr = ppaddr[type];
2015 svop->op_next = (OP*)svop;
2016 svop->op_flags = flags;
2017 if (opargs[type] & OA_RETSCALAR)
2019 if (opargs[type] & OA_TARGET)
2020 svop->op_targ = pad_alloc(type, SVs_PADTMP);
2021 return CHECKOP(type, svop);
2025 newGVOP(type, flags, gv)
2031 Newz(1101, gvop, 1, GVOP);
2032 gvop->op_type = type;
2033 gvop->op_ppaddr = ppaddr[type];
2034 gvop->op_gv = (GV*)SvREFCNT_inc(gv);
2035 gvop->op_next = (OP*)gvop;
2036 gvop->op_flags = flags;
2037 if (opargs[type] & OA_RETSCALAR)
2039 if (opargs[type] & OA_TARGET)
2040 gvop->op_targ = pad_alloc(type, SVs_PADTMP);
2041 return CHECKOP(type, gvop);
2045 newPVOP(type, flags, pv)
2051 Newz(1101, pvop, 1, PVOP);
2052 pvop->op_type = type;
2053 pvop->op_ppaddr = ppaddr[type];
2055 pvop->op_next = (OP*)pvop;
2056 pvop->op_flags = flags;
2057 if (opargs[type] & OA_RETSCALAR)
2059 if (opargs[type] & OA_TARGET)
2060 pvop->op_targ = pad_alloc(type, SVs_PADTMP);
2061 return CHECKOP(type, pvop);
2070 save_hptr(&curstash);
2071 save_item(curstname);
2076 name = SvPV(sv, len);
2077 curstash = gv_stashpvn(name,len,TRUE);
2078 sv_setpvn(curstname, name, len);
2082 sv_setpv(curstname,"<none>");
2090 utilize(aver, floor, version, id, arg)
2103 if (id->op_type != OP_CONST)
2104 croak("Module name must be constant");
2108 if(version != Nullop) {
2109 SV *vesv = ((SVOP*)version)->op_sv;
2111 if (arg == Nullop && !SvNIOK(vesv)) {
2118 if (version->op_type != OP_CONST || !SvNIOK(vesv))
2119 croak("Version number must be constant number");
2121 /* Make copy of id so we don't free it twice */
2122 pack = newSVOP(OP_CONST, 0, newSVsv(((SVOP*)id)->op_sv));
2124 /* Fake up a method call to VERSION */
2125 meth = newSVOP(OP_CONST, 0, newSVpv("VERSION", 7));
2126 veop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL,
2127 append_elem(OP_LIST,
2128 prepend_elem(OP_LIST, pack, list(version)),
2129 newUNOP(OP_METHOD, 0, meth)));
2133 /* Fake up an import/unimport */
2134 if (arg && arg->op_type == OP_STUB)
2135 imop = arg; /* no import on explicit () */
2136 else if(SvNIOK(((SVOP*)id)->op_sv)) {
2137 imop = Nullop; /* use 5.0; */
2140 /* Make copy of id so we don't free it twice */
2141 pack = newSVOP(OP_CONST, 0, newSVsv(((SVOP*)id)->op_sv));
2142 meth = newSVOP(OP_CONST, 0,
2144 ? newSVpv("import", 6)
2145 : newSVpv("unimport", 8)
2147 imop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL,
2148 append_elem(OP_LIST,
2149 prepend_elem(OP_LIST, pack, list(arg)),
2150 newUNOP(OP_METHOD, 0, meth)));
2153 /* Fake up a require */
2154 rqop = newUNOP(OP_REQUIRE, 0, id);
2156 /* Fake up the BEGIN {}, which does its thing immediately. */
2158 newSVOP(OP_CONST, 0, newSVpv("BEGIN", 5)),
2160 append_elem(OP_LINESEQ,
2161 append_elem(OP_LINESEQ,
2162 newSTATEOP(0, Nullch, rqop),
2163 newSTATEOP(0, Nullch, veop)),
2164 newSTATEOP(0, Nullch, imop) ));
2171 newSLICEOP(flags, subscript, listval)
2176 return newBINOP(OP_LSLICE, flags,
2177 list(force_list(subscript)),
2178 list(force_list(listval)) );
2188 if (op->op_type == OP_NULL && op->op_flags & OPf_KIDS)
2189 op = cUNOP->op_first;
2191 if (op->op_type == OP_COND_EXPR) {
2192 I32 t = list_assignment(cCONDOP->op_first->op_sibling);
2193 I32 f = list_assignment(cCONDOP->op_first->op_sibling->op_sibling);
2198 yyerror("Assignment to both a list and a scalar");
2202 if (op->op_type == OP_LIST || op->op_flags & OPf_PARENS ||
2203 op->op_type == OP_RV2AV || op->op_type == OP_RV2HV ||
2204 op->op_type == OP_ASLICE || op->op_type == OP_HSLICE)
2207 if (op->op_type == OP_PADAV || op->op_type == OP_PADHV)
2210 if (op->op_type == OP_RV2SV)
2217 newASSIGNOP(flags, left, optype, right)
2226 if (optype == OP_ANDASSIGN || optype == OP_ORASSIGN) {
2227 return newLOGOP(optype, 0,
2228 mod(scalar(left), optype),
2229 newUNOP(OP_SASSIGN, 0, scalar(right)));
2232 return newBINOP(optype, OPf_STACKED,
2233 mod(scalar(left), optype), scalar(right));
2237 if (list_assignment(left)) {
2239 eval_start = right; /* Grandfathering $[ assignment here. Bletch.*/
2240 left = mod(left, OP_AASSIGN);
2248 op = newBINOP(OP_AASSIGN, flags,
2249 list(force_list(right)),
2250 list(force_list(left)) );
2251 op->op_private = 0 | (flags >> 8);
2252 if (!(left->op_private & OPpLVAL_INTRO)) {
2253 static int generation = 100;
2257 for (curop = LINKLIST(op); curop != op; curop = LINKLIST(curop)) {
2258 if (opargs[curop->op_type] & OA_DANGEROUS) {
2259 if (curop->op_type == OP_GV) {
2260 GV *gv = ((GVOP*)curop)->op_gv;
2261 if (gv == defgv || SvCUR(gv) == generation)
2263 SvCUR(gv) = generation;
2265 else if (curop->op_type == OP_PADSV ||
2266 curop->op_type == OP_PADAV ||
2267 curop->op_type == OP_PADHV ||
2268 curop->op_type == OP_PADANY) {
2269 SV **svp = AvARRAY(comppad_name);
2270 SV *sv = svp[curop->op_targ];
2271 if (SvCUR(sv) == generation)
2273 SvCUR(sv) = generation; /* (SvCUR not used any more) */
2275 else if (curop->op_type == OP_RV2CV)
2277 else if (curop->op_type == OP_RV2SV ||
2278 curop->op_type == OP_RV2AV ||
2279 curop->op_type == OP_RV2HV ||
2280 curop->op_type == OP_RV2GV) {
2281 if (lastop->op_type != OP_GV) /* funny deref? */
2290 op->op_private = OPpASSIGN_COMMON;
2292 if (right && right->op_type == OP_SPLIT) {
2294 if ((tmpop = ((LISTOP*)right)->op_first) &&
2295 tmpop->op_type == OP_PUSHRE)
2297 PMOP *pm = (PMOP*)tmpop;
2298 if (left->op_type == OP_RV2AV &&
2299 !(left->op_private & OPpLVAL_INTRO) &&
2300 !(op->op_private & OPpASSIGN_COMMON) )
2302 tmpop = ((UNOP*)left)->op_first;
2303 if (tmpop->op_type == OP_GV && !pm->op_pmreplroot) {
2304 pm->op_pmreplroot = (OP*)((GVOP*)tmpop)->op_gv;
2305 pm->op_pmflags |= PMf_ONCE;
2306 tmpop = ((UNOP*)op)->op_first; /* to list (nulled) */
2307 tmpop = ((UNOP*)tmpop)->op_first; /* to pushmark */
2308 tmpop->op_sibling = Nullop; /* don't free split */
2309 right->op_next = tmpop->op_next; /* fix starting loc */
2310 op_free(op); /* blow off assign */
2311 right->op_flags &= ~(OPf_KNOW|OPf_LIST);
2312 /* "I don't know and I don't care." */
2317 if (modcount < 10000 &&
2318 ((LISTOP*)right)->op_last->op_type == OP_CONST)
2320 SV *sv = ((SVOP*)((LISTOP*)right)->op_last)->op_sv;
2322 sv_setiv(sv, modcount+1);
2330 right = newOP(OP_UNDEF, 0);
2331 if (right->op_type == OP_READLINE) {
2332 right->op_flags |= OPf_STACKED;
2333 return newBINOP(OP_NULL, flags, mod(scalar(left), OP_SASSIGN), scalar(right));
2336 eval_start = right; /* Grandfathering $[ assignment here. Bletch.*/
2337 op = newBINOP(OP_SASSIGN, flags,
2338 scalar(right), mod(scalar(left), OP_SASSIGN) );
2350 newSTATEOP(flags, label, op)
2355 U32 seq = intro_my();
2358 Newz(1101, cop, 1, COP);
2359 if (perldb && curcop->cop_line && curstash != debstash) {
2360 cop->op_type = OP_DBSTATE;
2361 cop->op_ppaddr = ppaddr[ OP_DBSTATE ];
2364 cop->op_type = OP_NEXTSTATE;
2365 cop->op_ppaddr = ppaddr[ OP_NEXTSTATE ];
2367 cop->op_flags = flags;
2368 cop->op_private = 0 | (flags >> 8);
2369 cop->op_next = (OP*)cop;
2372 cop->cop_label = label;
2373 hints |= HINT_BLOCK_SCOPE;
2376 cop->cop_arybase = curcop->cop_arybase;
2378 if (copline == NOLINE)
2379 cop->cop_line = curcop->cop_line;
2381 cop->cop_line = copline;
2384 cop->cop_filegv = (GV*)SvREFCNT_inc(curcop->cop_filegv);
2385 cop->cop_stash = curstash;
2387 if (perldb && curstash != debstash) {
2388 SV **svp = av_fetch(GvAV(curcop->cop_filegv),(I32)cop->cop_line, FALSE);
2389 if (svp && *svp != &sv_undef && !SvIOK(*svp)) {
2390 (void)SvIOK_on(*svp);
2392 SvSTASH(*svp) = (HV*)cop;
2396 return prepend_elem(OP_LINESEQ, (OP*)cop, op);
2399 /* "Introduce" my variables to visible status. */
2407 if (! min_intro_pending)
2410 svp = AvARRAY(comppad_name);
2411 for (i = min_intro_pending; i <= max_intro_pending; i++) {
2412 if ((sv = svp[i]) && sv != &sv_undef && !SvIVX(sv)) {
2413 SvIVX(sv) = 999999999; /* Don't know scope end yet. */
2414 SvNVX(sv) = (double)cop_seqmax;
2417 min_intro_pending = 0;
2418 comppad_name_fill = max_intro_pending; /* Needn't search higher */
2419 return cop_seqmax++;
2423 newLOGOP(type, flags, first, other)
2432 if (type == OP_XOR) /* Not short circuit, but here by precedence. */
2433 return newBINOP(type, flags, scalar(first), scalar(other));
2435 scalarboolean(first);
2436 /* optimize "!a && b" to "a || b", and "!a || b" to "a && b" */
2437 if (first->op_type == OP_NOT && (first->op_flags & OPf_SPECIAL)) {
2438 if (type == OP_AND || type == OP_OR) {
2444 first = cUNOP->op_first;
2446 first->op_next = op->op_next;
2447 cUNOP->op_first = Nullop;
2451 if (first->op_type == OP_CONST) {
2452 if (dowarn && (first->op_private & OPpCONST_BARE))
2453 warn("Probable precedence problem on %s", op_desc[type]);
2454 if ((type == OP_AND) == (SvTRUE(((SVOP*)first)->op_sv))) {
2463 else if (first->op_type == OP_WANTARRAY) {
2469 else if (dowarn && (first->op_flags & OPf_KIDS)) {
2470 OP *k1 = ((UNOP*)first)->op_first;
2471 OP *k2 = k1->op_sibling;
2473 switch (first->op_type)
2476 if (k2 && k2->op_type == OP_READLINE
2477 && (k2->op_flags & OPf_STACKED)
2478 && (k1->op_type == OP_RV2SV || k1->op_type == OP_PADSV))
2479 warnop = k2->op_type;
2483 if (k1->op_type == OP_READDIR || k1->op_type == OP_GLOB)
2484 warnop = k1->op_type;
2488 line_t oldline = curcop->cop_line;
2489 curcop->cop_line = copline;
2490 warn("Value of %s construct can be \"0\"; test with defined()",
2492 curcop->cop_line = oldline;
2499 if (type == OP_ANDASSIGN || type == OP_ORASSIGN)
2500 other->op_private |= OPpASSIGN_BACKWARDS; /* other is an OP_SASSIGN */
2502 Newz(1101, logop, 1, LOGOP);
2504 logop->op_type = type;
2505 logop->op_ppaddr = ppaddr[type];
2506 logop->op_first = first;
2507 logop->op_flags = flags | OPf_KIDS;
2508 logop->op_other = LINKLIST(other);
2509 logop->op_private = 1 | (flags >> 8);
2511 /* establish postfix order */
2512 logop->op_next = LINKLIST(first);
2513 first->op_next = (OP*)logop;
2514 first->op_sibling = other;
2516 op = newUNOP(OP_NULL, 0, (OP*)logop);
2517 other->op_next = op;
2523 newCONDOP(flags, first, trueop, falseop)
2533 return newLOGOP(OP_AND, 0, first, trueop);
2535 return newLOGOP(OP_OR, 0, first, falseop);
2537 scalarboolean(first);
2538 if (first->op_type == OP_CONST) {
2539 if (SvTRUE(((SVOP*)first)->op_sv)) {
2550 else if (first->op_type == OP_WANTARRAY) {
2554 Newz(1101, condop, 1, CONDOP);
2556 condop->op_type = OP_COND_EXPR;
2557 condop->op_ppaddr = ppaddr[OP_COND_EXPR];
2558 condop->op_first = first;
2559 condop->op_flags = flags | OPf_KIDS;
2560 condop->op_true = LINKLIST(trueop);
2561 condop->op_false = LINKLIST(falseop);
2562 condop->op_private = 1 | (flags >> 8);
2564 /* establish postfix order */
2565 condop->op_next = LINKLIST(first);
2566 first->op_next = (OP*)condop;
2568 first->op_sibling = trueop;
2569 trueop->op_sibling = falseop;
2570 op = newUNOP(OP_NULL, 0, (OP*)condop);
2572 trueop->op_next = op;
2573 falseop->op_next = op;
2579 newRANGE(flags, left, right)
2589 Newz(1101, condop, 1, CONDOP);
2591 condop->op_type = OP_RANGE;
2592 condop->op_ppaddr = ppaddr[OP_RANGE];
2593 condop->op_first = left;
2594 condop->op_flags = OPf_KIDS;
2595 condop->op_true = LINKLIST(left);
2596 condop->op_false = LINKLIST(right);
2597 condop->op_private = 1 | (flags >> 8);
2599 left->op_sibling = right;
2601 condop->op_next = (OP*)condop;
2602 flip = newUNOP(OP_FLIP, flags, (OP*)condop);
2603 flop = newUNOP(OP_FLOP, 0, flip);
2604 op = newUNOP(OP_NULL, 0, flop);
2607 left->op_next = flip;
2608 right->op_next = flop;
2610 condop->op_targ = pad_alloc(OP_RANGE, SVs_PADMY);
2611 sv_upgrade(PAD_SV(condop->op_targ), SVt_PVNV);
2612 flip->op_targ = pad_alloc(OP_RANGE, SVs_PADMY);
2613 sv_upgrade(PAD_SV(flip->op_targ), SVt_PVNV);
2615 flip->op_private = left->op_type == OP_CONST ? OPpFLIP_LINENUM : 0;
2616 flop->op_private = right->op_type == OP_CONST ? OPpFLIP_LINENUM : 0;
2619 if (!flip->op_private || !flop->op_private)
2620 linklist(op); /* blow off optimizer unless constant */
2626 newLOOPOP(flags, debuggable, expr, block)
2634 int once = block && block->op_flags & OPf_SPECIAL &&
2635 (block->op_type == OP_ENTERSUB || block->op_type == OP_NULL);
2638 if (once && expr->op_type == OP_CONST && !SvTRUE(((SVOP*)expr)->op_sv))
2639 return block; /* do {} while 0 does once */
2640 else if (expr->op_type == OP_READLINE || expr->op_type == OP_GLOB)
2641 expr = newASSIGNOP(0, newSVREF(newGVOP(OP_GV, 0, defgv)), 0, expr);
2644 listop = append_elem(OP_LINESEQ, block, newOP(OP_UNSTACK, 0));
2645 op = newLOGOP(OP_AND, 0, expr, listop);
2647 ((LISTOP*)listop)->op_last->op_next = LINKLIST(op);
2649 if (once && op != listop)
2650 op->op_next = ((LOGOP*)cUNOP->op_first)->op_other;
2653 op = newUNOP(OP_NULL, 0, op); /* or do {} while 1 loses outer block */
2655 op->op_flags |= flags;
2657 op->op_flags |= OPf_SPECIAL; /* suppress POPBLOCK curpm restoration*/
2662 newWHILEOP(flags, debuggable, loop, expr, block, cont)
2676 if (expr && (expr->op_type == OP_READLINE || expr->op_type == OP_GLOB)) {
2677 expr = newUNOP(OP_DEFINED, 0,
2678 newASSIGNOP(0, newSVREF(newGVOP(OP_GV, 0, defgv)), 0, expr) );
2682 block = newOP(OP_NULL, 0);
2685 next = LINKLIST(cont);
2687 cont = append_elem(OP_LINESEQ, cont, newOP(OP_UNSTACK, 0));
2689 listop = append_list(OP_LINESEQ, (LISTOP*)block, (LISTOP*)cont);
2690 redo = LINKLIST(listop);
2693 op = newLOGOP(OP_AND, 0, expr, scalar(listop));
2694 if (op == expr && op->op_type == OP_CONST && !SvTRUE(cSVOP->op_sv)) {
2695 op_free(expr); /* oops, it's a while (0) */
2697 return Nullop; /* (listop already freed by newLOGOP) */
2699 ((LISTOP*)listop)->op_last->op_next = condop =
2700 (op == listop ? redo : LINKLIST(op));
2708 Newz(1101,loop,1,LOOP);
2709 loop->op_type = OP_ENTERLOOP;
2710 loop->op_ppaddr = ppaddr[OP_ENTERLOOP];
2711 loop->op_private = 0;
2712 loop->op_next = (OP*)loop;
2715 op = newBINOP(OP_LEAVELOOP, 0, (OP*)loop, op);
2717 loop->op_redoop = redo;
2718 loop->op_lastop = op;
2721 loop->op_nextop = next;
2723 loop->op_nextop = op;
2725 op->op_flags |= flags;
2726 op->op_private |= (flags >> 8);
2731 #ifndef CAN_PROTOTYPE
2732 newFOROP(flags,label,forline,sv,expr,block,cont)
2741 newFOROP(I32 flags,char *label,line_t forline,OP *sv,OP *expr,OP *block,OP *cont)
2742 #endif /* CAN_PROTOTYPE */
2750 if (sv->op_type == OP_RV2SV) { /* symbol table variable */
2751 sv->op_type = OP_RV2GV;
2752 sv->op_ppaddr = ppaddr[OP_RV2GV];
2754 else if (sv->op_type == OP_PADSV) { /* private variable */
2755 padoff = sv->op_targ;
2760 croak("Can't use %s for loop variable", op_desc[sv->op_type]);
2763 sv = newGVOP(OP_GV, 0, defgv);
2765 if (expr->op_type == OP_RV2AV || expr->op_type == OP_PADAV) {
2766 expr = scalar(ref(expr, OP_ITER));
2767 iterflags |= OPf_STACKED;
2769 loop = (LOOP*)list(convert(OP_ENTERITER, iterflags,
2770 append_elem(OP_LIST, mod(force_list(expr), OP_GREPSTART),
2772 assert(!loop->op_next);
2773 Renew(loop, 1, LOOP);
2774 loop->op_targ = padoff;
2775 return newSTATEOP(0, label, newWHILEOP(flags, 1, loop,
2776 newOP(OP_ITER, 0), block, cont));
2780 newLOOPEX(type, label)
2785 if (type != OP_GOTO || label->op_type == OP_CONST) {
2786 op = newPVOP(type, 0, savepv(
2787 label->op_type == OP_CONST
2788 ? SvPVx(((SVOP*)label)->op_sv, na)
2793 if (label->op_type == OP_ENTERSUB)
2794 label = newUNOP(OP_REFGEN, 0, mod(label, OP_REFGEN));
2795 op = newUNOP(type, OPf_STACKED, label);
2797 hints |= HINT_BLOCK_SCOPE;
2805 if (!CvXSUB(cv) && CvROOT(cv)) {
2807 croak("Can't undef active subroutine");
2814 op_free(CvROOT(cv));
2815 CvROOT(cv) = Nullop;
2819 SvREFCNT_dec(CvGV(cv));
2821 SvREFCNT_dec(CvOUTSIDE(cv));
2822 CvOUTSIDE(cv) = Nullcv;
2823 if (CvPADLIST(cv)) {
2824 /* may be during global destruction */
2825 if (SvREFCNT(CvPADLIST(cv))) {
2826 I32 i = AvFILL(CvPADLIST(cv));
2828 SV** svp = av_fetch(CvPADLIST(cv), i--, FALSE);
2832 SvREFCNT_dec((SV*)CvPADLIST(cv));
2834 CvPADLIST(cv) = Nullav;
2838 #ifdef DEBUG_CLOSURES
2843 CV *outside = CvOUTSIDE(cv);
2844 AV* padlist = CvPADLIST(cv);
2845 AV* pad_name = (AV*)*av_fetch(padlist, 0, FALSE);
2846 AV* pad = (AV*)*av_fetch(padlist, 1, FALSE);
2847 SV** pname = AvARRAY(pad_name);
2848 SV** ppad = AvARRAY(pad);
2851 PerlIO_printf(Perl_debug_log, "\tCV=0x%p (%s), OUTSIDE=0x%p (%s)\n",
2853 (CvANON(cv) ? "ANON"
2854 : (cv == main_cv) ? "MAIN"
2855 : CvUNIQUE(outside) ? "UNIQUE"
2856 : CvGV(cv) ? GvNAME(CvGV(cv)) : "UNDEFINED"),
2859 : CvANON(outside) ? "ANON"
2860 : (outside == main_cv) ? "MAIN"
2861 : CvUNIQUE(outside) ? "UNIQUE"
2862 : CvGV(outside) ? GvNAME(CvGV(outside)) : "UNDEFINED"));
2864 for (ix = 1; ix <= AvFILL(pad); ix++) {
2865 if (SvPOK(pname[ix]))
2866 PerlIO_printf(Perl_debug_log, "\t%4d. 0x%p (\"%s\" %ld-%ld)\n",
2867 ix, ppad[ix], SvPVX(pname[ix]),
2868 (long)I_32(SvNVX(pname[ix])),
2869 (long)SvIVX(pname[ix]));
2872 #endif /* DEBUG_CLOSURES */
2875 cv_clone2(proto, outside)
2881 AV* protopadlist = CvPADLIST(proto);
2882 AV* protopad_name = (AV*)*av_fetch(protopadlist, 0, FALSE);
2883 AV* protopad = (AV*)*av_fetch(protopadlist, 1, FALSE);
2884 SV** pname = AvARRAY(protopad_name);
2885 SV** ppad = AvARRAY(protopad);
2889 assert(!CvUNIQUE(proto));
2896 cv = compcv = (CV*)NEWSV(1104,0);
2897 sv_upgrade((SV *)cv, SVt_PVCV);
2902 CvFILEGV(cv) = CvFILEGV(proto);
2903 CvGV(cv) = (GV*)SvREFCNT_inc(CvGV(proto));
2904 CvSTASH(cv) = CvSTASH(proto);
2905 CvROOT(cv) = CvROOT(proto);
2906 CvSTART(cv) = CvSTART(proto);
2908 CvOUTSIDE(cv) = (CV*)SvREFCNT_inc(outside);
2912 comppadlist = newAV();
2913 AvREAL_off(comppadlist);
2914 av_store(comppadlist, 0, SvREFCNT_inc((SV*)protopad_name));
2915 av_store(comppadlist, 1, (SV*)comppad);
2916 CvPADLIST(cv) = comppadlist;
2917 av_fill(comppad, AvFILL(protopad));
2918 curpad = AvARRAY(comppad);
2920 av = newAV(); /* will be @_ */
2922 av_store(comppad, 0, (SV*)av);
2923 AvFLAGS(av) = AVf_REIFY;
2925 for (ix = AvFILL(protopad); ix > 0; ix--) {
2927 if (pname[ix] != &sv_undef) {
2928 char *name = SvPVX(pname[ix]); /* XXX */
2929 if (SvFLAGS(pname[ix]) & SVf_FAKE) { /* lexical from outside? */
2930 I32 off = pad_findlex(name, ix, SvIVX(pname[ix]),
2931 CvOUTSIDE(cv), cxstack_ix);
2933 curpad[ix] = SvREFCNT_inc(ppad[ix]);
2935 croak("panic: cv_clone: %s", name);
2937 else { /* our own lexical */
2939 /* anon code -- we'll come back for it */
2940 sv = SvREFCNT_inc(ppad[ix]);
2942 else if (*name == '@')
2944 else if (*name == '%')
2960 /* Now that vars are all in place, clone nested closures. */
2962 for (ix = AvFILL(protopad); ix > 0; ix--) {
2963 if (pname[ix] != &sv_undef
2964 && !(SvFLAGS(pname[ix]) & SVf_FAKE)
2965 && *SvPVX(pname[ix]) == '&'
2966 && CvCLONE(ppad[ix]))
2968 CV *kid = cv_clone2((CV*)ppad[ix], cv);
2969 SvREFCNT_dec(ppad[ix]);
2972 curpad[ix] = (SV*)kid;
2976 #ifdef DEBUG_CLOSURES
2977 PerlIO_printf(Perl_debug_log, "Cloned inside:\n");
2979 PerlIO_printf(Perl_debug_log, " from:\n");
2981 PerlIO_printf(Perl_debug_log, " to:\n");
2993 return cv_clone2(proto, CvOUTSIDE(proto));
3003 if(cv && SvPOK(cv) && !SvCUR(cv)) {
3004 for (o = CvSTART(cv); o; o = o->op_next) {
3005 OPCODE type = o->op_type;
3007 if (type == OP_NEXTSTATE || type == OP_NULL || type == OP_PUSHMARK)
3009 if (type == OP_LEAVESUB || type == OP_RETURN)
3011 if (type != OP_CONST || sv)
3014 sv = ((SVOP*)o)->op_sv;
3021 newSUB(floor,op,proto,block)
3027 char *name = op ? SvPVx(cSVOP->op_sv, na) : Nullch;
3028 GV *gv = gv_fetchpv(name ? name : "__ANON__", GV_ADDMULTI, SVt_PVCV);
3035 if (cv = (name ? GvCV(gv) : Nullcv)) {
3037 /* just a cached method */
3041 else if (CvROOT(cv) || CvXSUB(cv) || GvASSUMECV(gv)) {
3042 /* already defined (or promised) */
3044 SV* const_sv = cv_const_sv(cv);
3045 char *p = proto ? SvPVx(((SVOP*)proto)->op_sv, na) : Nullch;
3047 if((!proto != !SvPOK(cv)) || (p && strNE(SvPV((SV*)cv,na), p))) {
3048 warn("Prototype mismatch: (%s) vs (%s)",
3049 SvPOK(cv) ? SvPV((SV*)cv,na) : "none",
3052 if (const_sv || dowarn) {
3053 line_t oldline = curcop->cop_line;
3054 curcop->cop_line = copline;
3055 warn(const_sv ? "Constant subroutine %s redefined"
3056 : "Subroutine %s redefined",name);
3057 curcop->cop_line = oldline;
3063 if (cv) { /* must reuse cv if autoloaded */
3065 CvFLAGS(cv) = CvFLAGS(compcv);
3066 CvOUTSIDE(cv) = CvOUTSIDE(compcv);
3067 CvOUTSIDE(compcv) = 0;
3068 CvPADLIST(cv) = CvPADLIST(compcv);
3069 CvPADLIST(compcv) = 0;
3070 if (SvREFCNT(compcv) > 1) /* XXX Make closures transit through stub. */
3071 CvOUTSIDE(compcv) = (CV*)SvREFCNT_inc((SV*)cv);
3072 SvREFCNT_dec(compcv);
3082 CvGV(cv) = (GV*)SvREFCNT_inc(gv);
3083 CvFILEGV(cv) = curcop->cop_filegv;
3084 CvSTASH(cv) = curstash;
3087 char *p = SvPVx(((SVOP*)proto)->op_sv, na);
3088 sv_setpv((SV*)cv, p);
3102 av = newAV(); /* Will be @_ */
3104 av_store(comppad, 0, (SV*)av);
3105 AvFLAGS(av) = AVf_REIFY;
3107 for (ix = AvFILL(comppad); ix > 0; ix--) {
3108 if (!SvPADMY(curpad[ix]) && !SvIMMORTAL(curpad[ix]))
3109 SvPADTMP_on(curpad[ix]);
3112 if (AvFILL(comppad_name) < AvFILL(comppad))
3113 av_store(comppad_name, AvFILL(comppad), Nullsv);
3115 CvROOT(cv) = newUNOP(OP_LEAVESUB, 0, scalarseq(block));
3116 CvSTART(cv) = LINKLIST(CvROOT(cv));
3117 CvROOT(cv)->op_next = 0;
3123 if (perldb && curstash != debstash) {
3125 SV *tmpstr = sv_newmortal();
3126 static GV *db_postponed;
3130 sprintf(buf, "%s:%ld",
3131 SvPVX(GvSV(curcop->cop_filegv)), (long)subline);
3132 sv = newSVpv(buf,0);
3134 sprintf(buf,"%ld",(long)curcop->cop_line);
3136 gv_efullname3(tmpstr, gv, Nullch);
3137 hv_store(GvHV(DBsub), SvPVX(tmpstr), SvCUR(tmpstr), sv, 0);
3138 if (!db_postponed) {
3139 db_postponed = gv_fetchpv("DB::postponed", TRUE, SVt_PVHV);
3141 hv = GvHVn(db_postponed);
3142 if (HvFILL(hv) >= 0 && hv_exists(hv, SvPVX(tmpstr), SvCUR(tmpstr))
3143 && (cv = GvCV(db_postponed))) {
3148 perl_call_sv((SV*)cv, G_DISCARD);
3152 if ((s = strrchr(name,':')))
3156 if (strEQ(s, "BEGIN") && !error_count) {
3158 SAVESPTR(compiling.cop_filegv);
3159 SAVEI16(compiling.cop_line);
3166 DEBUG_x( dump_sub(gv) );
3167 av_push(beginav, (SV *)cv);
3171 curcop = &compiling;
3174 else if (strEQ(s, "END") && !error_count) {
3177 av_unshift(endav, 1);
3178 av_store(endav, 0, (SV *)cv);
3190 newXSUB(name, ix, subaddr, filename)
3196 CV* cv = newXS(name, (void(*)())subaddr, filename);
3198 CvXSUBANY(cv).any_i32 = ix;
3204 newXS(name, subaddr, filename)
3206 void (*subaddr) _((CV*));
3209 GV *gv = gv_fetchpv(name ? name : "__ANON__", GV_ADDMULTI, SVt_PVCV);
3212 if (cv = (name ? GvCV(gv) : Nullcv)) {
3214 /* just a cached method */
3218 else if (CvROOT(cv) || CvXSUB(cv) || GvASSUMECV(gv)) {
3219 /* already defined (or promised) */
3221 line_t oldline = curcop->cop_line;
3222 curcop->cop_line = copline;
3223 warn("Subroutine %s redefined",name);
3224 curcop->cop_line = oldline;
3231 if (cv) /* must reuse cv if autoloaded */
3234 cv = (CV*)NEWSV(1105,0);
3235 sv_upgrade((SV *)cv, SVt_PVCV);
3242 CvGV(cv) = (GV*)SvREFCNT_inc(gv);
3243 CvFILEGV(cv) = gv_fetchfile(filename);
3244 CvXSUB(cv) = subaddr;
3247 char *s = strrchr(name,':');
3252 if (strEQ(s, "BEGIN")) {
3255 av_push(beginav, (SV *)cv);
3258 else if (strEQ(s, "END")) {
3261 av_unshift(endav, 1);
3262 av_store(endav, 0, (SV *)cv);
3273 newFORM(floor,op,block)
3284 name = SvPVx(cSVOP->op_sv, na);
3287 gv = gv_fetchpv(name,TRUE, SVt_PVFM);
3289 if (cv = GvFORM(gv)) {
3291 line_t oldline = curcop->cop_line;
3293 curcop->cop_line = copline;
3294 warn("Format %s redefined",name);
3295 curcop->cop_line = oldline;
3301 CvGV(cv) = (GV*)SvREFCNT_inc(gv);
3302 CvFILEGV(cv) = curcop->cop_filegv;
3304 for (ix = AvFILL(comppad); ix > 0; ix--) {
3305 if (!SvPADMY(curpad[ix]) && !SvIMMORTAL(curpad[ix]))
3306 SvPADTMP_on(curpad[ix]);
3309 CvROOT(cv) = newUNOP(OP_LEAVEWRITE, 0, scalarseq(block));
3310 CvSTART(cv) = LINKLIST(CvROOT(cv));
3311 CvROOT(cv)->op_next = 0;
3323 return newUNOP(OP_REFGEN, 0,
3324 mod(list(convert(OP_ANONLIST, 0, op)), OP_REFGEN));
3331 return newUNOP(OP_REFGEN, 0,
3332 mod(list(convert(OP_ANONHASH, 0, op)), OP_REFGEN));
3336 newANONSUB(floor, proto, block)
3341 return newUNOP(OP_REFGEN, 0,
3342 newSVOP(OP_ANONCODE, 0, (SV*)newSUB(floor, 0, proto, block)));
3349 switch (o->op_type) {
3351 o->op_type = OP_PADAV;
3352 o->op_ppaddr = ppaddr[OP_PADAV];
3353 return ref(newUNOP(OP_RV2AV, 0, scalar(o)), OP_RV2AV);
3356 o->op_type = OP_RV2AV;
3357 o->op_ppaddr = ppaddr[OP_RV2AV];
3362 warn("oops: oopsAV");
3372 switch (o->op_type) {
3375 o->op_type = OP_PADHV;
3376 o->op_ppaddr = ppaddr[OP_PADHV];
3377 return ref(newUNOP(OP_RV2HV, 0, scalar(o)), OP_RV2HV);
3381 o->op_type = OP_RV2HV;
3382 o->op_ppaddr = ppaddr[OP_RV2HV];
3387 warn("oops: oopsHV");
3397 if (o->op_type == OP_PADANY) {
3398 o->op_type = OP_PADAV;
3399 o->op_ppaddr = ppaddr[OP_PADAV];
3402 return newUNOP(OP_RV2AV, 0, scalar(o));
3410 if (type == OP_MAPSTART)
3411 return newUNOP(OP_NULL, 0, o);
3412 return ref(newUNOP(OP_RV2GV, OPf_REF, o), type);
3419 if (o->op_type == OP_PADANY) {
3420 o->op_type = OP_PADHV;
3421 o->op_ppaddr = ppaddr[OP_PADHV];
3424 return newUNOP(OP_RV2HV, 0, scalar(o));
3431 croak("NOT IMPL LINE %d",__LINE__);
3441 return newUNOP(OP_RV2CV, flags, scalar(o));
3448 if (o->op_type == OP_PADANY) {
3449 o->op_type = OP_PADSV;
3450 o->op_ppaddr = ppaddr[OP_PADSV];
3453 return newUNOP(OP_RV2SV, 0, scalar(o));
3456 /* Check routines. */
3465 name = NEWSV(1106,0);
3466 sv_upgrade(name, SVt_PVNV);
3467 sv_setpvn(name, "&", 1);
3470 ix = pad_alloc(op->op_type, SVs_PADMY);
3471 av_store(comppad_name, ix, name);
3472 av_store(comppad, ix, cSVOP->op_sv);
3473 SvPADMY_on(cSVOP->op_sv);
3474 cSVOP->op_sv = Nullsv;
3475 cSVOP->op_targ = ix;
3483 op->op_private = hints;
3491 if (cUNOP->op_first->op_type == OP_CONCAT)
3492 op->op_flags |= OPf_STACKED;
3500 if (op->op_flags & OPf_KIDS) {
3503 OPCODE type = op->op_type;
3504 op = modkids(ck_fun(op), type);
3505 kid = cUNOP->op_first;
3506 newop = kUNOP->op_first->op_sibling;
3508 (newop->op_sibling ||
3509 !(opargs[newop->op_type] & OA_RETSCALAR) ||
3510 newop->op_type == OP_PADAV || newop->op_type == OP_PADHV ||
3511 newop->op_type == OP_RV2AV || newop->op_type == OP_RV2HV)) {
3515 op_free(kUNOP->op_first);
3516 kUNOP->op_first = newop;
3518 op->op_ppaddr = ppaddr[++op->op_type];
3528 if (op->op_flags & OPf_KIDS) {
3529 OP *kid = cUNOP->op_first;
3530 if (kid->op_type == OP_HSLICE)
3531 op->op_private |= OPpSLICE;
3532 else if (kid->op_type != OP_HELEM)
3533 croak("%s argument is not a HASH element or slice",
3534 op_desc[op->op_type]);
3544 I32 type = op->op_type;
3546 if (op->op_flags & OPf_KIDS) {
3547 if (cLISTOP->op_first->op_type == OP_STUB) {
3549 op = newUNOP(type, OPf_SPECIAL,
3550 newGVOP(OP_GV, 0, gv_fetchpv("main'ARGV", TRUE, SVt_PVAV)));
3561 hints |= HINT_BLOCK_SCOPE;
3562 if (op->op_flags & OPf_KIDS) {
3563 SVOP *kid = (SVOP*)cUNOP->op_first;
3566 op->op_flags &= ~OPf_KIDS;
3569 else if (kid->op_type == OP_LINESEQ) {
3572 kid->op_next = op->op_next;
3573 cUNOP->op_first = 0;
3576 Newz(1101, enter, 1, LOGOP);
3577 enter->op_type = OP_ENTERTRY;
3578 enter->op_ppaddr = ppaddr[OP_ENTERTRY];
3579 enter->op_private = 0;
3581 /* establish postfix order */
3582 enter->op_next = (OP*)enter;
3584 op = prepend_elem(OP_LINESEQ, (OP*)enter, (OP*)kid);
3585 op->op_type = OP_LEAVETRY;
3586 op->op_ppaddr = ppaddr[OP_LEAVETRY];
3587 enter->op_other = op;
3593 op = newUNOP(OP_ENTEREVAL, 0, newSVREF(newGVOP(OP_GV, 0, defgv)));
3595 op->op_targ = (PADOFFSET)hints;
3604 if (op->op_flags & OPf_STACKED) {
3606 kid = cUNOP->op_first->op_sibling;
3607 if (kid->op_type == OP_RV2GV)
3620 if (op->op_flags & OPf_KIDS) {
3621 OP *kid = cUNOP->op_first;
3622 if (kid->op_type != OP_HELEM)
3623 croak("%s argument is not a HASH element", op_desc[op->op_type]);
3633 o = fold_constants(o);
3634 if (o->op_type == OP_CONST)
3643 SVOP *kid = (SVOP*)cUNOP->op_first;
3645 op->op_private |= (hints & HINT_STRICT_REFS);
3646 if (kid->op_type == OP_CONST) {
3651 name = SvPV(kid->op_sv, na);
3652 if ((hints & HINT_STRICT_REFS) && (kid->op_private & OPpCONST_BARE)) {
3653 char *badthing = Nullch;
3654 switch (op->op_type) {
3656 badthing = "a SCALAR";
3659 badthing = "an ARRAY";
3662 badthing = "a HASH";
3667 "Can't use bareword (\"%s\") as %s ref while \"strict refs\" in use",
3670 kid->op_type = OP_GV;
3671 iscv = (op->op_type == OP_RV2CV) * 2;
3672 for (gv = 0; !gv; iscv++) {
3674 * This is a little tricky. We only want to add the symbol if we
3675 * didn't add it in the lexer. Otherwise we get duplicate strict
3676 * warnings. But if we didn't add it in the lexer, we must at
3677 * least pretend like we wanted to add it even if it existed before,
3678 * or we get possible typo warnings. OPpCONST_ENTERED says
3679 * whether the lexer already added THIS instance of this symbol.
3681 gv = gv_fetchpv(name,
3682 iscv | !(kid->op_private & OPpCONST_ENTERED),
3685 : op->op_type == OP_RV2SV
3687 : op->op_type == OP_RV2AV
3689 : op->op_type == OP_RV2HV
3693 SvREFCNT_dec(kid->op_sv);
3694 kid->op_sv = SvREFCNT_inc(gv);
3703 I32 type = op->op_type;
3705 if (op->op_flags & OPf_REF)
3708 if (op->op_flags & OPf_KIDS) {
3709 SVOP *kid = (SVOP*)cUNOP->op_first;
3711 if (kid->op_type == OP_CONST && (kid->op_private & OPpCONST_BARE)) {
3712 OP *newop = newGVOP(type, OPf_REF,
3713 gv_fetchpv(SvPVx(kid->op_sv, na), TRUE, SVt_PVIO));
3720 if (type == OP_FTTTY)
3721 return newGVOP(type, OPf_REF, gv_fetchpv("main'STDIN", TRUE,
3724 return newUNOP(type, 0, newSVREF(newGVOP(OP_GV, 0, defgv)));
3737 int type = op->op_type;
3738 register I32 oa = opargs[type] >> OASHIFT;
3740 if (op->op_flags & OPf_STACKED) {
3741 if ((oa & OA_OPTIONAL) && (oa >> 4) && !((oa >> 4) & OA_OPTIONAL))
3744 return no_fh_allowed(op);
3747 if (op->op_flags & OPf_KIDS) {
3748 tokid = &cLISTOP->op_first;
3749 kid = cLISTOP->op_first;
3750 if (kid->op_type == OP_PUSHMARK ||
3751 kid->op_type == OP_NULL && kid->op_targ == OP_PUSHMARK)
3753 tokid = &kid->op_sibling;
3754 kid = kid->op_sibling;
3756 if (!kid && opargs[type] & OA_DEFGV)
3757 *tokid = kid = newSVREF(newGVOP(OP_GV, 0, defgv));
3761 sibl = kid->op_sibling;
3775 if (kid->op_type == OP_CONST &&
3776 (kid->op_private & OPpCONST_BARE)) {
3777 char *name = SvPVx(((SVOP*)kid)->op_sv, na);
3778 OP *newop = newAVREF(newGVOP(OP_GV, 0,
3779 gv_fetchpv(name, TRUE, SVt_PVAV) ));
3781 warn("Array @%s missing the @ in argument %d of %s()",
3782 name, numargs, op_desc[type]);
3785 kid->op_sibling = sibl;
3788 else if (kid->op_type != OP_RV2AV && kid->op_type != OP_PADAV)
3789 bad_type(numargs, "array", op_desc[op->op_type], kid);
3793 if (kid->op_type == OP_CONST &&
3794 (kid->op_private & OPpCONST_BARE)) {
3795 char *name = SvPVx(((SVOP*)kid)->op_sv, na);
3796 OP *newop = newHVREF(newGVOP(OP_GV, 0,
3797 gv_fetchpv(name, TRUE, SVt_PVHV) ));
3799 warn("Hash %%%s missing the %% in argument %d of %s()",
3800 name, numargs, op_desc[type]);
3803 kid->op_sibling = sibl;
3806 else if (kid->op_type != OP_RV2HV && kid->op_type != OP_PADHV)
3807 bad_type(numargs, "hash", op_desc[op->op_type], kid);
3812 OP *newop = newUNOP(OP_NULL, 0, kid);
3813 kid->op_sibling = 0;
3815 newop->op_next = newop;
3817 kid->op_sibling = sibl;
3822 if (kid->op_type != OP_GV) {
3823 if (kid->op_type == OP_CONST &&
3824 (kid->op_private & OPpCONST_BARE)) {
3825 OP *newop = newGVOP(OP_GV, 0,
3826 gv_fetchpv(SvPVx(((SVOP*)kid)->op_sv, na), TRUE,
3832 kid->op_sibling = 0;
3833 kid = newUNOP(OP_RV2GV, 0, scalar(kid));
3835 kid->op_sibling = sibl;
3841 mod(scalar(kid), type);
3845 tokid = &kid->op_sibling;
3846 kid = kid->op_sibling;
3848 op->op_private |= numargs;
3850 return too_many_arguments(op,op_desc[op->op_type]);
3853 else if (opargs[type] & OA_DEFGV) {
3855 return newUNOP(type, 0, newSVREF(newGVOP(OP_GV, 0, defgv)));
3859 while (oa & OA_OPTIONAL)
3861 if (oa && oa != OA_LIST)
3862 return too_few_arguments(op,op_desc[op->op_type]);
3871 GV *gv = gv_fetchpv("glob", FALSE, SVt_PVCV);
3873 if (gv && GvIMPORTED_CV(gv)) {
3874 op->op_type = OP_LIST;
3875 op->op_ppaddr = ppaddr[OP_LIST];
3876 op = newUNOP(OP_ENTERSUB, OPf_STACKED,
3877 append_elem(OP_LIST, op,
3878 scalar(newUNOP(OP_RV2CV, 0,
3879 newGVOP(OP_GV, 0, gv)))));
3882 gv = newGVgen("main");
3884 append_elem(OP_GLOB, op, newGVOP(OP_GV, 0, gv));
3895 OPCODE type = op->op_type == OP_GREPSTART ? OP_GREPWHILE : OP_MAPWHILE;
3897 op->op_ppaddr = ppaddr[OP_GREPSTART];
3898 Newz(1101, gwop, 1, LOGOP);
3900 if (op->op_flags & OPf_STACKED) {
3903 kid = cLISTOP->op_first->op_sibling;
3904 for (k = cLISTOP->op_first->op_sibling->op_next; k; k = k->op_next) {
3907 kid->op_next = (OP*)gwop;
3908 op->op_flags &= ~OPf_STACKED;
3910 kid = cLISTOP->op_first->op_sibling;
3911 if (type == OP_MAPWHILE)
3918 kid = cLISTOP->op_first->op_sibling;
3919 if (kid->op_type != OP_NULL)
3920 croak("panic: ck_grep");
3921 kid = kUNOP->op_first;
3923 gwop->op_type = type;
3924 gwop->op_ppaddr = ppaddr[type];
3925 gwop->op_first = listkids(op);
3926 gwop->op_flags |= OPf_KIDS;
3927 gwop->op_private = 1;
3928 gwop->op_other = LINKLIST(kid);
3929 gwop->op_targ = pad_alloc(type, SVs_PADTMP);
3930 kid->op_next = (OP*)gwop;
3932 kid = cLISTOP->op_first->op_sibling;
3933 if (!kid || !kid->op_sibling)
3934 return too_few_arguments(op,op_desc[op->op_type]);
3935 for (kid = kid->op_sibling; kid; kid = kid->op_sibling)
3936 mod(kid, OP_GREPSTART);
3945 if (op->op_flags & OPf_KIDS) {
3946 OP *kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
3947 if (kid && kid->op_type == OP_CONST)
3948 fbm_compile(((SVOP*)kid)->op_sv);
3957 /* XXX length optimization goes here */
3965 OPCODE type = op->op_type;
3966 return modkids(ck_fun(op), type);
3973 OPCODE type = op->op_type;
3974 return refkids(ck_fun(op), type);
3983 kid = cLISTOP->op_first;
3985 op = force_list(op);
3986 kid = cLISTOP->op_first;
3988 if (kid->op_type == OP_PUSHMARK)
3989 kid = kid->op_sibling;
3990 if (kid && op->op_flags & OPf_STACKED)
3991 kid = kid->op_sibling;
3992 else if (kid && !kid->op_sibling) { /* print HANDLE; */
3993 if (kid->op_type == OP_CONST && kid->op_private & OPpCONST_BARE) {
3994 op->op_flags |= OPf_STACKED; /* make it a filehandle */
3995 kid = newUNOP(OP_RV2GV, OPf_REF, scalar(kid));
3996 cLISTOP->op_first->op_sibling = kid;
3997 cLISTOP->op_last = kid;
3998 kid = kid->op_sibling;
4003 append_elem(op->op_type, op, newSVREF(newGVOP(OP_GV, 0, defgv)) );
4009 if (hints & HINT_LOCALE)
4010 op->op_private |= OPpLOCALE;
4024 if (hints & HINT_LOCALE)
4025 op->op_private |= OPpLOCALE;
4037 if (hints & HINT_LOCALE)
4038 op->op_private |= OPpLOCALE;
4048 cPMOP->op_pmflags |= PMf_RUNTIME;
4049 cPMOP->op_pmpermflags |= PMf_RUNTIME;
4064 if (cBINOP->op_first->op_flags & OPf_PARENS) {
4065 op->op_private |= OPpREPEAT_DOLIST;
4066 cBINOP->op_first = force_list(cBINOP->op_first);
4077 if (op->op_flags & OPf_KIDS) { /* Shall we supply missing .pm? */
4078 SVOP *kid = (SVOP*)cUNOP->op_first;
4080 if (kid->op_type == OP_CONST && (kid->op_private & OPpCONST_BARE)) {
4082 for (s = SvPVX(kid->op_sv); *s; s++) {
4083 if (*s == ':' && s[1] == ':') {
4085 Move(s+2, s+1, strlen(s+2)+1, char);
4086 --SvCUR(kid->op_sv);
4089 sv_catpvn(kid->op_sv, ".pm", 3);
4099 croak("NOT IMPL LINE %d",__LINE__);
4109 if (op->op_flags & OPf_KIDS) {
4110 kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4111 if (kid && kid->op_sibling) {
4112 op->op_type = OP_SSELECT;
4113 op->op_ppaddr = ppaddr[OP_SSELECT];
4115 return fold_constants(op);
4119 kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4120 if (kid && kid->op_type == OP_RV2GV)
4121 kid->op_private &= ~HINT_STRICT_REFS;
4129 I32 type = op->op_type;
4131 if (!(op->op_flags & OPf_KIDS)) {
4133 return newUNOP(type, 0,
4134 scalar(newUNOP(OP_RV2AV, 0,
4135 scalar(newGVOP(OP_GV, 0, subline
4137 : gv_fetchpv("ARGV", TRUE, SVt_PVAV) )))));
4139 return scalar(modkids(ck_fun(op), type));
4148 if (hints & HINT_LOCALE)
4149 op->op_private |= OPpLOCALE;
4152 if (op->op_flags & OPf_STACKED) {
4153 OP *kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4155 kid = kUNOP->op_first; /* get past rv2gv */
4157 if (kid->op_type == OP_SCOPE || kid->op_type == OP_LEAVE) {
4159 if (kid->op_type == OP_SCOPE) {
4163 else if (kid->op_type == OP_LEAVE) {
4164 if (op->op_type == OP_SORT) {
4165 null(kid); /* wipe out leave */
4168 for (k = kLISTOP->op_first->op_next; k; k = k->op_next) {
4169 if (k->op_next == kid)
4174 kid->op_next = 0; /* just disconnect the leave */
4175 k = kLISTOP->op_first;
4179 kid = cLISTOP->op_first->op_sibling; /* get past pushmark */
4180 null(kid); /* wipe out rv2gv */
4181 if (op->op_type == OP_SORT)
4185 op->op_flags |= OPf_SPECIAL;
4199 if (op->op_flags & OPf_STACKED)
4200 return no_fh_allowed(op);
4202 kid = cLISTOP->op_first;
4203 if (kid->op_type != OP_NULL)
4204 croak("panic: ck_split");
4205 kid = kid->op_sibling;
4206 op_free(cLISTOP->op_first);
4207 cLISTOP->op_first = kid;
4209 cLISTOP->op_first = kid = newSVOP(OP_CONST, 0, newSVpv(" ", 1));
4210 cLISTOP->op_last = kid; /* There was only one element previously */
4213 if (kid->op_type != OP_MATCH) {
4214 OP *sibl = kid->op_sibling;
4215 kid->op_sibling = 0;
4216 kid = pmruntime( newPMOP(OP_MATCH, OPf_SPECIAL), kid, Nullop);
4217 if (cLISTOP->op_first == cLISTOP->op_last)
4218 cLISTOP->op_last = kid;
4219 cLISTOP->op_first = kid;
4220 kid->op_sibling = sibl;
4223 if (pm->op_pmshort && !(pm->op_pmflags & PMf_ALL)) {
4224 SvREFCNT_dec(pm->op_pmshort); /* can't use substring to optimize */
4228 kid->op_type = OP_PUSHRE;
4229 kid->op_ppaddr = ppaddr[OP_PUSHRE];
4232 if (!kid->op_sibling)
4233 append_elem(OP_SPLIT, op, newSVREF(newGVOP(OP_GV, 0, defgv)) );
4235 kid = kid->op_sibling;
4238 if (!kid->op_sibling)
4239 append_elem(OP_SPLIT, op, newSVOP(OP_CONST, 0, newSViv(0)));
4241 kid = kid->op_sibling;
4244 if (kid->op_sibling)
4245 return too_many_arguments(op,op_desc[op->op_type]);
4254 OP *prev = ((cUNOP->op_first->op_sibling)
4255 ? cUNOP : ((UNOP*)cUNOP->op_first))->op_first;
4256 OP *o = prev->op_sibling;
4263 for (cvop = o; cvop->op_sibling; cvop = cvop->op_sibling) ;
4264 if (cvop->op_type == OP_RV2CV) {
4266 op->op_private |= (cvop->op_private & OPpENTERSUB_AMPER);
4267 null(cvop); /* disable rv2cv */
4268 tmpop = (SVOP*)((UNOP*)cvop)->op_first;
4269 if (tmpop->op_type == OP_GV) {
4270 cv = GvCVu(tmpop->op_sv);
4271 if (cv && SvPOK(cv) && !(op->op_private & OPpENTERSUB_AMPER))
4272 proto = SvPV((SV*)cv,na);
4275 op->op_private |= (hints & HINT_STRICT_REFS);
4276 if (perldb && curstash != debstash)
4277 op->op_private |= OPpENTERSUB_DB;
4282 return too_many_arguments(op, CvNAME(cv));
4300 if (o->op_type != OP_REFGEN && o->op_type != OP_UNDEF)
4301 bad_type(arg, "block", CvNAME(cv), o);
4306 if (o->op_type == OP_RV2GV)
4310 o = newUNOP(OP_RV2GV, 0, kid);
4311 o->op_sibling = kid->op_sibling;
4312 kid->op_sibling = 0;
4313 prev->op_sibling = o;
4321 if (o->op_type != OP_RV2GV)
4322 bad_type(arg, "symbol", CvNAME(cv), o);
4325 if (o->op_type != OP_RV2CV)
4326 bad_type(arg, "sub", CvNAME(cv), o);
4329 if (o->op_type != OP_RV2SV && o->op_type != OP_PADSV)
4330 bad_type(arg, "scalar", CvNAME(cv), o);
4333 if (o->op_type != OP_RV2AV && o->op_type != OP_PADAV)
4334 bad_type(arg, "array", CvNAME(cv), o);
4337 if (o->op_type != OP_RV2HV && o->op_type != OP_PADHV)
4338 bad_type(arg, "hash", CvNAME(cv), o);
4342 o = newUNOP(OP_REFGEN, 0, kid);
4343 o->op_sibling = kid->op_sibling;
4344 kid->op_sibling = 0;
4345 prev->op_sibling = o;
4356 croak("Malformed prototype for %s: %s",
4357 CvNAME(cv),SvPV((SV*)cv,na));
4362 mod(o, OP_ENTERSUB);
4366 if (proto && !optional && *proto == '$')
4367 return too_few_arguments(op, CvNAME(cv));
4375 SvREADONLY_on(cSVOP->op_sv);
4383 if (op->op_flags & OPf_KIDS) {
4384 SVOP *kid = (SVOP*)cUNOP->op_first;
4386 if (kid->op_type == OP_NULL)
4387 kid = (SVOP*)kid->op_sibling;
4389 kid->op_type == OP_CONST && (kid->op_private & OPpCONST_BARE))
4390 op->op_flags |= OPf_SPECIAL;
4395 /* A peephole optimizer. We visit the ops in the order they're to execute. */
4401 register OP* oldop = 0;
4402 if (!o || o->op_seq)
4407 for (; o; o = o->op_next) {
4413 switch (o->op_type) {
4416 curcop = ((COP*)o); /* for warnings */
4417 o->op_seq = op_seqmax++;
4428 if (o->op_next->op_type == OP_STRINGIFY)
4430 o->op_seq = op_seqmax++;
4433 if ((o->op_flags & (OPf_KNOW|OPf_LIST)) != (OPf_KNOW|OPf_LIST)) {
4434 o->op_seq = op_seqmax++;
4435 break; /* Scalar stub must produce undef. List stub is noop */
4439 if (o->op_targ == OP_NEXTSTATE || o->op_targ == OP_DBSTATE)
4440 curcop = ((COP*)op);
4446 if (oldop && o->op_next) {
4447 oldop->op_next = o->op_next;
4450 o->op_seq = op_seqmax++;
4454 if (o->op_next->op_type == OP_RV2SV) {
4455 if (!(o->op_next->op_private & OPpDEREF)) {
4457 o->op_private |= o->op_next->op_private & OPpLVAL_INTRO;
4458 o->op_next = o->op_next->op_next;
4459 o->op_type = OP_GVSV;
4460 o->op_ppaddr = ppaddr[OP_GVSV];
4463 else if (o->op_next->op_type == OP_RV2AV) {
4464 OP* pop = o->op_next->op_next;
4466 if (pop->op_type == OP_CONST &&
4467 (op = pop->op_next) &&
4468 pop->op_next->op_type == OP_AELEM &&
4469 !(pop->op_next->op_private & (OPpDEREF|OPpLVAL_INTRO)) &&
4470 (i = SvIV(((SVOP*)pop)->op_sv) - compiling.cop_arybase)
4474 SvREFCNT_dec(((SVOP*)pop)->op_sv);
4478 o->op_flags |= pop->op_next->op_flags & OPf_MOD;
4479 o->op_next = pop->op_next->op_next;
4480 o->op_type = OP_AELEMFAST;
4481 o->op_ppaddr = ppaddr[OP_AELEMFAST];
4482 o->op_private = (U8)i;
4483 GvAVn(((GVOP*)o)->op_gv);
4486 o->op_seq = op_seqmax++;
4493 o->op_seq = op_seqmax++;
4494 peep(cLOGOP->op_other);
4498 o->op_seq = op_seqmax++;
4499 peep(cCONDOP->op_true);
4500 peep(cCONDOP->op_false);
4504 o->op_seq = op_seqmax++;
4505 peep(cLOOP->op_redoop);
4506 peep(cLOOP->op_nextop);
4507 peep(cLOOP->op_lastop);
4512 o->op_seq = op_seqmax++;
4513 peep(cPMOP->op_pmreplstart);
4517 o->op_seq = op_seqmax++;
4518 if (dowarn && o->op_next && o->op_next->op_type == OP_NEXTSTATE) {
4519 if (o->op_next->op_sibling &&
4520 o->op_next->op_sibling->op_type != OP_DIE) {
4521 line_t oldline = curcop->cop_line;
4523 curcop->cop_line = ((COP*)o->op_next)->cop_line;
4524 warn("Statement unlikely to be reached");
4525 warn("(Maybe you meant system() when you said exec()?)\n");
4526 curcop->cop_line = oldline;
4531 o->op_seq = op_seqmax++;