cop.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/* cop.h
*
* Copyright (c) 1991-2001, Larry Wall
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
*
*/
struct cop {
char * cop_label; /* label for this construct */
#ifdef USE_ITHREADS
char * cop_stashpv; /* package line was compiled in */
char * cop_file; /* file name the following line # is from */
#else
#endif
};
#ifdef USE_ITHREADS
# define CopSTASHPV(c) ((c)->cop_stashpv)
# define CopSTASH(c) (CopSTASHPV(c) \
#else
# define CopFILEGV(c) ((c)->cop_filegv)
/* cop_stash is not refcounted */
#endif /* USE_ITHREADS */
#define CopLINE_inc(c) (++CopLINE(c))
#define CopLINE_dec(c) (--CopLINE(c))
#define CopLINE_set(c,l) (CopLINE(c) = (l))
/*
* Here we have some enormously heavy (or at least ponderous) wizardry.
*/
/* subroutine context */
struct block_sub {
#ifndef USE_THREADS
#endif /* USE_THREADS */
};
#define PUSHFORMAT(cx) \
#ifdef USE_THREADS
# define POP_SAVEARRAY() NOOP
#else
# define POP_SAVEARRAY() \
STMT_START { \
} STMT_END
#endif /* USE_THREADS */
/* junk in @_ spells trouble when cloning CVs and in pp_caller(), so don't
* leave any (a fast av_clear(ary), basically) */
#define CLEAR_ARGARRAY(ary) \
STMT_START { \
} STMT_END
STMT_START { \
POP_SAVEARRAY(); \
/* abandon @_ if it got reified */ \
} \
else { \
} \
} \
} STMT_END
STMT_START { \
if (sv) \
SvREFCNT_dec(sv); \
} STMT_END
/* eval context */
struct block_eval {
SV * old_namesv;
OP * old_eval_root;
};
STMT_START { \
} STMT_END
STMT_START { \
} STMT_END
/* loop context */
struct block_loop {
char * label;
#ifdef USE_ITHREADS
void * iterdata;
#else
#endif
};
#ifdef USE_ITHREADS
# define CxITERVAR(c) \
#else
#endif
sv_2mortal(*s_v_p); \
} \
/* context common to subroutines, evals and loops */
struct block {
union {
struct block_eval blku_eval;
struct block_loop blku_loop;
} blk_u;
};
/* Enter a block. */
/* Exit a block (RETURN and LAST). */
/* Continue a block elsewhere (NEXT and REDO). */
/* substitution context */
struct subst {
bool sbu_once;
bool sbu_rxtainted;
char * sbu_orig;
char * sbu_s;
char * sbu_m;
char * sbu_strend;
void * sbu_rxres;
};
struct context {
union {
} cx_u;
};
#define CXTYPEMASK 0xff
#define CXt_NULL 0
#define CXt_SUB 1
#define CXt_EVAL 2
#define CXt_LOOP 3
#define CXt_SUBST 4
#define CXt_BLOCK 5
#define CXt_FORMAT 6
/* private flags for CXt_EVAL */
#ifdef USE_ITHREADS
/* private flags for CXt_LOOP */
has pad offset; if not set,
iterdata holds GV* */
== (CXt_LOOP|CXp_PADVAR))
#endif
== (CXt_EVAL|CXp_TRYBLOCK))
/* "gimme" values */
/*
=for apidoc AmU||G_SCALAR
Used to indicate scalar context. See C<GIMME_V>, C<GIMME>, and
L<perlcall>.
=for apidoc AmU||G_ARRAY
Used to indicate list context. See C<GIMME_V>, C<GIMME> and
L<perlcall>.
=for apidoc AmU||G_VOID
Used to indicate void context. See C<GIMME_V> and L<perlcall>.
=for apidoc AmU||G_DISCARD
Indicates that arguments returned from a callback should be discarded. See
L<perlcall>.
=for apidoc AmU||G_EVAL
Used to force a Perl C<eval> wrapper around a callback. See
L<perlcall>.
=for apidoc AmU||G_NOARGS
Indicates that no arguments are being sent to a callback. See
L<perlcall>.
=cut
*/
#define G_SCALAR 0
#define G_ARRAY 1
/* extra flags for Perl_call_* routines */
/* flag bits for PL_in_eval */
#define EVAL_NULL 0 /* not in an eval */
/* Support for switching (stack and block) contexts.
* This ensures magic doesn't invalidate local stack and cx pointers.
*/
#define PERLSI_UNKNOWN -1
#define PERLSI_UNDEF 0
#define PERLSI_MAIN 1
#define PERLSI_MAGIC 2
#define PERLSI_SORT 3
#define PERLSI_SIGNAL 4
#define PERLSI_OVERLOAD 5
#define PERLSI_DESTROY 6
#define PERLSI_WARNHOOK 7
#define PERLSI_DIEHOOK 8
#define PERLSI_REQUIRE 9
struct stackinfo {
* currently used only with DEBUGGING,
* but not #ifdef-ed for bincompat */
};
#ifdef DEBUGGING
# define SET_MARK_OFFSET \
#else
# define SET_MARK_OFFSET NOOP
#endif
#define PUSHSTACKi(type) \
STMT_START { \
if (!next) { \
} \
PL_curstackinfo = next; \
} STMT_END
/* POPSTACK works with PL_stack_sp, so it may need to be bracketed by
#define POPSTACK \
STMT_START { \
dSP; \
if (!prev) { \
my_exit(1); \
} \
/* don't free prev here, free them all at the END{} */ \
PL_curstackinfo = prev; \
} STMT_END
#define POPSTACK_TO(s) \
STMT_START { \
while (PL_curstack != s) { \
dounwind(-1); \
POPSTACK; \
} \
} STMT_END