| 1 | /* op.h
|
|---|
| 2 | *
|
|---|
| 3 | * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
|---|
| 4 | * 2000, 2001, 2002, 2003, 2004, 2005 by Larry Wall and others
|
|---|
| 5 | *
|
|---|
| 6 | * You may distribute under the terms of either the GNU General Public
|
|---|
| 7 | * License or the Artistic License, as specified in the README file.
|
|---|
| 8 | *
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 | /*
|
|---|
| 12 | * The fields of BASEOP are:
|
|---|
| 13 | * op_next Pointer to next ppcode to execute after this one.
|
|---|
| 14 | * (Top level pre-grafted op points to first op,
|
|---|
| 15 | * but this is replaced when op is grafted in, when
|
|---|
| 16 | * this op will point to the real next op, and the new
|
|---|
| 17 | * parent takes over role of remembering starting op.)
|
|---|
| 18 | * op_ppaddr Pointer to current ppcode's function.
|
|---|
| 19 | * op_type The type of the operation.
|
|---|
| 20 | * op_flags Flags common to all operations. See OPf_* below.
|
|---|
| 21 | * op_private Flags peculiar to a particular operation (BUT,
|
|---|
| 22 | * by default, set to the number of children until
|
|---|
| 23 | * the operation is privatized by a check routine,
|
|---|
| 24 | * which may or may not check number of children).
|
|---|
| 25 | */
|
|---|
| 26 |
|
|---|
| 27 | #ifdef DEBUGGING_OPS
|
|---|
| 28 | #define OPCODE opcode
|
|---|
| 29 | #else
|
|---|
| 30 | #define OPCODE U16
|
|---|
| 31 | #endif
|
|---|
| 32 |
|
|---|
| 33 | #ifdef BASEOP_DEFINITION
|
|---|
| 34 | #define BASEOP BASEOP_DEFINITION
|
|---|
| 35 | #else
|
|---|
| 36 | #define BASEOP \
|
|---|
| 37 | OP* op_next; \
|
|---|
| 38 | OP* op_sibling; \
|
|---|
| 39 | OP* (CPERLscope(*op_ppaddr))(pTHX); \
|
|---|
| 40 | PADOFFSET op_targ; \
|
|---|
| 41 | OPCODE op_type; \
|
|---|
| 42 | U16 op_seq; \
|
|---|
| 43 | U8 op_flags; \
|
|---|
| 44 | U8 op_private;
|
|---|
| 45 | #endif
|
|---|
| 46 |
|
|---|
| 47 | #define OP_GIMME(op,dfl) \
|
|---|
| 48 | (((op)->op_flags & OPf_WANT) == OPf_WANT_VOID ? G_VOID : \
|
|---|
| 49 | ((op)->op_flags & OPf_WANT) == OPf_WANT_SCALAR ? G_SCALAR : \
|
|---|
| 50 | ((op)->op_flags & OPf_WANT) == OPf_WANT_LIST ? G_ARRAY : \
|
|---|
| 51 | dfl)
|
|---|
| 52 |
|
|---|
| 53 | /*
|
|---|
| 54 | =head1 "Gimme" Values
|
|---|
| 55 |
|
|---|
| 56 | =for apidoc Amn|U32|GIMME_V
|
|---|
| 57 | The XSUB-writer's equivalent to Perl's C<wantarray>. Returns C<G_VOID>,
|
|---|
| 58 | C<G_SCALAR> or C<G_ARRAY> for void, scalar or list context,
|
|---|
| 59 | respectively.
|
|---|
| 60 |
|
|---|
| 61 | =for apidoc Amn|U32|GIMME
|
|---|
| 62 | A backward-compatible version of C<GIMME_V> which can only return
|
|---|
| 63 | C<G_SCALAR> or C<G_ARRAY>; in a void context, it returns C<G_SCALAR>.
|
|---|
| 64 | Deprecated. Use C<GIMME_V> instead.
|
|---|
| 65 |
|
|---|
| 66 | =cut
|
|---|
| 67 | */
|
|---|
| 68 |
|
|---|
| 69 | #define GIMME_V OP_GIMME(PL_op, block_gimme())
|
|---|
| 70 |
|
|---|
| 71 | /* Public flags */
|
|---|
| 72 |
|
|---|
| 73 | #define OPf_WANT 3 /* Mask for "want" bits: */
|
|---|
| 74 | #define OPf_WANT_VOID 1 /* Want nothing */
|
|---|
| 75 | #define OPf_WANT_SCALAR 2 /* Want single value */
|
|---|
| 76 | #define OPf_WANT_LIST 3 /* Want list of any length */
|
|---|
| 77 | #define OPf_KIDS 4 /* There is a firstborn child. */
|
|---|
| 78 | #define OPf_PARENS 8 /* This operator was parenthesized. */
|
|---|
| 79 | /* (Or block needs explicit scope entry.) */
|
|---|
| 80 | #define OPf_REF 16 /* Certified reference. */
|
|---|
| 81 | /* (Return container, not containee). */
|
|---|
| 82 | #define OPf_MOD 32 /* Will modify (lvalue). */
|
|---|
| 83 | #define OPf_STACKED 64 /* Some arg is arriving on the stack. */
|
|---|
| 84 | #define OPf_SPECIAL 128 /* Do something weird for this op: */
|
|---|
| 85 | /* On local LVAL, don't init local value. */
|
|---|
| 86 | /* On OP_SORT, subroutine is inlined. */
|
|---|
| 87 | /* On OP_NOT, inversion was implicit. */
|
|---|
| 88 | /* On OP_LEAVE, don't restore curpm. */
|
|---|
| 89 | /* On truncate, we truncate filehandle */
|
|---|
| 90 | /* On control verbs, we saw no label */
|
|---|
| 91 | /* On flipflop, we saw ... instead of .. */
|
|---|
| 92 | /* On UNOPs, saw bare parens, e.g. eof(). */
|
|---|
| 93 | /* On OP_ENTERSUB || OP_NULL, saw a "do". */
|
|---|
| 94 | /* On OP_EXISTS, treat av as av, not avhv. */
|
|---|
| 95 | /* On OP_(ENTER|LEAVE)EVAL, don't clear $@ */
|
|---|
| 96 | /* On OP_ENTERITER, loop var is per-thread */
|
|---|
| 97 | /* On pushre, re is /\s+/ imp. by split " " */
|
|---|
| 98 | /* On regcomp, "use re 'eval'" was in scope */
|
|---|
| 99 | /* On OP_READLINE, was <$filehandle> */
|
|---|
| 100 | /* On RV2[ACGHS]V, don't create GV--in
|
|---|
| 101 | defined()*/
|
|---|
| 102 | /* On OP_DBSTATE, indicates breakpoint
|
|---|
| 103 | * (runtime property) */
|
|---|
| 104 | /* On OP_AELEMFAST, indiciates pad var */
|
|---|
| 105 |
|
|---|
| 106 | /* old names; don't use in new code, but don't break them, either */
|
|---|
| 107 | #define OPf_LIST OPf_WANT_LIST
|
|---|
| 108 | #define OPf_KNOW OPf_WANT
|
|---|
| 109 |
|
|---|
| 110 | #define GIMME \
|
|---|
| 111 | (PL_op->op_flags & OPf_WANT \
|
|---|
| 112 | ? ((PL_op->op_flags & OPf_WANT) == OPf_WANT_LIST \
|
|---|
| 113 | ? G_ARRAY \
|
|---|
| 114 | : G_SCALAR) \
|
|---|
| 115 | : dowantarray())
|
|---|
| 116 |
|
|---|
| 117 | /* NOTE: OP_NEXTSTATE, OP_DBSTATE, and OP_SETSTATE (i.e. COPs) carry lower
|
|---|
| 118 | * bits of PL_hints in op_private */
|
|---|
|
|---|