This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
make die/warn and other diagnostics go to wherever STDERR happens
[perl5.git] / cop.h
diff --git a/cop.h b/cop.h
index 6529974..829bbe8 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -35,12 +35,15 @@ struct block_sub {
     AV *       argarray;
     U16                olddepth;
     U8         hasargs;
+    U8         lval;           /* XXX merge lval and hasargs? */
 };
 
 #define PUSHSUB(cx)                                                    \
        cx->blk_sub.cv = cv;                                            \
        cx->blk_sub.olddepth = CvDEPTH(cv);                             \
-       cx->blk_sub.hasargs = hasargs;
+       cx->blk_sub.hasargs = hasargs;                                  \
+       cx->blk_sub.lval = PL_op->op_private &                          \
+                             (OPpLVAL_INTRO|OPpENTERSUB_INARGS);
 
 #define PUSHFORMAT(cx)                                                 \
        cx->blk_sub.cv = cv;                                            \
@@ -63,16 +66,22 @@ struct block_sub {
 #define POPSAVEARRAY()                                                 \
     STMT_START {                                                       \
        SvREFCNT_dec(GvAV(PL_defgv));                                   \
-       GvAV(PL_defgv) = cxsub.savearray;                                       \
+       GvAV(PL_defgv) = cxsub.savearray;                               \
     } STMT_END
 #endif /* USE_THREADS */
 
 #define POPSUB2()                                                      \
        if (cxsub.hasargs) {                                            \
            POPSAVEARRAY();                                             \
-           /* destroy arg array */                                     \
-           av_clear(cxsub.argarray);                                   \
-           AvREAL_off(cxsub.argarray);                                 \
+           /* abandon @_ if it got reified */                          \
+           if (AvREAL(cxsub.argarray)) {                               \
+               SSize_t fill = AvFILLp(cxsub.argarray);                 \
+               SvREFCNT_dec(cxsub.argarray);                           \
+               cxsub.argarray = newAV();                               \
+               av_extend(cxsub.argarray, fill);                        \
+               AvFLAGS(cxsub.argarray) = AVf_REIFY;                    \
+               PL_curpad[0] = (SV*)cxsub.argarray;                     \
+           }                                                           \
        }                                                               \
        if (cxsub.cv) {                                                 \
            if (!(CvDEPTH(cxsub.cv) = cxsub.olddepth))                  \
@@ -186,7 +195,7 @@ struct block {
        cx->blk_oldretsp        = PL_retstack_ix,                       \
        cx->blk_oldpm           = PL_curpm,                             \
        cx->blk_gimme           = gimme;                                \
-       DEBUG_l( PerlIO_printf(PerlIO_stderr(), "Entering block %ld, type %s\n",        \
+       DEBUG_l( PerlIO_printf(Perl_debug_log, "Entering block %ld, type %s\n", \
                    (long)cxstack_ix, PL_block_type[CxTYPE(cx)]); )
 
 /* Exit a block (RETURN and LAST). */
@@ -198,7 +207,7 @@ struct block {
        PL_retstack_ix   = cx->blk_oldretsp,                            \
        pm               = cx->blk_oldpm,                               \
        gimme            = cx->blk_gimme;                               \
-       DEBUG_l( PerlIO_printf(PerlIO_stderr(), "Leaving block %ld, type %s\n",         \
+       DEBUG_l( PerlIO_printf(Perl_debug_log, "Leaving block %ld, type %s\n",          \
                    (long)cxstack_ix+1,PL_block_type[CxTYPE(cx)]); )
 
 /* Continue a block elsewhere (NEXT and REDO). */
@@ -291,12 +300,19 @@ struct context {
 #define G_ARRAY                1
 #define G_VOID         128     /* skip this bit when adding flags below */
 
-/* extra flags for perl_call_* routines */
+/* extra flags for Perl_call_* routines */
 #define G_DISCARD      2       /* Call FREETMPS. */
 #define G_EVAL         4       /* Assume eval {} around subroutine call. */
 #define G_NOARGS       8       /* Don't construct a @_ array. */
 #define G_KEEPERR      16      /* Append errors to $@, don't overwrite it */
 #define G_NODEBUG      32      /* Disable debugging at toplevel.  */
+#define G_NOCATCH      64       /* Don't do CATCH_SET() */
+
+/* flag bits for PL_in_eval */
+#define EVAL_NULL      0       /* not in an eval */
+#define EVAL_INEVAL    1       /* some enclosing scope is an eval */
+#define EVAL_WARNONLY  2       /* used by yywarn() when calling yyerror() */
+#define EVAL_KEEPERR   4       /* set by Perl_call_sv if G_KEEPERR */
 
 /* Support for switching (stack and block) contexts.
  * This ensures magic doesn't invalidate local stack and cx pointers.
@@ -364,7 +380,7 @@ typedef struct stackinfo PERL_SI;
        djSP;                                                           \
        PERL_SI *prev = PL_curstackinfo->si_prev;                       \
        if (!prev) {                                                    \
-           PerlIO_printf(PerlIO_stderr(), "panic: POPSTACK\n");        \
+           PerlIO_printf(Perl_error_log, "panic: POPSTACK\n");         \
            my_exit(1);                                                 \
        }                                                               \
        SWITCHSTACK(PL_curstack,prev->si_stack);                        \