X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/809abb02185a4df0f7a1a043727bae7a5c08a798..4319409baa063eddacb1cc10ffb52369b987af67:/pad.h diff --git a/pad.h b/pad.h index d057211..33717d3 100644 --- a/pad.h +++ b/pad.h @@ -1,6 +1,6 @@ /* pad.h * - * Copyright (C) 2002, 2003, 2005, by Larry Wall and others + * Copyright (C) 2002, 2003, 2005, 2006, 2007 by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -33,12 +33,66 @@ typedef U64TYPE PADOFFSET; /* B.xs needs these for the benefit of B::Deparse */ /* Low range end is exclusive (valid from the cop seq after this one) */ -#define COP_SEQ_RANGE_LOW(sv) U_32(SvNVX(sv)) /* High range end is inclusive (valid up to this cop seq) */ -#define COP_SEQ_RANGE_HIGH(sv) U_32(SvUVX(sv)) -#define PARENT_PAD_INDEX(sv) U_32(SvNVX(sv)) -#define PARENT_FAKELEX_FLAGS(sv) U_32(SvUVX(sv)) +#if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) +# define COP_SEQ_RANGE_LOW(sv) \ + (({ SV *const _svi = (SV *) (sv); \ + assert(SvTYPE(_svi) == SVt_NV || SvTYPE(_svi) >= SVt_PVNV); \ + assert(SvTYPE(_svi) != SVt_PVAV); \ + assert(SvTYPE(_svi) != SVt_PVHV); \ + assert(SvTYPE(_svi) != SVt_PVCV); \ + assert(SvTYPE(_svi) != SVt_PVFM); \ + assert(!isGV_with_GP(_svi)); \ + ((XPVNV*) SvANY(_svi))->xnv_u.xpad_cop_seq.xlow; \ + })) +# define COP_SEQ_RANGE_HIGH(sv) \ + (({ SV *const _svi = (SV *) (sv); \ + assert(SvTYPE(_svi) == SVt_NV || SvTYPE(_svi) >= SVt_PVNV); \ + assert(SvTYPE(_svi) != SVt_PVAV); \ + assert(SvTYPE(_svi) != SVt_PVHV); \ + assert(SvTYPE(_svi) != SVt_PVCV); \ + assert(SvTYPE(_svi) != SVt_PVFM); \ + assert(!isGV_with_GP(_svi)); \ + ((XPVNV*) SvANY(_svi))->xnv_u.xpad_cop_seq.xhigh; \ + })) +# define PARENT_PAD_INDEX(sv) \ + (({ SV *const _svi = (SV *) (sv); \ + assert(SvTYPE(_svi) == SVt_NV || SvTYPE(_svi) >= SVt_PVNV); \ + assert(SvTYPE(_svi) != SVt_PVAV); \ + assert(SvTYPE(_svi) != SVt_PVHV); \ + assert(SvTYPE(_svi) != SVt_PVCV); \ + assert(SvTYPE(_svi) != SVt_PVFM); \ + assert(!isGV_with_GP(_svi)); \ + ((XPVNV*) SvANY(_svi))->xnv_u.xpad_cop_seq.xlow; \ + })) +# define PARENT_FAKELEX_FLAGS(sv) \ + (({ SV *const _svi = (SV *) (sv); \ + assert(SvTYPE(_svi) == SVt_NV || SvTYPE(_svi) >= SVt_PVNV); \ + assert(SvTYPE(_svi) != SVt_PVAV); \ + assert(SvTYPE(_svi) != SVt_PVHV); \ + assert(SvTYPE(_svi) != SVt_PVCV); \ + assert(SvTYPE(_svi) != SVt_PVFM); \ + assert(!isGV_with_GP(_svi)); \ + ((XPVNV*) SvANY(_svi))->xnv_u.xpad_cop_seq.xhigh; \ + })) +#else +# define COP_SEQ_RANGE_LOW(sv) \ + (0 + (((XPVNV*) SvANY(sv))->xnv_u.xpad_cop_seq.xlow)) +# define COP_SEQ_RANGE_HIGH(sv) \ + (0 + (((XPVNV*) SvANY(sv))->xnv_u.xpad_cop_seq.xhigh)) + + +# define PARENT_PAD_INDEX(sv) \ + (0 + (((XPVNV*) SvANY(sv))->xnv_u.xpad_cop_seq.xlow)) +# define PARENT_FAKELEX_FLAGS(sv) \ + (0 + (((XPVNV*) SvANY(sv))->xnv_u.xpad_cop_seq.xhigh)) +#endif + +/* Flags set in the SvIVX field of FAKE namesvs */ + +#define PAD_FAKELEX_ANON 1 /* the lex is declared in an ANON, or ... */ +#define PAD_FAKELEX_MULTI 2 /* the lex can be instantiated multiple times */ /* flags for the pad_new() function */ @@ -222,37 +276,37 @@ Assumes the slot entry is a valid C lexical. =for apidoc m|STRLEN|PAD_COMPNAME_GEN|PADOFFSET po The generation number of the name at offset C in the current -compiling pad (lvalue). Note that C is hijacked for this purpose. +compiling pad (lvalue). Note that C is hijacked for this purpose. =for apidoc m|STRLEN|PAD_COMPNAME_GEN_set|PADOFFSET po|int gen Sets the generation number of the name at offset C in the current -ling pad (lvalue) to C. Note that C is hijacked for this purpose. +ling pad (lvalue) to C. Note that C is hijacked for this purpose. =cut */ -#define PAD_COMPNAME_FLAGS(po) SvFLAGS(*av_fetch(PL_comppad_name, (po), FALSE)) +#define PAD_COMPNAME_SV(po) (*av_fetch(PL_comppad_name, (po), FALSE)) +#define PAD_COMPNAME_FLAGS(po) SvFLAGS(PAD_COMPNAME_SV(po)) #define PAD_COMPNAME_FLAGS_isOUR(po) \ ((PAD_COMPNAME_FLAGS(po) & (SVpad_NAME|SVpad_OUR)) == (SVpad_NAME|SVpad_OUR)) -#define PAD_COMPNAME_PV(po) SvPV_nolen(*av_fetch(PL_comppad_name, (po), FALSE)) +#define PAD_COMPNAME_PV(po) SvPV_nolen(PAD_COMPNAME_SV(po)) #define PAD_COMPNAME_TYPE(po) pad_compname_type(po) #define PAD_COMPNAME_OURSTASH(po) \ - (OURSTASH(*av_fetch(PL_comppad_name, (po), FALSE))) + (SvOURSTASH(PAD_COMPNAME_SV(po))) -#define PAD_COMPNAME_GEN(po) SvCUR(AvARRAY(PL_comppad_name)[po]) +#define PAD_COMPNAME_GEN(po) ((STRLEN)SvUVX(AvARRAY(PL_comppad_name)[po])) -#define PAD_COMPNAME_GEN_set(po, gen) SvCUR_set(AvARRAY(PL_comppad_name)[po], gen) +#define PAD_COMPNAME_GEN_set(po, gen) SvUV_set(AvARRAY(PL_comppad_name)[po], (UV)(gen)) /* =for apidoc m|void|PAD_DUP|PADLIST dstpad|PADLIST srcpad|CLONE_PARAMS* param Clone a padlist. -=for apidoc m|void|PAD_CLONE_VARS|PerlInterpreter *proto_perl \ -|CLONE_PARAMS* param +=for apidoc m|void|PAD_CLONE_VARS|PerlInterpreter *proto_perl|CLONE_PARAMS* param Clone the state variables associated with running and compiling pads. =cut @@ -290,3 +344,13 @@ Clone the state variables associated with running and compiling pads. PL_padix_floor = proto_perl->Ipadix_floor; \ PL_pad_reset_pending = proto_perl->Ipad_reset_pending; \ PL_cop_seqmax = proto_perl->Icop_seqmax; + +/* + * Local variables: + * c-indentation-style: bsd + * c-basic-offset: 4 + * indent-tabs-mode: t + * End: + * + * ex: set ts=8 sts=4 sw=4 noet: + */