summaryrefslogtreecommitdiff
path: root/regen/opcode.pl
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-11-12 20:09:44 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-11-12 20:28:57 -0800
commitdc1230deb7c22155db3d9bfaaef55575ded1f267 (patch)
tree93d19e0182bc4a58044dfae65a09265dede0bd66 /regen/opcode.pl
parentacd367ed7165d54fe7204b9e31c0b57fcf0223ba (diff)
downloadperl-dc1230deb7c22155db3d9bfaaef55575ded1f267.tar.gz
[perl #123161] Add %B::Op_private::ops_using
Diffstat (limited to 'regen/opcode.pl')
-rwxr-xr-xregen/opcode.pl31
1 files changed, 30 insertions, 1 deletions
diff --git a/regen/opcode.pl b/regen/opcode.pl
index a261661f4c..fa9127c21f 100755
--- a/regen/opcode.pl
+++ b/regen/opcode.pl
@@ -409,11 +409,12 @@ sub print_B_Op_private {
@
@=head1 DESCRIPTION
@
-@This module provides three global hashes:
+@This module provides four global hashes:
@
@ %B::Op_private::bits
@ %B::Op_private::defines
@ %B::Op_private::labels
+@ %B::Op_private::ops_using
@
@which contain information about the per-op meanings of the bits in the
@op_private field.
@@ -481,6 +482,13 @@ sub print_B_Op_private {
@If the label equals '-', then Concise will treat the bit as a raw bit and
@not try to display it symbolically.
@
+@=head2 C<%ops_using>
+@
+@For each define, this gives a reference to an array of op names that use
+@the flag.
+@
+@ @ops_using_lvintro = @{ $B::Op_private::ops_using{OPp_LVAL_INTRO} };
+@
@=cut
package B::Op_private;
@@ -494,6 +502,8 @@ EOF
my $v = (::perl_version())[3];
print $fh qq{\nour \$VERSION = "$v";\n\n};
+ my %ops_using;
+
# for each flag/bit combination, find the ops which use it
my %combos;
for my $op (sort keys %FLAGS) {
@@ -503,6 +513,7 @@ EOF
next unless defined $e;
next if ref $e; # bit field, not flag
push @{$combos{$e}{$bit}}, $op;
+ push @{$ops_using{$e}}, $op;
}
}
@@ -606,6 +617,24 @@ EOF
printf $fh " %-23s => '%s',\n", $_ , $LABELS{$_} for sort keys %LABELS;
print $fh ");\n";
+ # %ops_using
+ print $fh "\n\nour %ops_using = (\n";
+ # Save memory by using the same array wherever possible.
+ my %flag_by_op_list;
+ my $pending = '';
+ for my $flag (sort keys %ops_using) {
+ my $op_list = $ops_using{$flag} = "@{$ops_using{$flag}}";
+ if (!exists $flag_by_op_list{$op_list}) {
+ $flag_by_op_list{$op_list} = $flag;
+ printf $fh " %-23s => %s,\n", $flag , "[qw($op_list)]"
+ }
+ else {
+ $pending .= "\$ops_using{$flag} = "
+ . "\$ops_using{$flag_by_op_list{$op_list}};\n";
+ }
+ }
+ print $fh ");\n\n$pending";
+
}