/* 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_NULL, saw a "do". */
/* On OP_EXISTS, treat av as av, not avhv. */
/* On OP_(ENTER|LEAVE)EVAL, don't clear $@ */
/* On pushre, rx is used as part of split, e.g. split " " */
in dynamic context */
#define OPpENTERSUB_LVAL_MASK (OPpLVAL_INTRO|OPpENTERSUB_INARGS)
-/* VMS-specific hints in COPs */
-#define OPpHINT_M_VMSISH_MASK (OPpHINT_M_VMSISH_STATUS|OPpHINT_M_VMSISH_TIME)
-
struct op {
OP * op_last;
};
+struct methop {
+ BASEOP
+ union {
+ /* op_u.op_first *must* be aligned the same as the op_first
+ * field of the other op types, and op_u.op_meth_sv *must*
+ * be aligned with op_sv */
+ OP* op_first; /* optree for method name */
+ SV* op_meth_sv; /* static method name */
+ } op_u;
+};
+
struct pmop {
BASEOP
OP * op_first;
#define PM_SETRE(o,r) ((o)->op_pmregexp = (r))
#endif
-/* Leave some space, so future bit allocations can go either in the shared or
- * unshared area without affecting binary compatibility */
-#define PMf_BASE_SHIFT (_RXf_PMf_SHIFT_NEXT+6)
+/* Currently these PMf flags occupy a single 32-bit word. Not all bits are
+ * currently used. The lower bits are shared with their corresponding RXf flag
+ * bits, up to but not including _RXf_PMf_SHIFT_NEXT. The unused bits
+ * immediately follow; finally the used Pmf-only (unshared) bits, so that the
+ * highest bit in the word is used. This gathers all the unused bits as a pool
+ * in the middle, like so: 11111111111111110000001111111111
+ * where the '1's represent used bits, and the '0's unused. This design allows
+ * us to allocate off one end of the pool if we need to add a shared bit, and
+ * off the other end if we need a non-shared bit, without disturbing the other
+ * bits. This maximizes the likelihood of being able to change things without
+ * breaking binary compatibility.
+ *
+ * To add shared bits, do so in op_reg_common.h. This should change
+ * _RXf_PMf_SHIFT_NEXT so that things won't compile. Then come to regexp.h and
+ * op.h and adjust the constant adders in the definitions of PMf_BASE_SHIFT and
+ * Pmf_BASE_SHIFT down by the number of shared bits you added. That's it.
+ * Things should be binary compatible. But if either of these gets to having
+ * to subtract rather than add, leave at 0 and adjust all the entries below
+ * that are in terms of this according. But if the first one of those is
+ * already PMf_BASE_SHIFT+0, there are no bits left, and a redesign is in
+ * order.
+ *
+ * To remove unshared bits, just delete its entry. If you're where breaking
+ * binary compatibility is ok to do, you might want to adjust things to move
+ * the newly opened space so that it gets absorbed into the common pool.
+ *
+ * To add unshared bits, first use up any gaps in the middle. Otherwise,
+ * allocate off the low end until you get to PMf_BASE_SHIFT+0. If that isn't
+ * enough, move PMf_BASE_SHIFT down (if possible) and add the new bit at the
+ * other end instead; this preserves binary compatibility. */
+#define PMf_BASE_SHIFT (_RXf_PMf_SHIFT_NEXT+4)
/* 'use re "taint"' in scope: taint $1 etc. if target tainted */
-#define PMf_RETAINT (1<<(PMf_BASE_SHIFT+0))
+#define PMf_RETAINT (1U<<(PMf_BASE_SHIFT+5))
/* 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_ONCE (1<<(PMf_BASE_SHIFT+1))
+#define PMf_ONCE (1U<<(PMf_BASE_SHIFT+6))
/* PMf_ONCE, i.e. ?pat?, has matched successfully. Not used under threading. */
-#define PMf_USED (1<<(PMf_BASE_SHIFT+3))
+#define PMf_USED (1U<<(PMf_BASE_SHIFT+7))
/* subst replacement is constant */
-#define PMf_CONST (1<<(PMf_BASE_SHIFT+4))
+#define PMf_CONST (1U<<(PMf_BASE_SHIFT+8))
/* keep 1st runtime pattern forever */
-#define PMf_KEEP (1<<(PMf_BASE_SHIFT+5))
+#define PMf_KEEP (1U<<(PMf_BASE_SHIFT+9))
-#define PMf_GLOBAL (1<<(PMf_BASE_SHIFT+6)) /* pattern had a g modifier */
+#define PMf_GLOBAL (1U<<(PMf_BASE_SHIFT+10)) /* pattern had a g modifier */
/* don't reset pos() if //g fails */
-#define PMf_CONTINUE (1<<(PMf_BASE_SHIFT+7))
+#define PMf_CONTINUE (1U<<(PMf_BASE_SHIFT+11))
/* evaluating replacement as expr */
-#define PMf_EVAL (1<<(PMf_BASE_SHIFT+8))
+#define PMf_EVAL (1U<<(PMf_BASE_SHIFT+12))
/* Return substituted string instead of modifying it. */
-#define PMf_NONDESTRUCT (1<<(PMf_BASE_SHIFT+9))
+#define PMf_NONDESTRUCT (1U<<(PMf_BASE_SHIFT+13))
/* the pattern has a CV attached (currently only under qr/...(?{}).../) */
-#define PMf_HAS_CV (1<<(PMf_BASE_SHIFT+10))
+#define PMf_HAS_CV (1U<<(PMf_BASE_SHIFT+14))
/* op_code_list is private; don't free it etc. It may well point to
* code within another sub, with different pad etc */
-#define PMf_CODELIST_PRIVATE (1<<(PMf_BASE_SHIFT+11))
+#define PMf_CODELIST_PRIVATE (1U<<(PMf_BASE_SHIFT+15))
/* the PMOP is a QR (we should be able to detect that from the op type,
* but the regex compilation API passes just the pm flags, not the op
* itself */
-#define PMf_IS_QR (1<<(PMf_BASE_SHIFT+12))
-#define PMf_USE_RE_EVAL (1<<(PMf_BASE_SHIFT+13)) /* use re'eval' in scope */
-
-#if PMf_BASE_SHIFT+13 > 31
+#define PMf_IS_QR (1U<<(PMf_BASE_SHIFT+16))
+#define PMf_USE_RE_EVAL (1U<<(PMf_BASE_SHIFT+17)) /* use re'eval' in scope */
+
+/* See comments at the beginning of these defines about adding bits. The
+ * highest bit position should be used, so that if PMf_BASE_SHIFT gets
+ * increased, the #error below will be triggered so that you will be reminded
+ * to adjust things at the other end to keep the bit positions unchanged */
+#if PMf_BASE_SHIFT+17 > 31
# error Too many PMf_ bits used. See above and regnodes.h for any spare in middle
#endif
#define cPVOPx(o) ((PVOP*)o)
#define cCOPx(o) ((COP*)o)
#define cLOOPx(o) ((LOOP*)o)
+#define cMETHOPx(o) ((METHOP*)o)
#define cUNOP cUNOPx(PL_op)
#define cBINOP cBINOPx(PL_op)
# define cSVOPx_svp(v) (&cSVOPx(v)->op_sv)
#endif
+# define cMETHOPx_meth(v) cSVOPx_sv(v)
+
#define cGVOP_gv cGVOPx_gv(PL_op)
#define cGVOPo_gv cGVOPx_gv(o)
#define kGVOP_gv cGVOPx_gv(kid)
#define OA_BASEOP_OR_UNOP (11 << OCSHIFT)
#define OA_FILESTATOP (12 << OCSHIFT)
#define OA_LOOPEXOP (13 << OCSHIFT)
+#define OA_METHOP (14 << OCSHIFT)
/* Each remaining nybble of PL_opargs (i.e. bits 12..15, 16..19 etc)
* encode the type for each arg */