diff options
author | Branislav ZahradnĂk <barney@cpan.org> | 2022-10-16 16:11:29 +0200 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2022-11-05 08:54:45 +0100 |
commit | 3892d1b9862e0060a24b706f9d106238a944f6c5 (patch) | |
tree | fd0c5f38f4854d9dfd887cfa25e5d665b3f47224 /regen | |
parent | 6670cf877529cd66e7e350aff0ab375ed7f5bc7f (diff) | |
download | perl-3892d1b9862e0060a24b706f9d106238a944f6c5.tar.gz |
Refactor opcode.pl - pp_proto.h - move generator code to function
Diffstat (limited to 'regen')
-rwxr-xr-x | regen/opcode.pl | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/regen/opcode.pl b/regen/opcode.pl index f86d930232..2aaa3693f2 100755 --- a/regen/opcode.pl +++ b/regen/opcode.pl @@ -33,6 +33,8 @@ sub generate_opnames_h_opcode_enum; sub generate_opnames_h_epilogue; sub generate_opnames_h_opcode_predicates; +sub generate_pp_proto_h; + my $restrict_to_core = "if defined(PERL_CORE) || defined(PERL_EXT)"; BEGIN { @@ -972,6 +974,7 @@ my %opflags = ( generate_opcode_h; generate_opnames_h; +generate_pp_proto_h; sub gen_op_is_macro { my ($op_is, $macname) = @_; @@ -1003,23 +1006,9 @@ sub gen_op_is_macro { } } -my $pp = open_new('pp_proto.h', '>', - { by => 'opcode.pl', from => 'its data' }); - -{ - my %funcs; - for (@ops) { - my $name = $alias{$_} ? $alias{$_}[0] : "Perl_pp_$_"; - ++$funcs{$name}; - } - for (sort keys %funcs) { - print $pp qq{PERL_CALLCONV OP *$_(pTHX) __attribute__visibility__("hidden");\n}; - } -} - OP_PRIVATE::print_B_Op_private($oprivpm); -foreach ($pp, $oprivpm) { +foreach ($oprivpm) { read_only_bottom_close_and_rename($_); } @@ -1324,3 +1313,26 @@ sub generate_opnames_h_opcode_predicates { gen_op_is_macro( \%OP_IS_DIRHOP, 'OP_IS_DIRHOP'); gen_op_is_macro( \%OP_IS_INFIX_BIT, 'OP_IS_INFIX_BIT'); } + +sub generate_pp_proto_h { + my $pp = open_new('pp_proto.h', '>', { + by => 'opcode.pl', + from => 'its data', + }); + + my $old = select $pp; + + my %funcs; + for (@ops) { + my $name = $alias{$_} ? $alias{$_}[0] : "Perl_pp_$_"; + ++$funcs{$name}; + } + + for (sort keys %funcs) { + print $pp qq{PERL_CALLCONV OP *$_(pTHX) __attribute__visibility__("hidden");\n}; + } + + read_only_bottom_close_and_rename(select); + + select $old; +} |