📄 op.h
字号:
/* op.h * * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, * 2000, 2001, 2002, 2003, 2004, 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. * *//* * The fields of BASEOP are: * op_next Pointer to next ppcode to execute after this one. * (Top level pre-grafted op points to first op, * but this is replaced when op is grafted in, when * this op will point to the real next op, and the new * parent takes over role of remembering starting op.) * op_ppaddr Pointer to current ppcode's function. * op_type The type of the operation. * op_opt Whether or not the op has been optimised by the * peephole optimiser. * * See the comments in S_clear_yystack() for more * details on the following three flags: * * op_latefree tell op_free() to clear this op (and free any kids) * but not yet deallocate the struct. This means that * the op may be safely op_free()d multiple times * op_latefreed an op_latefree op has been op_free()d * op_attached this op (sub)tree has been attached to a CV * * op_spare three spare bits! * op_flags Flags common to all operations. See OPf_* below. * op_private Flags peculiar to a particular operation (BUT, * by default, set to the number of children until * the operation is privatized by a check routine, * which may or may not check number of children). */#define OPCODE U16#ifdef PERL_MAD# define MADPROP_IN_BASEOP MADPROP* op_madprop;#else# define MADPROP_IN_BASEOP#endif#ifdef BASEOP_DEFINITION#define BASEOP BASEOP_DEFINITION#else#define BASEOP \ OP* op_next; \ OP* op_sibling; \ OP* (CPERLscope(*op_ppaddr))(pTHX); \ MADPROP_IN_BASEOP \ PADOFFSET op_targ; \ unsigned op_type:9; \ unsigned op_opt:1; \ unsigned op_latefree:1; \ unsigned op_latefreed:1; \ unsigned op_attached:1; \ unsigned op_spare:3; \ U8 op_flags; \ U8 op_private;#endif#define OP_GIMME(op,dfl) \ (((op)->op_flags & OPf_WANT) == OPf_WANT_VOID ? G_VOID : \ ((op)->op_flags & OPf_WANT) == OPf_WANT_SCALAR ? G_SCALAR : \ ((op)->op_flags & OPf_WANT) == OPf_WANT_LIST ? G_ARRAY : \ dfl)/*=head1 "Gimme" Values=for apidoc Amn|U32|GIMME_VThe XSUB-writer's equivalent to Perl's C<wantarray>. Returns C<G_VOID>,C<G_SCALAR> or C<G_ARRAY> for void, scalar or list context,respectively.=for apidoc Amn|U32|GIMMEA backward-compatible version of C<GIMME_V> which can only returnC<G_SCALAR> or C<G_ARRAY>; in a void context, it returns C<G_SCALAR>.Deprecated. Use C<GIMME_V> instead.=cut*/#define GIMME_V OP_GIMME(PL_op, block_gimme())/* Public flags */#define OPf_WANT 3 /* Mask for "want" bits: */#define OPf_WANT_VOID 1 /* Want nothing */#define OPf_WANT_SCALAR 2 /* Want single value */#define OPf_WANT_LIST 3 /* Want list of any length */#define OPf_KIDS 4 /* There is a firstborn child. */#define OPf_PARENS 8 /* This operator was parenthesized. */ /* (Or block needs explicit scope entry.) */#define OPf_REF 16 /* Certified reference. */ /* (Return container, not containee). */#define OPf_MOD 32 /* Will modify (lvalue). */#define OPf_STACKED 64 /* Some arg is arriving on the stack. */#define OPf_SPECIAL 128 /* Do something weird for this op: */ /* On local LVAL, don't init local value. */ /* On OP_CONST, value is the hints hash for eval, so return a copy from pp_const() */ /* On OP_SORT, subroutine is inlined. */ /* On OP_NOT, inversion was implicit. */ /* On OP_LEAVE, don't restore curpm. */ /* On truncate, we truncate filehandle */ /* On control verbs, we saw no label */ /* On flipflop, we saw ... instead of .. */ /* On UNOPs, saw bare parens, e.g. eof(). */ /* On OP_ENTERSUB || OP_NULL, saw a "do". */ /* On OP_EXISTS, treat av as av, not avhv. */ /* On OP_(ENTER|LEAVE)EVAL, don't clear $@ */ /* On OP_ENTERITER, loop var is per-thread */ /* On pushre, rx is used as part of split, e.g. split " " */ /* On regcomp, "use re 'eval'" was in scope */ /* On OP_READLINE, was <$filehandle> */ /* On RV2[ACGHS]V, don't create GV--in defined()*/ /* On OP_DBSTATE, indicates breakpoint * (runtime property) */ /* On OP_AELEMFAST, indiciates pad var */ /* On OP_REQUIRE, was seen as CORE::require */ /* On OP_ENTERWHEN, there's no condition */ /* On OP_BREAK, an implicit break */ /* On OP_SMARTMATCH, an implicit smartmatch */ /* On OP_ANONHASH and OP_ANONLIST, create a reference to the new anon hash or array *//* old names; don't use in new code, but don't break them, either */#define OPf_LIST OPf_WANT_LIST#define OPf_KNOW OPf_WANT#define GIMME \ (PL_op->op_flags & OPf_WANT \ ? ((PL_op->op_flags & OPf_WANT) == OPf_WANT_LIST \ ? G_ARRAY \ : G_SCALAR) \ : dowantarray())/* NOTE: OP_NEXTSTATE, OP_DBSTATE, and OP_SETSTATE (i.e. COPs) carry lower * bits of PL_hints in op_private *//* Private for lvalues */#define OPpLVAL_INTRO 128 /* Lvalue must be localized or lvalue sub *//* Private for OP_LEAVE, OP_LEAVESUB, OP_LEAVESUBLV and OP_LEAVEWRITE */#define OPpREFCOUNTED 64 /* op_targ carries a refcount *//* Private for OP_AASSIGN */#define OPpASSIGN_COMMON 64 /* Left & right have syms in common. *//* Private for OP_SASSIGN */#define OPpASSIGN_BACKWARDS 64 /* Left & right switched. */#define OPpASSIGN_CV_TO_GV 128 /* Possible optimisation for constants. *//* Private for OP_MATCH and OP_SUBST{,CONST} */#define OPpRUNTIME 64 /* Pattern coming in on the stack *//* Private for OP_TRANS */#define OPpTRANS_FROM_UTF 1#define OPpTRANS_TO_UTF 2#define OPpTRANS_IDENTICAL 4 /* right side is same as left */#define OPpTRANS_SQUASH 8 /* 16 is used for OPpTARGET_MY */#define OPpTRANS_COMPLEMENT 32#define OPpTRANS_GROWS 64#define OPpTRANS_DELETE 128#define OPpTRANS_ALL (OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF|OPpTRANS_IDENTICAL|OPpTRANS_SQUASH|OPpTRANS_COMPLEMENT|OPpTRANS_GROWS|OPpTRANS_DELETE)/* Private for OP_REPEAT */#define OPpREPEAT_DOLIST 64 /* List replication. *//* Private for OP_RV2GV, OP_RV2SV, OP_AELEM, OP_HELEM, OP_PADSV */#define OPpDEREF (32|64) /* autovivify: Want ref to something: */#define OPpDEREF_AV 32 /* Want ref to AV. */#define OPpDEREF_HV 64 /* Want ref to HV. */#define OPpDEREF_SV (32|64) /* Want ref to SV. */ /* OP_ENTERSUB only */#define OPpENTERSUB_DB 16 /* Debug subroutine. */#define OPpENTERSUB_HASTARG 32 /* Called from OP tree. */#define OPpENTERSUB_NOMOD 64 /* Immune to mod() for :attrlist. */ /* OP_RV2CV only */#define OPpENTERSUB_AMPER 8 /* Used & form to call. */#define OPpENTERSUB_NOPAREN 128 /* bare sub call (without parens) */#define OPpENTERSUB_INARGS 4 /* Lval used as arg to a sub. */ /* OP_GV only */#define OPpEARLY_CV 32 /* foo() called before sub foo was parsed */ /* OP_?ELEM only */#define OPpLVAL_DEFER 16 /* Defer creation of array/hash elem */ /* OP_RV2?V, OP_GVSV, OP_ENTERITER only */#define OPpOUR_INTRO 16 /* Variable was in an our() */ /* OP_RV2[AGH]V, OP_PAD[AH]V, OP_[AH]ELEM */#define OPpMAYBE_LVSUB 8 /* We might be an lvalue to return */ /* OP_PADSV only */#define OPpPAD_STATE 16 /* is a "state" pad */ /* for OP_RV2?V, lower bits carry hints (currently only HINT_STRICT_REFS) */ /* OP_RV2GV only */#define OPpDONT_INIT_GV 4 /* Call gv_fetchpv with GV_NOINIT *//* (Therefore will return whatever is currently in the symbol table, not guaranteed to be a PVGV) */ /* OP_RV2CV only */#define OPpMAY_RETURN_CONSTANT 1 /* If a constant sub, return the constant *//* Private for OPs with TARGLEX */ /* (lower bits may carry MAXARG) */#define OPpTARGET_MY 16 /* Target is PADMY. *//* Private for OP_ENTERITER and OP_ITER */#define OPpITER_REVERSED 4 /* for (reverse ...) */#define OPpITER_DEF 8 /* for $_ or for my $_ *//* Private for OP_CONST */#define OPpCONST_NOVER 2 /* no 6; */#define OPpCONST_SHORTCIRCUIT 4 /* eg the constant 5 in (5 || foo) */#define OPpCONST_STRICT 8 /* bearword subject to strict 'subs' */#define OPpCONST_ENTERED 16 /* Has been entered as symbol. */#define OPpCONST_ARYBASE 32 /* Was a $[ translated to constant. */#define OPpCONST_BARE 64 /* Was a bare word (filehandle?). */#define OPpCONST_WARNING 128 /* Was a $^W translated to constant. *//* Private for OP_FLIP/FLOP */#define OPpFLIP_LINENUM 64 /* Range arg potentially a line num. *//* Private for OP_LIST */#define OPpLIST_GUESSED 64 /* Guessed that pushmark was needed. *//* Private for OP_DELETE */#define OPpSLICE 64 /* Operating on a list of keys *//* Private for OP_EXISTS */#define OPpEXISTS_SUB 64 /* Checking for &sub, not {} or []. *//* Private for OP_SORT */#define OPpSORT_NUMERIC 1 /* Optimized away { $a <=> $b } */#define OPpSORT_INTEGER 2 /* Ditto while under "use integer" */#define OPpSORT_REVERSE 4 /* Reversed sort */#define OPpSORT_INPLACE 8 /* sort in-place; eg @a = sort @a */#define OPpSORT_DESCEND 16 /* Descending sort */#define OPpSORT_QSORT 32 /* Use quicksort (not mergesort) */#define OPpSORT_STABLE 64 /* Use a stable algorithm *//* Private for OP_THREADSV */#define OPpDONE_SVREF 64 /* Been through newSVREF once *//* Private for OP_OPEN and OP_BACKTICK */#define OPpOPEN_IN_RAW 16 /* binmode(F,":raw") on input fh */#define OPpOPEN_IN_CRLF 32 /* binmode(F,":crlf") on input fh */#define OPpOPEN_OUT_RAW 64 /* binmode(F,":raw") on output fh */#define OPpOPEN_OUT_CRLF 128 /* binmode(F,":crlf") on output fh *//* Private for OP_EXIT, HUSH also for OP_DIE */#define OPpHUSH_VMSISH 64 /* hush DCL exit msg vmsish mode*/#define OPpEXIT_VMSISH 128 /* exit(0) vs. exit(1) vmsish mode*//* Private for OP_FTXXX */#define OPpFT_ACCESS 2 /* use filetest 'access' */#define OPpFT_STACKED 4 /* stacked filetest, as in "-f -x $f" */#define OP_IS_FILETEST_ACCESS(op) \ (((op)->op_type) == OP_FTRREAD || \ ((op)->op_type) == OP_FTRWRITE || \ ((op)->op_type) == OP_FTREXEC || \ ((op)->op_type) == OP_FTEREAD || \ ((op)->op_type) == OP_FTEWRITE || \ ((op)->op_type) == OP_FTEEXEC)/* Private for OP_(MAP|GREP)(WHILE|START) */#define OPpGREP_LEX 2 /* iterate over lexical $_ */ /* Private for OP_ENTEREVAL */#define OPpEVAL_HAS_HH 2 /* Does it have a copy of %^H */ struct op { BASEOP};struct unop { BASEOP OP * op_first;};struct binop { BASEOP OP * op_first; OP * op_last;};struct logop { BASEOP OP * op_first; OP * op_other;};struct listop { BASEOP OP * op_first; OP * op_last;};struct pmop { BASEOP OP * op_first; OP * op_last;#ifdef USE_ITHREADS IV op_pmoffset;#else REGEXP * op_pmregexp; /* compiled expression */#endif U32 op_pmflags; union { OP * op_pmreplroot; /* For OP_SUBST */#ifdef USE_ITHREADS PADOFFSET op_pmtargetoff; /* For OP_PUSHRE */#else GV * op_pmtargetgv;#endif } op_pmreplrootu; union { OP * op_pmreplstart; /* Only used in OP_SUBST */#ifdef USE_ITHREADS char * op_pmstashpv; /* Only used in OP_MATCH, with PMf_ONCE set */#else HV * op_pmstash;#endif } op_pmstashstartu;};#ifdef USE_ITHREADS#define PM_GETRE(o) (INT2PTR(REGEXP*,SvIVX(PL_regex_pad[(o)->op_pmoffset])))#define PM_SETRE(o,r) STMT_START { \ SV* const sv = PL_regex_pad[(o)->op_pmoffset]; \ sv_setiv(sv, PTR2IV(r)); \ } STMT_END#define PM_GETRE_SAFE(o) (PL_regex_pad ? PM_GETRE(o) : (REGEXP*)0)#define PM_SETRE_SAFE(o,r) if (PL_regex_pad) PM_SETRE(o,r)#else#define PM_GETRE(o) ((o)->op_pmregexp)#define PM_SETRE(o,r) ((o)->op_pmregexp = (r))#define PM_GETRE_SAFE PM_GETRE#define PM_SETRE_SAFE PM_SETRE#endif#define PMf_RETAINT 0x0001 /* taint $1 etc. if target tainted */#define PMf_ONCE 0x0002 /* match successfully only once per reset, with related flag RXf_USED in re->extflags holding state. This is used only for ?? matches, and only on OP_MATCH and OP_QR */#define PMf_UNUSED 0x0004 /* free for use */#define PMf_MAYBE_CONST 0x0008 /* replacement contains variables */#define PMf_USED 0x0010 /* PMf_ONCE has matched successfully. Not used under threading. */#define PMf_CONST 0x0040 /* subst replacement is constant */#define PMf_KEEP 0x0080 /* keep 1st runtime pattern forever */#define PMf_GLOBAL 0x0100 /* pattern had a g modifier */#define PMf_CONTINUE 0x0200 /* don't reset pos() if //g fails */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -