This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
RMG - Consistent four-space indent; wrap all lines to 79 characters
[perl5.git] / regen / op_private
CommitLineData
f3574cc6
DM
1#!perl
2
3=head1 F<regen/op_private>
4
5This file contains all the definitions of the meanings of the flags in the
6op_private field of an OP.
7
8After editing this file, run C<make regen>. This will generate/update data
9in:
10
11 opcode.h
12 lib/B/Op_private.pm
13
14C<B::Op_private> holds three global hashes, C<%bits>, C<%defines>,
15C<%labels>, which hold roughly the same information as found in this file
16(after processing).
17
18F<opcode.h> gains a series of C<OPp*> defines, and a few static data
19structures:
20
c10dbd97
DM
21C<PL_op_private_valid> defines, per-op, which op_private bits are legally
22allowed to be set. This is a good first place to look to see if an op has
f3574cc6
DM
23any spare private bits.
24
25C<PL_op_private_bitdef_ix>, C<PL_op_private_bitdefs>,
26C<PL_op_private_labels>, C<PL_op_private_bitfields>,
27C<PL_op_private_valid> contain (in a compact form) the data needed by
28Perl_do_op_dump() to dump the op_private field of an op.
29
30This file actually contains perl code which is run by F<regen/opcode.pl>.
31The basic idea is that you keep calling addbits() to add definitions of
32what a particular bit or range of bits in op_private means for a
33particular op. This can be specified either as a 1-bit flag or a 1-or-more
34bit bit field. Here's a general example:
35
36 addbits('aelem',
37 7 => qw(OPpLVAL_INTRO LVINTRO),
956f044d 38 6 => qw(OPpLVAL_DEFER LVDEFER),
9e209402 39 '4..5' => {
f3574cc6
DM
40 mask_def => 'OPpDEREF',
41 enum => [ qw(
42 1 OPpDEREF_AV DREFAV
43 2 OPpDEREF_HV DREFHV
44 3 OPpDEREF_SV DREFSV
45 )],
46 },
f3574cc6
DM
47 );
48
956f044d 49Here for the op C<aelem>, bits 6 and 7 (bits are numbered 0..7) are
f3574cc6
DM
50defined as single-bit flags. The first string following the bit number is
51the define name that gets emitted in F<opcode.h>, and the second string is
52the label, which will be displayed by F<Concise.pm> and Perl_do_op_dump()
53(as used by C<perl -Dx>).
54
55If the bit number is actually two numbers connected with '..', then this
56defines a bit field, which is 1 or more bits taken to hold a small
57unsigned integer. Instead of two string arguments, it just has a single
58hash ref argument. A bit field allows you to generate extra defines, such
59as a mask, and optionally allows you to define an enumeration, where a
60subset of the possible values of the bit field are given their own defines
61and labels. The full syntax of this hash is explained further below.
62
63Note that not all bits for a particular op need to be added in a single
64addbits() call; they accumulate. In particular, this file is arranged in
65two halves; first, generic flags shared by multiple ops are added, then
66in the second half, specific per-op flags are added, e.g.
67
68 addbits($_, 7 => qw(OPpLVAL_INTRO LVINTRO)) for qw(pos substr vec ...);
69
70 ....
71
72 addbits('substr',
73 4 => qw(OPpSUBSTR_REPL_FIRST REPL1ST),
74 3 => ...
75 );
76
c10dbd97
DM
77(although the dividing line between these two halves is somewhat
78subjective, and is based on whether "OPp" is followed by the op name or
79something generic).
f3574cc6
DM
80
81There are some utility functions for generating a list of ops from
82F<regen/opcodes> based on various criteria. These are:
83
84 ops_with_check('ck_foo')
85 ops_with_flag('X')
86 ops_with_arg(N, 'XYZ')
87
c10dbd97 88which respectively return a list of op names where:
f3574cc6
DM
89
90 field 3 of regen/opcodes specifies 'ck_foo' as the check function;
91 field 4 of of regen/opcodes has flag or type 'X' set;
92 argument field N of of regen/opcodes matches 'XYZ';
93
94For example
95
96 addbits($_, 4 => qw(OPpTARGET_MY TARGMY)) for ops_with_flag('T');
97
98If a label is specified as '-', then the flag or bit field is not
99displayed symbolically by Concise/-Dx; instead the bits are treated as
c10dbd97
DM
100unrecognised and are included in the final residual integer value after
101all recognised bits have been processed (this doesn't apply to individual
f3574cc6
DM
102enum labels).
103
104Here is a full example of a bit field hash:
105
106 '5..6' => {
107 mask_def => 'OPpFOO_MASK',
108 baseshift_def => 'OPpFOO_SHIFT',
109 bitcount_def => 'OPpFOO_BITS',
110 label => 'FOO',
111 enum => [ qw(
112 1 OPpFOO_A A
113 2 OPpFOO_B B
114 3 OPpFOO_C C
115 )],
116 };
117
118The optional C<*_def> keys cause defines to be emitted that specify
119useful values based on the bit range (5 to 6 in this case):
120
121 mask_def: a mask that will extract the bit field
122 baseshift_def: how much to shift to make the bit field reach bit 0
123 bitcount_def: how many bits make up the bit field
124
125The example above will generate
126
127 #define OPpFOO_MASK 0x60
128 #define OPpFOO_SHIFT 5
129 #define OPpFOO_BITS 2
130
131The optional enum list specifies a set of defines and labels for (possibly
132a subset of) the possible values of the bit field (which in this example
133are 0,1,2,3). If a particular value matches an enum, then it will be
134displayed symbolically (e.g. 'C'), otherwise as a small integer. The
135defines are suitably shifted. The example above will generate
136
137 #define OPpFOO_A 0x20
138 #define OPpFOO_B 0x40
139 #define OPpFOO_C 0x60
140
141So you can write code like
142
143 if ((o->op_private & OPpFOO_MASK) == OPpFOO_C) ...
144
145The optional 'label' key causes Concise/-Dx output to prefix the value
146with C<LABEL=>; so in this case it might display C<FOO=C>. If the field
147value is zero, and if no label is present, and if no enum matches, then
148the field isn't displayed.
149
150=cut
151
152
153use warnings;
154use strict;
155
156
157
158
159# ====================================================================
160#
161# GENERIC OPpFOO flags
162#
163# Flags where FOO is a generic term (like LVAL), and the flag is
164# shared between multiple (possibly unrelated) ops.
165
166
167
168
169{
170 # The lower few bits of op_private often indicate the number of
171 # arguments. This is usually set by newUNOP() and newLOGOP (to 1),
172 # by newBINOP() (to 1 or 2), and by ck_fun() (to 1..15).
173 #
174 # These values are sometimes used at runtime: in particular,
175 # the MAXARG macro extracts out the lower 4 bits.
176 #
177 # Some ops encroach upon these bits; for example, entersub is a unop,
178 # but uses bit 0 for something else. Bit 0 is initially set to 1 in
179 # newUNOP(), but is later cleared (in ck_rvconst()), when the code
180 # notices that this op is an entersub.
181 #
182 # The important thing below is that any ops which use MAXARG at
183 # runtime must have all 4 bits allocated; if bit 3 were used for a new
184 # flag say, then things could break. The information on the other
185 # types of op is for completeness (so we can account for every bit
186 # used in every op)
187
188 my (%maxarg, %args0, %args1, %args2, %args3, %args4);
189
190 # these are the functions which currently use MAXARG at runtime
191 # (i.e. in the pp() functions). Thus they must always have 4 bits
192 # allocated
193 $maxarg{$_} = 1 for qw(
194 binmode bless caller chdir close enterwrite eof exit fileno getc
195 getpgrp gmtime index mkdir rand reset setpgrp sleep srand sysopen
196 tell umask
197 );
198
199 # find which ops use 0,1,2,3 or 4 bits of op_private for arg count info
200
201 $args0{$_} = 1 for qw(entersub); # UNOPs that usurp bit 0
202
203 $args1{$_} = 1 for (
204 qw(reverse), # ck_fun(), but most bits stolen
205 grep !$maxarg{$_} && !$args0{$_},
206 ops_with_flag('1'), # UNOP
2f7c6295 207 ops_with_flag('+'), # UNOP_AUX
f3574cc6
DM
208 ops_with_flag('%'), # BASEOP/UNOP
209 ops_with_flag('|'), # LOGOP
210 ops_with_flag('-'), # FILESTATOP
211 ops_with_flag('}'), # LOOPEXOP
b46e009d 212 ops_with_flag('.'), # METHOP
f3574cc6
DM
213 );
214
215 $args2{$_} = 1 for (
216 qw(vec),
217 grep !$maxarg{$_} && !$args0{$_} && !$args1{$_},
218 ops_with_flag('2'), # BINOP
219 # this is a binop, but special-cased as a
220 # baseop in regen/opcodes
221 'sassign',
222 );
223
224 $args3{$_} = 1 for grep !$maxarg{$_} && !$args0{$_}
225 && !$args1{$_} && !$args2{$_},
226 # substr starts off with 4 bits set in
227 # ck_fun(), but since it never has more than 7
228 # args, bit 3 is later stolen
229 qw(substr);
230
231 $args4{$_} = 1 for keys %maxarg,
232 grep !$args0{$_} && !$args1{$_}
233 && !$args2{$_} && !$args3{$_},
234 ops_with_check('ck_fun'),
235 # these other ck_*() functions call ck_fun()
236 ops_with_check('ck_exec'),
237 ops_with_check('ck_glob'),
238 ops_with_check('ck_index'),
239 ops_with_check('ck_join'),
240 ops_with_check('ck_lfun'),
241 ops_with_check('ck_open'),
242 ops_with_check('ck_select'),
73f4c4fe 243 ops_with_check('ck_stringify'),
f3574cc6
DM
244 ops_with_check('ck_tell'),
245 ops_with_check('ck_trunc'),
246 ;
247
248
249 for (sort keys %args1) {
250 addbits($_, '0..0' => {
251 mask_def => 'OPpARG1_MASK',
252 label => '-',
253 }
254 );
255 }
256
257 for (sort keys %args2) {
258 addbits($_, '0..1' => {
259 mask_def => 'OPpARG2_MASK',
260 label => '-',
261 }
262 );
263 }
264
265 for (sort keys %args3) {
266 addbits($_, '0..2' => {
267 mask_def => 'OPpARG3_MASK',
268 label => '-',
269 }
270 );
271 }
272
273 for (sort keys %args4) {
274 addbits($_, '0..3' => {
275 mask_def => 'OPpARG4_MASK',
276 label => '-',
277 }
278 );
279 }
280}
281
282
283
284# if NATIVE_HINTS is defined, op_private on cops holds the top 8 bits
285# of PL_hints, although only bits 6 & 7 are officially used for that
286# purpose (the rest ought to be masked off). Bit 5 is set separately
287
288for (qw(nextstate dbstate)) {
289 addbits($_,
290 5 => qw(OPpHUSH_VMSISH HUSH),
f3574cc6
DM
291 );
292}
293
294
4e0538d9
DM
295# op is in local context, or pad variable is being introduced, e.g.
296# local $h{foo}
297# my $x
f3574cc6
DM
298
299addbits($_, 7 => qw(OPpLVAL_INTRO LVINTRO))
4e0538d9 300 for qw(gvsv rv2sv rv2hv rv2gv rv2av aelem helem aslice
f3574cc6 301 hslice delete padsv padav padhv enteriter entersub padrange
fedf30e1 302 pushmark cond_expr refassign lvref lvrefslice lvavref multideref),
f3574cc6
DM
303 'list', # this gets set in my_attrs() for some reason
304 ;
305
306
307
308# TARGLEX
309#
310# in constructs like my $x; ...; $x = $a + $b,
311# the sassign is optimised away and OPpTARGET_MY is set on the add op
b4941db2
DM
312#
313# Note that OPpTARGET_MY is mainly used at compile-time. At run time,
314# the pp function just updates the SV pointed to by op_targ, and doesn't
315# care whether that's a PADTMP or a lexical var.
f3574cc6 316
16a6edfa
DM
317# Some comments about when its safe to use T/OPpTARGET_MY.
318#
319# Safe to set if the ppcode uses:
320# tryAMAGICbin, tryAMAGICun, SETn, SETi, SETu, PUSHn, PUSHTARG, SETTARG,
321# SETs(TARG), XPUSHn, XPUSHu,
e83bf98c
FC
322# but make sure set-magic is invoked separately for SETs(TARG) (or change
323# it to SETTARG).
16a6edfa
DM
324#
325# Unsafe to set if the ppcode uses dTARG or [X]RETPUSH[YES|NO|UNDEF]
326#
e83bf98c
FC
327# Only the code paths that handle scalar rvalue context matter. If dTARG
328# or RETPUSHNO occurs only in list or lvalue paths, T is safe.
329#
d1455c67 330# lt and friends do SETs (including ncmp, but not scmp or i_ncmp)
16a6edfa
DM
331#
332# Additional mode of failure: the opcode can modify TARG before it "used"
333# all the arguments (or may call an external function which does the same).
334# If the target coincides with one of the arguments ==> kaboom.
335#
336# pp.c pos substr each not OK (RETPUSHUNDEF)
16a6edfa 337# ref not OK (RETPUSHNO)
b0da25f0 338# trans not OK (target is used for lhs, not retval)
16a6edfa
DM
339# ucfirst etc not OK: TMP arg processed inplace
340# quotemeta not OK (unsafe when TARG == arg)
d8cdf573 341# pack - unknown whether it is safe
16a6edfa
DM
342# sprintf: is calling do_sprintf(TARG,...) which can act on TARG
343# before other args are processed.
344#
345# Suspicious wrt "additional mode of failure" (and only it):
346# schop, chop, postinc/dec, bit_and etc, negate, complement.
347#
348# Also suspicious: 4-arg substr, sprintf, uc/lc (POK_only), reverse, pack.
349#
350# substr/vec: doing TAINT_off()???
351#
352# pp_hot.c
353# readline - unknown whether it is safe
354# match subst not OK (dTARG)
355# grepwhile not OK (not always setting)
356# join not OK (unsafe when TARG == arg)
357#
8ecc2ae2
FC
358# concat - pp_concat special-cases TARG==arg to avoid
359# "additional mode of failure"
16a6edfa
DM
360#
361# pp_ctl.c
362# mapwhile flip caller not OK (not always setting)
363#
364# pp_sys.c
365# backtick glob warn die not OK (not always setting)
366# warn not OK (RETPUSHYES)
367# open fileno getc sysread syswrite ioctl accept shutdown
368# ftsize(etc) readlink telldir fork alarm getlogin not OK (RETPUSHUNDEF)
369# umask select not OK (XPUSHs(&PL_sv_undef);)
370# fileno getc sysread syswrite tell not OK (meth("FILENO" "GETC"))
371# sselect shm* sem* msg* syscall - unknown whether they are safe
372# gmtime not OK (list context)
373#
374# Suspicious wrt "additional mode of failure": warn, die, select.
375
376
f3574cc6
DM
377addbits($_, 4 => qw(OPpTARGET_MY TARGMY))
378 for ops_with_flag('T'),
379 # This flag is also used to indicate matches against implicit $_,
380 # where $_ is lexical; e.g. my $_; ....; /foo/
381 qw(match subst trans transr);
382;
383
384
385
386
387
388# op_targ carries a refcount
389addbits($_, 6 => qw(OPpREFCOUNTED REFC))
390 for qw(leave leavesub leavesublv leavewrite leaveeval);
391
392
393
394# Do not copy return value
395addbits($_, 7 => qw(OPpLVALUE LV)) for qw(leave leaveloop);
396
397
398
399# Pattern coming in on the stack
400addbits($_, 6 => qw(OPpRUNTIME RTIME))
401 for qw(match subst substcont qr pushre);
402
403
404
405# autovivify: Want ref to something
406for (qw(rv2gv rv2sv padsv aelem helem entersub)) {
9e209402 407 addbits($_, '4..5' => {
f3574cc6
DM
408 mask_def => 'OPpDEREF',
409 enum => [ qw(
410 1 OPpDEREF_AV DREFAV
411 2 OPpDEREF_HV DREFHV
412 3 OPpDEREF_SV DREFSV
413 )],
414 }
415 );
416}
417
418
419
420# Defer creation of array/hash elem
fedf30e1 421addbits($_, 6 => qw(OPpLVAL_DEFER LVDEFER)) for qw(aelem helem multideref);
f3574cc6
DM
422
423
424
425addbits($_, 2 => qw(OPpSLICEWARNING SLICEWARN)) # warn about @hash{$scalar}
426 for qw(rv2hv rv2av padav padhv hslice aslice);
427
428
429
430# XXX Concise seemed to think that OPpOUR_INTRO is used in rv2gv too,
431# but I can't see it - DAPM
9e209402 432addbits($_, 6 => qw(OPpOUR_INTRO OURINTR)) # Variable was in an our()
de183bbb 433 for qw(gvsv rv2sv rv2av rv2hv enteriter split);
f3574cc6
DM
434
435
436
437# We might be an lvalue to return
438addbits($_, 3 => qw(OPpMAYBE_LVSUB LVSUB))
439 for qw(aassign rv2av rv2gv rv2hv padav padhv aelem helem aslice hslice
fedf30e1 440 av2arylen keys rkeys kvaslice kvhslice substr pos vec multideref);
f3574cc6
DM
441
442
443
444for (qw(rv2hv padhv)) {
445 addbits($_, # e.g. %hash in (%hash || $foo) ...
9e209402 446 4 => qw(OPpMAYBE_TRUEBOOL BOOL?), # ... cx not known till run time
f3574cc6 447 5 => qw(OPpTRUEBOOL BOOL), # ... in void cxt
f3574cc6
DM
448 );
449}
450
451
452
fedf30e1
DM
453addbits($_, 1 => qw(OPpHINT_STRICT_REFS STRICT))
454 for qw(rv2sv rv2av rv2hv rv2gv multideref);
f3574cc6
DM
455
456
457
458# Treat caller(1) as caller(2)
459addbits($_, 7 => qw(OPpOFFBYONE +1)) for qw(caller wantarray runcv);
460
461
462
463# label is in UTF8 */
464addbits($_, 7 => qw(OPpPV_IS_UTF8 UTF)) for qw(last redo next goto dump);
465
466
467
468# ====================================================================
469#
470# OP-SPECIFIC OPpFOO_* flags:
471#
472# where FOO is typically the name of an op, and the flag is used by a
473# single op (or maybe by a few closely related ops).
474
475
476
9e209402 477addbits($_, 6 => qw(OPpPAD_STATE STATE)) for qw(padav padhv padsv lvavref
3ad7d304 478 lvref refassign pushmark);
f3574cc6
DM
479
480
481
482addbits('aassign', 6 => qw(OPpASSIGN_COMMON COMMON));
483
484
485
486addbits('sassign',
487 6 => qw(OPpASSIGN_BACKWARDS BKWARD), # Left & right switched
488 7 => qw(OPpASSIGN_CV_TO_GV CV2GV), # Possible optimisation for constants
489);
490
491
492
493for (qw(trans transr)) {
494 addbits($_,
495 0 => qw(OPpTRANS_FROM_UTF <UTF),
496 1 => qw(OPpTRANS_TO_UTF >UTF),
497 2 => qw(OPpTRANS_IDENTICAL IDENT), # right side is same as left
498 3 => qw(OPpTRANS_SQUASH SQUASH),
499 # 4 is used for OPpTARGET_MY
500 5 => qw(OPpTRANS_COMPLEMENT COMPL),
501 6 => qw(OPpTRANS_GROWS GROWS),
502 7 => qw(OPpTRANS_DELETE DEL),
503 );
504}
505
506
507
508addbits('repeat', 6 => qw(OPpREPEAT_DOLIST DOLIST)); # List replication
509
510
511
512# OP_ENTERSUB and OP_RV2CV flags
513#
514# Flags are set on entersub and rv2cv in three phases:
515# parser - the parser passes the flag to the op constructor
516# check - the check routine called by the op constructor sets the flag
517# context - application of scalar/ref/lvalue context applies the flag
518#
519# In the third stage, an entersub op might turn into an rv2cv op (undef &foo,
520# \&foo, lock &foo, exists &foo, defined &foo). The two places where that
521# happens (op_lvalue_flags and doref in op.c) need to make sure the flags do
522# not conflict, since some flags with different meanings overlap between
523# the two ops. Flags applied in the context phase are only set when there
524# is no conversion of op type.
525#
526# bit entersub flag phase rv2cv flag phase
527# --- ------------- ----- ---------- -----
528# 0 OPpENTERSUB_INARGS context
529# 1 HINT_STRICT_REFS check HINT_STRICT_REFS check
62ead80f 530# 2 OPpENTERSUB_HASTARG checki OPpENTERSUB_HASTARG
f3574cc6 531# 3 OPpENTERSUB_AMPER check OPpENTERSUB_AMPER parser
9e209402
FC
532# 4 OPpDEREF_AV context
533# 5 OPpDEREF_HV context OPpMAY_RETURN_CONSTANT parser/context
534# 6 OPpENTERSUB_DB check OPpENTERSUB_DB
f3574cc6
DM
535# 7 OPpLVAL_INTRO context OPpENTERSUB_NOPAREN parser
536
537# NB: OPpHINT_STRICT_REFS must equal HINT_STRICT_REFS
538
539addbits('entersub',
540 0 => qw(OPpENTERSUB_INARGS INARGS), # Lval used as arg to a sub
c486bd5c 541 1 => qw(OPpHINT_STRICT_REFS STRICT), # 'use strict' in scope
f3574cc6
DM
542 2 => qw(OPpENTERSUB_HASTARG TARG ), # Called from OP tree
543 3 => qw(OPpENTERSUB_AMPER AMPER), # Used & form to call
9e209402
FC
544 # 4..5 => OPpDEREF, already defined above
545 6 => qw(OPpENTERSUB_DB DBG ), # Debug subroutine
f3574cc6
DM
546 # 7 => OPpLVAL_INTRO, already defined above
547);
f3574cc6 548
62ead80f
DM
549# note that some of these flags are just left-over from when an entersub
550# is converted into an rv2cv, and could probably be cleared/re-assigned
f3574cc6
DM
551
552addbits('rv2cv',
62ead80f
DM
553 1 => qw(OPpHINT_STRICT_REFS STRICT), # 'use strict' in scope
554 2 => qw(OPpENTERSUB_HASTARG TARG ), # If const sub, return the const
555 3 => qw(OPpENTERSUB_AMPER AMPER ), # Used & form to call
62ead80f 556
9e209402
FC
557 5 => qw(OPpMAY_RETURN_CONSTANT CONST ),
558 6 => qw(OPpENTERSUB_DB DBG ), # Debug subroutine
62ead80f 559 7 => qw(OPpENTERSUB_NOPAREN NO() ), # bare sub call (without parens)
f3574cc6
DM
560);
561
562
563
564#foo() called before sub foo was parsed */
565addbits('gv', 5 => qw(OPpEARLY_CV EARLYCV));
566
567
568
569# 1st arg is replacement string */
570addbits('substr', 4 => qw(OPpSUBSTR_REPL_FIRST REPL1ST));
571
572
573
574addbits('padrange',
575 # bits 0..6 hold target range
576 '0..6' => {
577 label => '-',
578 mask_def => 'OPpPADRANGE_COUNTMASK',
579 bitcount_def => 'OPpPADRANGE_COUNTSHIFT',
580 }
581 # 7 => OPpLVAL_INTRO, already defined above
582);
583
584
585
586for (qw(aelemfast aelemfast_lex)) {
587 addbits($_,
588 '0..7' => {
589 label => '-',
590 }
591 );
592}
593
594
595
596addbits('rv2gv',
597 2 => qw(OPpDONT_INIT_GV NOINIT), # Call gv_fetchpv with GV_NOINIT
598 # (Therefore will return whatever is currently in
599 # the symbol table, not guaranteed to be a PVGV)
9e209402 600 6 => qw(OPpALLOW_FAKE FAKE), # OK to return fake glob
f3574cc6
DM
601);
602
603
604
605addbits('enteriter',
606 2 => qw(OPpITER_REVERSED REVERSED),# for (reverse ...)
c486bd5c 607 3 => qw(OPpITER_DEF DEF), # 'for $_' or 'for my $_'
f3574cc6
DM
608);
609addbits('iter', 2 => qw(OPpITER_REVERSED REVERSED));
610
611
612
613addbits('const',
614 1 => qw(OPpCONST_NOVER NOVER), # no 6;
615 2 => qw(OPpCONST_SHORTCIRCUIT SHORT), # e.g. the constant 5 in (5 || foo)
616 3 => qw(OPpCONST_STRICT STRICT), # bareword subject to strict 'subs'
617 4 => qw(OPpCONST_ENTERED ENTERED), # Has been entered as symbol
618 6 => qw(OPpCONST_BARE BARE), # Was a bare word (filehandle?)
619);
620
621
622
623# Range arg potentially a line num. */
624addbits($_, 6 => qw(OPpFLIP_LINENUM LINENUM)) for qw(flip flop);
625
626
627
628# Guessed that pushmark was needed. */
629addbits('list', 6 => qw(OPpLIST_GUESSED GUESSED));
630
631
632
633# Operating on a list of keys
634addbits('delete', 6 => qw(OPpSLICE SLICE));
635# also 7 => OPpLVAL_INTRO, already defined above
636
637
638
639# Checking for &sub, not {} or [].
640addbits('exists', 6 => qw(OPpEXISTS_SUB SUB));
641
642
643
644addbits('sort',
645 0 => qw(OPpSORT_NUMERIC NUM ), # Optimized away { $a <=> $b }
646 1 => qw(OPpSORT_INTEGER INT ), # Ditto while under "use integer"
647 2 => qw(OPpSORT_REVERSE REV ), # Reversed sort
648 3 => qw(OPpSORT_INPLACE INPLACE), # sort in-place; eg @a = sort @a
649 4 => qw(OPpSORT_DESCEND DESC ), # Descending sort
650 5 => qw(OPpSORT_QSORT QSORT ), # Use quicksort (not mergesort)
651 6 => qw(OPpSORT_STABLE STABLE ), # Use a stable algorithm
652);
653
654
655
656# reverse in-place (@a = reverse @a) */
657addbits('reverse', 3 => qw(OPpREVERSE_INPLACE INPLACE));
658
659
660
661for (qw(open backtick)) {
662 addbits($_,
663 4 => qw(OPpOPEN_IN_RAW INBIN ), # binmode(F,":raw") on input fh
664 5 => qw(OPpOPEN_IN_CRLF INCR ), # binmode(F,":crlf") on input fh
665 6 => qw(OPpOPEN_OUT_RAW OUTBIN), # binmode(F,":raw") on output fh
666 7 => qw(OPpOPEN_OUT_CRLF OUTCR ), # binmode(F,":crlf") on output fh
667 );
668}
669
670
671
672# The various OPpFT* filetest ops
673
674# "use filetest 'access'" is in scope:
675# this flag is set only on a subset of the FT* ops
676addbits($_, 1 => qw(OPpFT_ACCESS FTACCESS)) for ops_with_arg(0, 'F-+');
677
678# all OPpFT* ops except stat and lstat
679for (grep { $_ !~ /^l?stat$/ } ops_with_flag('-')) {
680 addbits($_,
681 2 => qw(OPpFT_STACKED FTSTACKED ), # stacked filetest,
682 # e.g. "-f" in "-f -x $foo"
683 3 => qw(OPpFT_STACKING FTSTACKING), # stacking filetest.
684 # e.g. "-x" in "-f -x $foo"
685 4 => qw(OPpFT_AFTER_t FTAFTERt ), # previous op was -t
686 );
687}
688
689
690
691addbits($_, 1 => qw(OPpGREP_LEX GREPLEX)) # iterate over lexical $_
692 for qw(mapwhile mapstart grepwhile grepstart);
693
694
695
696addbits('entereval',
697 1 => qw(OPpEVAL_HAS_HH HAS_HH ), # Does it have a copy of %^H ?
698 2 => qw(OPpEVAL_UNICODE UNI ),
699 3 => qw(OPpEVAL_BYTES BYTES ),
700 4 => qw(OPpEVAL_COPHH COPHH ), # Construct %^H from COP hints
c486bd5c 701 5 => qw(OPpEVAL_RE_REPARSING REPARSE), # eval_sv(..., G_RE_REPARSING)
f3574cc6
DM
702);
703
704
705
706# These must not conflict with OPpDONT_INIT_GV or OPpALLOW_FAKE.
707# See pp.c:S_rv2gv. */
708addbits('coreargs',
709 0 => qw(OPpCOREARGS_DEREF1 DEREF1), # Arg 1 is a handle constructor
710 1 => qw(OPpCOREARGS_DEREF2 DEREF2), # Arg 2 is a handle constructor
711 #2 reserved for OPpDONT_INIT_GV in rv2gv
712 #4 reserved for OPpALLOW_FAKE in rv2gv
713 6 => qw(OPpCOREARGS_SCALARMOD $MOD ), # \$ rather than \[$@%*]
714 7 => qw(OPpCOREARGS_PUSHMARK MARK ), # Call pp_pushmark
715);
716
717
718
719addbits('split', 7 => qw(OPpSPLIT_IMPLIM IMPLIM)); # implicit limit
720
6102323a
FC
721
722
723addbits($_,
724 2 => qw(OPpLVREF_ELEM ELEM ),
5a36b2c0 725 3 => qw(OPpLVREF_ITER ITER ),
9e209402 726'4..5'=> {
c2380ea1
FC
727 mask_def => 'OPpLVREF_TYPE',
728 enum => [ qw(
729 0 OPpLVREF_SV SV
730 1 OPpLVREF_AV AV
731 2 OPpLVREF_HV HV
732 3 OPpLVREF_CV CV
733 )],
734 },
6102323a
FC
735 #7 => qw(OPpLVAL_INTRO LVINTRO),
736) for 'refassign', 'lvref';
737
fedf30e1
DM
738
739
740addbits('multideref',
741 4 => qw(OPpMULTIDEREF_EXISTS EXISTS), # deref is actually exists
742 5 => qw(OPpMULTIDEREF_DELETE DELETE), # deref is actually delete
743);
744
f3574cc6
DM
7451;
746
747# ex: set ts=8 sts=4 sw=4 et: