| 1 | package Dist::Zilla::PluginBundle::Author::ZMUGHAL::Babble::FunctionParameters; | ||||||||||||||||||||||||||||||||
| 2 | 1 | $Dist::Zilla::PluginBundle::Author::ZMUGHAL::Babble::FunctionParameters::VERSION = '0.006'; | |||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Import::Into; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Mu; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | ro setup_package => ( | ||||||||||||||||||||||||||||||||
| 9 | 0 | ▶ | default => sub { 'Orbital::Transfer::Common::Setup' }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 10 | 1 | ); | |||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | lazy _import_info => sub { | ||||||||||||||||||||||||||||||
|
Subroutine
_build__import_info: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 14 | 1 | $self->setup_package->import::into(0); | |||||||||||||||||||||||||||||||
| 15 | 1 | my $fp_config = $^H{'Function::Parameters/config'}; | |||||||||||||||||||||||||||||||
| 16 | 1 | $self->setup_package->unimport::out_of(0); | |||||||||||||||||||||||||||||||
| 17 | return +{ | ||||||||||||||||||||||||||||||||
| 18 | 1 | 'fp' => $fp_config, | |||||||||||||||||||||||||||||||
| 19 | }; | ||||||||||||||||||||||||||||||||
| 20 | 1 | }; | |||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | lazy _fp_keywords_re => sub { | ||||||||||||||||||||||||||||||
|
Subroutine
_build__fp_keywords_re: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 23 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 24 | return | ||||||||||||||||||||||||||||||||
| 25 | '(?:' | ||||||||||||||||||||||||||||||||
| 26 | 1 | . join("|", map quotemeta, keys %{ $self->_import_info->{fp} }) | |||||||||||||||||||||||||||||||
| 27 | . ')'; | ||||||||||||||||||||||||||||||||
| 28 | 1 | }; | |||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 1 | my $FPTypeRE = q{ | |||||||||||||||||||||||||||||||
| 31 | (?: | ||||||||||||||||||||||||||||||||
| 32 | [^$@%:(]+ | \( (?&PerlScalarExpression) \) | ||||||||||||||||||||||||||||||||
| 33 | ) | ||||||||||||||||||||||||||||||||
| 34 | }; | ||||||||||||||||||||||||||||||||
| 35 | 1 | my $FPParamRE = q{ | |||||||||||||||||||||||||||||||
| 36 | (?: | ||||||||||||||||||||||||||||||||
| 37 | #(?<type> | ||||||||||||||||||||||||||||||||
| 38 | (?> (?&PerlBabbleFPType)? ) | ||||||||||||||||||||||||||||||||
| 39 | #) | ||||||||||||||||||||||||||||||||
| 40 | (?> (?&PerlOWS) ) | ||||||||||||||||||||||||||||||||
| 41 | #(?<named> | ||||||||||||||||||||||||||||||||
| 42 | (?> :? ) | ||||||||||||||||||||||||||||||||
| 43 | #) | ||||||||||||||||||||||||||||||||
| 44 | #(?<var> | ||||||||||||||||||||||||||||||||
| 45 | (?> \$ (?&PerlIdentifier) ) | ||||||||||||||||||||||||||||||||
| 46 | #) | ||||||||||||||||||||||||||||||||
| 47 | (?> | ||||||||||||||||||||||||||||||||
| 48 | (?&PerlOWS) | ||||||||||||||||||||||||||||||||
| 49 | #(?<hasdefault> | ||||||||||||||||||||||||||||||||
| 50 | (?: = ) | ||||||||||||||||||||||||||||||||
| 51 | #) | ||||||||||||||||||||||||||||||||
| 52 | (?&PerlOWS) | ||||||||||||||||||||||||||||||||
| 53 | #(?<default> | ||||||||||||||||||||||||||||||||
| 54 | (?: (?&PerlScalarExpression)? ) | ||||||||||||||||||||||||||||||||
| 55 | #) | ||||||||||||||||||||||||||||||||
| 56 | )? | ||||||||||||||||||||||||||||||||
| 57 | ) | ||||||||||||||||||||||||||||||||
| 58 | | | ||||||||||||||||||||||||||||||||
| 59 | (?: | ||||||||||||||||||||||||||||||||
| 60 | #(?<other> | ||||||||||||||||||||||||||||||||
| 61 | (?: (?> [$@%] ) (?> (?&PerlIdentifier)? ) ) | ||||||||||||||||||||||||||||||||
| 62 | #) | ||||||||||||||||||||||||||||||||
| 63 | ) | ||||||||||||||||||||||||||||||||
| 64 | }; | ||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||
| 66 | 1 | my $FPParamListPartial = q{ | |||||||||||||||||||||||||||||||
| 67 | (?&PerlBabbleFPParam) | ||||||||||||||||||||||||||||||||
| 68 | (?: (?&PerlOWS) [,] (?&PerlOWS) (?&PerlBabbleFPParam))*? | ||||||||||||||||||||||||||||||||
| 69 | }; | ||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | 1 | my $FPParamListComplete = qq{ | |||||||||||||||||||||||||||||||
| 72 | \\( | ||||||||||||||||||||||||||||||||
| 73 | (?> (?&PerlOWS) ) | ||||||||||||||||||||||||||||||||
| 74 | (?: | ||||||||||||||||||||||||||||||||
| 75 | (?: | ||||||||||||||||||||||||||||||||
| 76 | $FPParamListPartial | ||||||||||||||||||||||||||||||||
| 77 | (?&PerlOWS) [:] (?&PerlOWS) | ||||||||||||||||||||||||||||||||
| 78 | )? | ||||||||||||||||||||||||||||||||
| 79 | (?: | ||||||||||||||||||||||||||||||||
| 80 | $FPParamListPartial | ||||||||||||||||||||||||||||||||
| 81 | ) | ||||||||||||||||||||||||||||||||
| 82 | )?? | ||||||||||||||||||||||||||||||||
| 83 | (?> (?&PerlOWS) ) | ||||||||||||||||||||||||||||||||
| 84 | \\) | ||||||||||||||||||||||||||||||||
| 85 | }; | ||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||
| 87 | 1 | ▶ | sub extend_grammar { | ||||||||||||||||||||||||||||||
|
Subroutine
extend_grammar: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 88 | 1 | my ($self, $g) = @_; | |||||||||||||||||||||||||||||||
| 89 | 1 | $g->add_rule(BabbleFPType => $FPTypeRE ); | |||||||||||||||||||||||||||||||
| 90 | 1 | $g->add_rule(BabbleFPParam => $FPParamRE ); | |||||||||||||||||||||||||||||||
| 91 | 1 | $g->add_rule(BabbleFPParamList => $FPParamListComplete ); | |||||||||||||||||||||||||||||||
| 92 | 1 | $g->add_rule(FPDeclaration => qq{ | |||||||||||||||||||||||||||||||
| 93 | 1 | @{[ $self->_fp_keywords_re ]} | |||||||||||||||||||||||||||||||
| 94 | (?&PerlOWS) | ||||||||||||||||||||||||||||||||
| 95 | (?: (?&PerlIdentifier)(?&PerlOWS) )?+ | ||||||||||||||||||||||||||||||||
| 96 | (?> (?&PerlBabbleFPParamList) ) | ||||||||||||||||||||||||||||||||
| 97 | (?&PerlOWS) | ||||||||||||||||||||||||||||||||
| 98 | (?: (?>(?&PerlAttributes)) (?&PerlOWS) )?+ | ||||||||||||||||||||||||||||||||
| 99 | (?&PerlBlock) | ||||||||||||||||||||||||||||||||
| 100 | }); | ||||||||||||||||||||||||||||||||
| 101 | 1 | $g->augment_rule(SubroutineDeclaration => '(?&PerlFPDeclaration)'); | |||||||||||||||||||||||||||||||
| 102 | 1 | $g->augment_rule(AnonymousSubroutine => '(?&PerlFPDeclaration)'); | |||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||
| 105 | 28 | ▶ | sub _do_transform { | ||||||||||||||||||||||||||||||
|
Subroutine
_do_transform: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 106 | 28 | my ($self, $top, $cb) = @_; | |||||||||||||||||||||||||||||||
| 107 | 28 | $top->remove_use_statement('Function::Parameters'); | |||||||||||||||||||||||||||||||
| 108 | $top->each_match_within(FPDeclaration => [ | ||||||||||||||||||||||||||||||||
| 109 | [ kw => $self->_fp_keywords_re ], | ||||||||||||||||||||||||||||||||
| 110 | [ name => '(?&PerlOWS) (?:(?&PerlIdentifier)(?&PerlOWS))?+' ], | ||||||||||||||||||||||||||||||||
| 111 | [ sig => '(?&PerlBabbleFPParamList)' ], | ||||||||||||||||||||||||||||||||
| 112 | [ rest => q{ | ||||||||||||||||||||||||||||||||
| 113 | (?&PerlOWS) | ||||||||||||||||||||||||||||||||
| 114 | (?: (?>(?&PerlAttributes)) (?&PerlOWS) )?+ | ||||||||||||||||||||||||||||||||
| 115 | (?&PerlBlock) | ||||||||||||||||||||||||||||||||
| 116 | } ], | ||||||||||||||||||||||||||||||||
| 117 | 28 | ▶ | ] => sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 118 | 28 | my ($m) = @_; | |||||||||||||||||||||||||||||||
| 119 | 28 | my $gr = $m->grammar_regexp; | |||||||||||||||||||||||||||||||
| 120 | 28 | my ($kw, $sig, $rest) = @{$m->submatches}{qw(kw sig rest)}; | |||||||||||||||||||||||||||||||
| 121 | 28 | my $kw_text = $kw->text; | |||||||||||||||||||||||||||||||
| 122 | 28 | my $kw_info = $self->_import_info->{fp}{$kw_text}; | |||||||||||||||||||||||||||||||
| 123 | 28 | my $sig_text = $sig->text; | |||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | 28 | (my $inner_sig = $sig_text) =~ s/(?: \A \( (?&PerlOWS) | (?&PerlOWS) \) \Z ) $gr//xg; | |||||||||||||||||||||||||||||||
| 126 | 28 | my ($invocant_pl, $rest_pl) = $inner_sig =~ / | |||||||||||||||||||||||||||||||
| 127 | \A | ||||||||||||||||||||||||||||||||
| 128 | (?: | ||||||||||||||||||||||||||||||||
| 129 | ($FPParamListPartial) | ||||||||||||||||||||||||||||||||
| 130 | (?&PerlOWS) [:] (?&PerlOWS) | ||||||||||||||||||||||||||||||||
| 131 | )? | ||||||||||||||||||||||||||||||||
| 132 | ($FPParamListPartial) | ||||||||||||||||||||||||||||||||
| 133 | \Z $gr/x; | ||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | 28 | my @invocants = $self->_parse_param_list($m, $invocant_pl); | |||||||||||||||||||||||||||||||
| 136 | 28 | my @params = $self->_parse_param_list($m, $rest_pl); | |||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||
| 138 | 28 | $cb->($m, $kw_text, \@invocants, \@params); | |||||||||||||||||||||||||||||||
| 139 | 28 | }); | |||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||
| 143 | 14 | ▶ | sub _transform_to_plain_via_generate_front { | ||||||||||||||||||||||||||||||
|
Subroutine
_transform_to_plain_via_generate_front: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 144 | 14 | my ($self, $kw_text, $invocants, $params) = @_; | |||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | 14 | my $kw_info = $self->_import_info->{fp}{$kw_text}; | |||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||
| 148 | 14 | my @invocant_vars; | |||||||||||||||||||||||||||||||
| 149 | 14 | ▶ | if( ! @$invocants && $kw_info->{shift} ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
not @$invocants and $kw_info->{"shift"}
MC/DC100%2/2
not @$invocants and $kw_info->{"shift"}
not @$invocants
$kw_info->{"shift"}
Truth table100%3/3
not(A) and B
A= not @$invocantsB= $kw_info->{"shift"}
| |||||||||||||||||||||||||||||||||
| 150 | 10 | push @invocant_vars, split ' ', $kw_info->{shift}; | |||||||||||||||||||||||||||||||
| 151 | } elsif( @$invocants ) { | ||||||||||||||||||||||||||||||||
| 152 | 1 | push @invocant_vars, map { $_->{var} } @$invocants; | |||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||
| 155 | 14 | my @front_statements; | |||||||||||||||||||||||||||||||
| 156 | 14 | ▶ | if( @invocant_vars ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 157 | 11 | my $shift_perl = join "; ", map { "my $_ = shift" } @invocant_vars; | |||||||||||||||||||||||||||||||
| 158 | 11 | push @front_statements, $shift_perl; | |||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||
| 160 | 14 | ▶ | if( @$params ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 161 | 13 | my @params_vars; | |||||||||||||||||||||||||||||||
| 162 | 13 | push @params_vars, map { $_->{var} } @$params; | |||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||
| 164 | 13 | my $params_perl = join ", ", @params_vars; | |||||||||||||||||||||||||||||||
| 165 | 13 | push @front_statements, "my ($params_perl) = \@_"; | |||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||
| 167 | 14 | my $front = join "; ", @front_statements; | |||||||||||||||||||||||||||||||
| 168 | 14 | $front .= ";"; | |||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||
| 170 | 14 | return $front; | |||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||
| 173 | 14 | ▶ | sub _transform_to_plain_via_deparse_front { | ||||||||||||||||||||||||||||||
|
Subroutine
_transform_to_plain_via_deparse_front: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||
| 174 | 14 | my ($self, $kw_text, $invocants, $params) = @_; | |||||||||||||||||||||||||||||||
| 175 | 14 | my $sig_text = ''; | |||||||||||||||||||||||||||||||
| 176 | 14 | $sig_text .= '('; | |||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||
| 178 | 14 | ▶ | if( @$invocants ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 179 | $sig_text .= join ", ", map { | ||||||||||||||||||||||||||||||||
| 180 | 1 | $_->{var} | |||||||||||||||||||||||||||||||
| 181 | 1 | } @$invocants; | |||||||||||||||||||||||||||||||
| 182 | 1 | $sig_text .= " : "; | |||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||
| 184 | 14 | ▶ | if( @$params ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 185 | $sig_text .= join ", ", map { | ||||||||||||||||||||||||||||||||
| 186 | 13 | my $param_reconstitute = join " ", grep defined, @$_{qw(var hasdefault default)}; | |||||||||||||||||||||||||||||||
| 187 | 23 | ▶ | if( exists $_->{named} && $_->{named} eq ":" ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $_->{"named"} and $_->{"named"} eq ":"
MC/DC100%2/2
exists $_->{"named"} and $_->{"named"} eq ":"
exists $_->{"named"}
$_->{"named"} eq ":"
Truth table100%3/3
A and B
A= exists $_->{"named"}B= $_->{"named"} eq ":"
| |||||||||||||||||||||||||||||||||
| 188 | 10 | $param_reconstitute = ":" . $param_reconstitute; | |||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||
| 190 | $param_reconstitute | ||||||||||||||||||||||||||||||||
| 191 | 23 | } @$params; | |||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||
| 194 | 14 | $sig_text .= ')'; | |||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||
| 196 | 14 | my $front = $self->_fp_arg_code_deparse($kw_text, $sig_text); | |||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||
| 198 | 14 | return $front; | |||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||
| 201 | 28 | ▶ | sub _transform_to_plain_cb { | ||||||||||||||||||||||||||||||
|
Subroutine
_transform_to_plain_cb: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 202 | 28 | my ($self, $top, $cb) = @_; | |||||||||||||||||||||||||||||||
| 203 | 28 | ▶ | $self->_do_transform($top, sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 204 | 28 | my ($m, $kw_text, $invocants, $params) = @_; | |||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||
| 206 | 28 | my ($kw, $sig, $rest) = @{$m->submatches}{qw(kw sig rest)}; | |||||||||||||||||||||||||||||||
| 207 | 28 | my $kw_info = $self->_import_info->{fp}{$kw_text}; | |||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||
| 209 | 28 | $kw->replace_text('sub'); | |||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||
| 211 | 28 | my $front = $self->$cb($kw_text, $invocants, $params); | |||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||
| 213 | 28 | $self->_transform_place_front_in_block($rest, $front); | |||||||||||||||||||||||||||||||
| 214 | 28 | $sig->replace_text(''); | |||||||||||||||||||||||||||||||
| 215 | 28 | }); | |||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | sub transform_to_plain { | ||||||||||||||||||||||||||||||
|
Subroutine
transform_to_plain: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 219 | 0 | my ($self, $top) = @_; | |||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | $self->_transform_to_plain_cb( $top, sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 221 | 0 | my $front_generate = _transform_to_plain_via_generate_front(@_); | |||||||||||||||||||||||||||||||
| 222 | 0 | my $front_deparse = _transform_to_plain_via_deparse_front(@_); | |||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if( $front_generate ne $front_deparse ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 224 | 0 | warn <<EOF | |||||||||||||||||||||||||||||||
| 225 | Front not the same: | ||||||||||||||||||||||||||||||||
| 226 | - Gen: $front_generate | ||||||||||||||||||||||||||||||||
| 227 | - Dep: $front_deparse | ||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||
| 229 | EOF | ||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||
| 231 | 0 | return $front_deparse; | |||||||||||||||||||||||||||||||
| 232 | 0 | }); | |||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||
| 235 | 14 | ▶ | sub transform_to_plain_via_generate { | ||||||||||||||||||||||||||||||
|
Subroutine
transform_to_plain_via_generate: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 236 | 14 | my ($self, $top) = @_; | |||||||||||||||||||||||||||||||
| 237 | 14 | $self->_transform_to_plain_cb( $top, \&_transform_to_plain_via_generate_front ); | |||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||
| 240 | 14 | ▶ | sub transform_to_plain_via_deparse { | ||||||||||||||||||||||||||||||
|
Subroutine
transform_to_plain_via_deparse: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 241 | 14 | my ($self, $top) = @_; | |||||||||||||||||||||||||||||||
| 242 | 14 | $self->_transform_to_plain_cb( $top, \&_transform_to_plain_via_deparse_front ); | |||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||
| 245 | 56 | ▶ | sub _parse_param_list { | ||||||||||||||||||||||||||||||
|
Subroutine
_parse_param_list: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 246 | 56 | my ($self, $m, $param_text) = @_; | |||||||||||||||||||||||||||||||
| 247 | 56 | ▶ | return () unless $param_text; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 248 | 28 | my $gr = $m->grammar_regexp; | |||||||||||||||||||||||||||||||
| 249 | 28 | (my $capturing_re = $FPParamRE) =~ s/^(\s*)#/$1/gm; | |||||||||||||||||||||||||||||||
| 250 | 28 | my @params; | |||||||||||||||||||||||||||||||
| 251 | 28 | ▶ | if( $param_text =~ /\A $capturing_re $gr/xg ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 252 | 28 | push @params, +{ %+ }; | |||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||
| 254 | 28 | ▶ | while( $param_text =~ /\G (?&PerlOWS) [,] (?&PerlOWS) $capturing_re $gr/xg) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 255 | 20 | push @params, +{ %+ }; | |||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||
| 257 | 28 | for my $param (@params) { | |||||||||||||||||||||||||||||||
| 258 | 48 | ▶ | if( exists $param->{other} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 259 | 4 | $param->{var} = delete $param->{other}; | |||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||
| 262 | 28 | @params; | |||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||
| 266 | 14 | ▶ | sub _fp_arg_code_deparse { | ||||||||||||||||||||||||||||||
|
Subroutine
_fp_arg_code_deparse: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 267 | 14 | my ($self, $kw_text, $sig_text) = @_; | |||||||||||||||||||||||||||||||
| 268 | 14 | my $kw_info = $self->_import_info->{fp}{$kw_text}; | |||||||||||||||||||||||||||||||
| 269 | 14 | my $text = $self->_deparse_fp( $kw_text, $sig_text ); | |||||||||||||||||||||||||||||||
| 270 | 14 | (my $replaced = $text) =~ s/\Qpackage Eval::Closure::Sandbox_\E.*?^\s*}$//ms; | |||||||||||||||||||||||||||||||
| 271 | 14 | $replaced =~ s/^\s*\QFunction::Parameters::_croak\E.*;$//mg; | |||||||||||||||||||||||||||||||
| 272 | 14 | ▶ | if( $kw_info->{instl} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 273 | 1 | $replaced =~ s/^\s*\Q@{[ $kw_info->{instl} ]}\E\(.*\{$//mg; | |||||||||||||||||||||||||||||||
| 274 | 1 | $replaced =~ s/^(\s*42;)\n\s*\}\n\s*\);$/$1/mg; | |||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||
| 276 | 14 | $replaced =~ s/\A[^{]*?\{\s*|42;\n\}\Z//msg; | |||||||||||||||||||||||||||||||
| 277 | 14 | $replaced =~ s/^\s*|\s*$//msg; | |||||||||||||||||||||||||||||||
| 278 | 14 | $replaced =~ s/\n+/ /msg; | |||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||
| 280 | 14 | $replaced =~ s/shift\(\);/shift;/g; | |||||||||||||||||||||||||||||||
| 281 | 14 | $replaced =~ s/my\(/my (/g; | |||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||
| 283 | 14 | $replaced =~ s/\Q%{__rest} = ();\E/(%{__rest}) = ();/; | |||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||
| 285 | 14 | $replaced; | |||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||
| 288 | 14 | ▶ | sub _deparse_fp { | ||||||||||||||||||||||||||||||
|
Subroutine
_deparse_fp: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 289 | 14 | require B::Deparse; | |||||||||||||||||||||||||||||||
| 290 | 14 | require Eval::Closure; | |||||||||||||||||||||||||||||||
| 291 | # https://github.com/mauke/Function-Parameters/issues/29 | ||||||||||||||||||||||||||||||||
| 292 | 14 | my $deparse = B::Deparse->new("-d"); | |||||||||||||||||||||||||||||||
| 293 | 14 | my ($self, $kw_text, $sig_text) = @_; | |||||||||||||||||||||||||||||||
| 294 | 14 | my $kw_info = $self->_import_info->{fp}{$kw_text}; | |||||||||||||||||||||||||||||||
| 295 | 14 | my $code = qq{ | |||||||||||||||||||||||||||||||
| 296 | 14 | use @{[ $self->setup_package ]}; | |||||||||||||||||||||||||||||||
| 297 | }; | ||||||||||||||||||||||||||||||||
| 298 | 14 | ▶ | if( $kw_info->{instl} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 299 | 1 | $code .= qq{ | |||||||||||||||||||||||||||||||
| 300 | sub { | ||||||||||||||||||||||||||||||||
| 301 | $kw_text foo $sig_text { 42 } | ||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||
| 303 | }; | ||||||||||||||||||||||||||||||||
| 304 | } else { | ||||||||||||||||||||||||||||||||
| 305 | 13 | $code .= qq{ | |||||||||||||||||||||||||||||||
| 306 | $kw_text $sig_text { 42 }; | ||||||||||||||||||||||||||||||||
| 307 | }; | ||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||
| 309 | 14 | my $coderef = Eval::Closure::eval_closure( | |||||||||||||||||||||||||||||||
| 310 | source => $code, | ||||||||||||||||||||||||||||||||
| 311 | ); | ||||||||||||||||||||||||||||||||
| 312 | 14 | my $text = $deparse->coderef2text( $coderef ); | |||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||
| 315 | 28 | ▶ | sub _transform_place_front_in_block { | ||||||||||||||||||||||||||||||
|
Subroutine
_transform_place_front_in_block: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 316 | 28 | my ($self, $rest, $front) = @_; | |||||||||||||||||||||||||||||||
| 317 | 28 | ▶ | $rest->transform_text(sub { s/^(\s*)\{/${1}{ ${front}/ }); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||
| 320 | 1 | 1; | |||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||
| 322 | __END__ | ||||||||||||||||||||||||||||||||