| 1 | # This file provides a class that parses the Code -member | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # of the PDL::PP code. | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # This is what makes the nice loops go around etc. | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | package # hide from PAUSE/MetaCPAN | ||||||||||||||||||||||||||||||||||||||||||
| 8 | PDL::PP::Code; | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 317 | ▶ | sub get_pdls { @{$_[0]}{qw(ParNames ParObjs)} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_pdls: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | my @code_args_always = qw(BadFlag SignatureObj GenericTypes ExtraGenericSwitches HaveBroadcasting Name); | |||||||||||||||||||||||||||||||||||||||||
| 17 | 15 | ▶ | sub make_args { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_args: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 15 | my ($target) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 15 | ("${target}CodeParsed", ["${target}CodeUnparsed","Bad${target}CodeUnparsed?",@code_args_always]); | |||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | # Do the appropriate substitutions in the code. | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 39 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=24 SCAR=33.9
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 39 | my($class,$code,$badcode, | |||||||||||||||||||||||||||||||||||||||||
| 25 | $handlebad, $sig,$generictypes,$extrageneric,$havebroadcasting,$name, | ||||||||||||||||||||||||||||||||||||||||||
| 26 | $dont_add_brcloop, $backcode, $nulldatacheck) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 39 | my $parnames = $sig->names_sorted; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 39 | $handlebad = !!$handlebad; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 39 | ▶ | confess "Error: missing name argument to PDL::PP::Code->new call!\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | unless defined $name; | ||||||||||||||||||||||||||||||||||||||||||
| 32 | confess "Error: empty or undefined GenericTypes!\n" | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 39 | ▶ | unless @{$generictypes || []}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$generictypes || []
MC/DC0%0/1
$generictypes || []
$generictypes
Truth table50%1/2
A
A= $generictypes
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 39 | ▶ | $badcode //= $code if $handlebad; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$badcode //= $code
MC/DC0%0/2
$badcode //= $code
$badcode
$code
Truth table33%1/3
A //= B
A= $badcodeB= $code
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | # last two arguments may not be supplied | ||||||||||||||||||||||||||||||||||||||||||
| 38 | # | ||||||||||||||||||||||||||||||||||||||||||
| 39 | # "backcode" is a flag to the PDL::PP::Broadcastloop class indicating the broadcastloop | ||||||||||||||||||||||||||||||||||||||||||
| 40 | # is for writeback code (typically used for writeback of data from child to parent PDL | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 39 | ▶ | $dont_add_brcloop ||= !$havebroadcasting; # two have identical (though inverted) meaning so only track one | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$dont_add_brcloop ||= !$havebroadcasting
MC/DC100%2/2
$dont_add_brcloop ||= !$havebroadcasting
$dont_add_brcloop
!$havebroadcasting
Truth table100%3/3
A ||= not(B)
A= $dont_add_brcloopB= !$havebroadcasting
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | # C++ style comments | ||||||||||||||||||||||||||||||||||||||||||
| 45 | # | ||||||||||||||||||||||||||||||||||||||||||
| 46 | # This regexp isn't perfect because it doesn't cope with | ||||||||||||||||||||||||||||||||||||||||||
| 47 | # literal string constants. | ||||||||||||||||||||||||||||||||||||||||||
| 48 | # | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 39 | $code =~ s,//.*?\n,,g; | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 39 | ▶ | if ($::PP_VERBOSE) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | print "Processing code for $name\n"; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | print "DONT_ADD_BRCLOOP!\n" if $dont_add_brcloop; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | print "EXTRAGEN: {" . | |||||||||||||||||||||||||||||||||||||||||
| 55 | join(" ", | ||||||||||||||||||||||||||||||||||||||||||
| 56 | map "$_=>$$extrageneric{$_}", sort keys %$extrageneric) | ||||||||||||||||||||||||||||||||||||||||||
| 57 | . "}\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | print "ParNAMES: ",(join ',',@$parnames),"\n"; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | print "GENTYPES: ", @$generictypes, "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | print "HandleBad: $handlebad\n"; | |||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 39 | my $this = bless { | |||||||||||||||||||||||||||||||||||||||||
| 63 | IndObjs => $sig->dims_obj, | ||||||||||||||||||||||||||||||||||||||||||
| 64 | ParNames => $parnames, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | ParObjs => $sig->objs, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | Sig => $sig, | ||||||||||||||||||||||||||||||||||||||||||
| 67 | Gencurtype => [], # stack to hold GenType in generic switches | ||||||||||||||||||||||||||||||||||||||||||
| 68 | ftypes_vars => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 69 | ftypes_type => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 70 | Generictypes => $generictypes, # so that MacroAccess can check it | ||||||||||||||||||||||||||||||||||||||||||
| 71 | Name => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | NullDataCheck => $nulldatacheck, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | BadFlag => $handlebad, | ||||||||||||||||||||||||||||||||||||||||||
| 74 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 39 | my @codes = $code; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 39 | ▶ | push @codes, $badcode if $handlebad && ($code ne $badcode || $badcode =~ /PDL_BAD_CODE|PDL_IF_BAD/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$handlebad and $code ne $badcode || $badcode =~ /PDL_BAD_CODE|PDL_IF_BAD/
$code ne $badcode or $badcode =~ /PDL_BAD_CODE|PDL_IF_BAD/
MC/DC66%2/3
$handlebad and $code ne $badcode || $badcode =~ /PDL_BAD_CODE|PDL_IF_BAD/
$handlebad
$code ne $badcode
$badcode =~ /PDL_BAD_CODE|PDL_IF_BAD/
Truth table75%3/4
A and B or C
A= $handlebadB= $code ne $badcodeC= $badcode =~ /PDL_BAD_CODE|PDL_IF_BAD/
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 39 | my (@coderefs, @sizeprivs); | |||||||||||||||||||||||||||||||||||||||||
| 79 | 39 | for my $c (@codes) { | |||||||||||||||||||||||||||||||||||||||||
| 80 | # First, separate the code into an array of C fragments (strings), | ||||||||||||||||||||||||||||||||||||||||||
| 81 | # variable references (strings starting with $) and | ||||||||||||||||||||||||||||||||||||||||||
| 82 | # loops (array references, 1. item = variable. | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 41 | my ( $broadcastloops, $coderef, $sizeprivs ) = | |||||||||||||||||||||||||||||||||||||||||
| 84 | $this->separate_code( "{$c}" ); | ||||||||||||||||||||||||||||||||||||||||||
| 85 | # Now, if there is no explicit broadcastlooping in the code, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | # enclose everything into it. | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 40 | ▶ | if(!$broadcastloops && !$dont_add_brcloop) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$broadcastloops or $dont_add_brcloop
MC/DC100%2/2
$broadcastloops or $dont_add_brcloop
$broadcastloops
$dont_add_brcloop
Truth table100%3/3
A or B
A= $broadcastloopsB= $dont_add_brcloop
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 32 | ▶ | print "Adding broadcastloop...\n" if $::PP_VERBOSE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 32 | ▶ | $coderef = $coderef->enter(('PDL::PP::'.($backcode ? 'BackCode' : '').'BroadcastLoop')->new); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | # Enclose it all in a generic switch. | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 40 | ▶ | my $if_gentype = ($code.($badcode//'')) =~ /PDL_IF_GENTYPE_/; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$badcode // ""
MC/DC100%1/1
$badcode // ""
$badcode
Truth table100%2/2
A
A= $badcode
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | $coderef = $coderef->enter(PDL::PP::GenericSwitch->new($generictypes, undef, | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 40 | [grep {!$extrageneric->{$_}} @$parnames],'$PRIV(__datatype)',$if_gentype)); | |||||||||||||||||||||||||||||||||||||||||
| 95 | # Do we have extra generic switches? | ||||||||||||||||||||||||||||||||||||||||||
| 96 | # If we do, first reverse the hash: | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 40 | my %glh; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | push @{$glh{$extrageneric->{$_}}},$_ for sort keys %$extrageneric; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 40 | my $no = 0; | |||||||||||||||||||||||||||||||||||||||||
| 100 | $coderef = $coderef->enter(PDL::PP::GenericSwitch->new($generictypes,$no++, | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 40 | $glh{$_},$_,$if_gentype)) for sort keys %glh; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 40 | push @coderefs, $coderef; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 40 | push @sizeprivs, $sizeprivs; | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 38 | ▶ | amalgamate_sizeprivs(@sizeprivs) if @sizeprivs > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 38 | my $sizeprivs = $sizeprivs[0]; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 38 | my $coderef = PDL::PP::BadSwitch->new( @coderefs ); | |||||||||||||||||||||||||||||||||||||||||
| 108 | 38 | ▶ | print "SIZEPRIVSX: ",(join ',',%$sizeprivs),"\n" if $::PP_VERBOSE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 38 | my $pobjs = $sig->objs; | |||||||||||||||||||||||||||||||||||||||||
| 111 | # Then, in this form, put it together what we want the code to actually do. | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 38 | ▶ | print "SIZEPRIVS: ",(join ',',%$sizeprivs),"\n" if $::PP_VERBOSE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | $this->{Code} = (join '',sort values %$sizeprivs). | ||||||||||||||||||||||||||||||||||||||||||
| 114 | ($dont_add_brcloop?'':join '', map "$_\n", | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 'if (!$PRIV(broadcast).incs) $CROAK("broadcast.incs NULL");', | ||||||||||||||||||||||||||||||||||||||||||
| 116 | '/* broadcastloop declarations */', | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 'int __brcloopval;', | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 'register PDL_Indx __tind0,__tind1; /* counters along dim */', | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 'register PDL_Indx __tnpdls = $PRIV(broadcast).npdls;', | ||||||||||||||||||||||||||||||||||||||||||
| 120 | '/* dims here are how many steps along those dims */', | ||||||||||||||||||||||||||||||||||||||||||
| 121 | (map "register PDL_Indx __tinc0_$parnames->[$_] = PDL_BRC_INC(\$PRIV(broadcast).incs,__tnpdls,$_,0);", 0..$#$parnames), | ||||||||||||||||||||||||||||||||||||||||||
| 122 | (map "register PDL_Indx __tinc1_$parnames->[$_] = PDL_BRC_INC(\$PRIV(broadcast).incs,__tnpdls,$_,1);", 0..$#$parnames), | ||||||||||||||||||||||||||||||||||||||||||
| 123 | eol_protect( | ||||||||||||||||||||||||||||||||||||||||||
| 124 | "#define ".$this->broadcastloop_macroname($backcode, 'START') . " " . | ||||||||||||||||||||||||||||||||||||||||||
| 125 | $this->broadcastloop_start($this->func_name($backcode)) | ||||||||||||||||||||||||||||||||||||||||||
| 126 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 127 | eol_protect( | ||||||||||||||||||||||||||||||||||||||||||
| 128 | "#define ".$this->broadcastloop_macroname($backcode, 'END') . " " . | ||||||||||||||||||||||||||||||||||||||||||
| 129 | $this->broadcastloop_end | ||||||||||||||||||||||||||||||||||||||||||
| 130 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 38 | ▶ | (grep $_, map $_->get_incregisters, @$pobjs{sort keys %$pobjs}), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | ). | ||||||||||||||||||||||||||||||||||||||||||
| 133 | $this->params_declare. | ||||||||||||||||||||||||||||||||||||||||||
| 134 | $coderef->get_str($this,[]) | ||||||||||||||||||||||||||||||||||||||||||
| 135 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 36 | $this->{Code}; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } # new | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | # amalgamate sizeprivs from Code/BadCode segments | ||||||||||||||||||||||||||||||||||||||||||
| 140 | # (sizeprivs is a simple hash, with each element | ||||||||||||||||||||||||||||||||||||||||||
| 141 | # containing a string - see PDL::PP::Loop) | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | ▶ | sub amalgamate_sizeprivs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
amalgamate_sizeprivs: called CC=4 SCAR=23.7
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 2 | my ($sizeprivs, $bad_sizeprivs) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | ▶ | while ( my ( $bad_key, $bad_str ) = each %$bad_sizeprivs ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $str = $$sizeprivs{$bad_key}; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | die "ERROR: sizeprivs problem in PP/PDLCode.pm (BadVal stuff)\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $str and $str ne $bad_str
MC/DC0%0/2
defined $str and $str ne $bad_str
defined $str
$str ne $bad_str
Truth table0%0/3
A and B
A= defined $strB= $str ne $bad_str
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | if defined $str and $str ne $bad_str; | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $$sizeprivs{$bad_key} = $bad_str; # copy over | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 70 | ▶ | sub eol_protect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
eol_protect: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 70 | my ($text) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 70 | join " \\\n", grep /\S/, split /\n/, $text; | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 38 | ▶ | sub params_declare { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
params_declare: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 38 | my ($this) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 38 | my ($ord,$pdls) = $this->get_pdls; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 38 | my %istyped = map +($_=>1), grep $pdls->{$_}{FlagTypeOverride}, @$ord; | |||||||||||||||||||||||||||||||||||||||||
| 161 | my @decls = map $_->get_xsdatapdecl($istyped{$_->name} ? "PDL_TYPE_PARAM_".$_->name : "PDL_TYPE_OP", $this->{NullDataCheck}, $istyped{$_->name} ? "PDL_PPSYM_PARAM_".$_->name : "PDL_PPSYM_OP", $this->{BadFlag}), | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 38 | ▶ | map $pdls->{$_}, @$ord; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 38 | my @param_names = ("PDL_TYPE_OP", "PDL_PPSYM_OP", map +("PDL_TYPE_PARAM_$_","PDL_PPSYM_PARAM_$_"), grep $istyped{$_}, @$ord); | |||||||||||||||||||||||||||||||||||||||||
| 164 | 38 | <<EOF; | |||||||||||||||||||||||||||||||||||||||||
| 165 | #ifndef PDL_DECLARE_PARAMS_$this->{Name}_$this->{NullDataCheck} | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 38 | #define PDL_DECLARE_PARAMS_$this->{Name}_$this->{NullDataCheck}(@{[join ',', @param_names]}) \\ | |||||||||||||||||||||||||||||||||||||||||
| 167 | 38 | @{[join " \\\n ", @decls]} | |||||||||||||||||||||||||||||||||||||||||
| 168 | #endif | ||||||||||||||||||||||||||||||||||||||||||
| 169 | EOF | ||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 399 | ▶ | sub func_name { $_[1] ? "writebackdata" : "readdata" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
func_name: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 364 | ▶ | sub broadcastloop_macroname { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
broadcastloop_macroname: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 364 | my ($this, $backcode, $which) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 364 | "PDL_BROADCASTLOOP_${which}_$this->{Name}_".$this->func_name($backcode); | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 35 | ▶ | sub broadcastloop_start { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
broadcastloop_start: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 35 | my ($this, $funcname) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 35 | my ($ord,$pdls) = $this->get_pdls; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 35 | <<EOF; | |||||||||||||||||||||||||||||||||||||||||
| 183 | PDL_BROADCASTLOOP_START( | ||||||||||||||||||||||||||||||||||||||||||
| 184 | $funcname, | ||||||||||||||||||||||||||||||||||||||||||
| 185 | \$PRIV(broadcast), | ||||||||||||||||||||||||||||||||||||||||||
| 186 | \$PRIV(vtable), | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 35 | @{[ PDL::PP::indent 2, join "", map $pdls->{$ord->[$_]}->do_pointeraccess." += __offsp[$_];\n", 0..$#$ord ]} , | |||||||||||||||||||||||||||||||||||||||||
| 188 | 35 | (@{[ PDL::PP::indent 2, join "", map ",".$pdls->{$ord->[$_]}->do_pointeraccess." += __tinc1_$ord->[$_] - __tinc0_$ord->[$_] * __tdims0\n", 0..$#$ord ]} ), | |||||||||||||||||||||||||||||||||||||||||
| 189 | 35 | (@{[ PDL::PP::indent 2, join "", map ",".$pdls->{$ord->[$_]}->do_pointeraccess." += __tinc0_$ord->[$_]\n", 0..$#{$ord} ]} ) | |||||||||||||||||||||||||||||||||||||||||
| 190 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 191 | EOF | ||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 35 | ▶ | sub broadcastloop_end { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
broadcastloop_end: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 35 | my ($this) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 35 | my ($ord,$pdls) = $this->get_pdls(); | |||||||||||||||||||||||||||||||||||||||||
| 197 | 35 | <<EOF; | |||||||||||||||||||||||||||||||||||||||||
| 198 | PDL_BROADCASTLOOP_END( | ||||||||||||||||||||||||||||||||||||||||||
| 199 | \$PRIV(broadcast), | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 35 | @{[ PDL::PP::indent 2, join "", map $pdls->{$ord->[$_]}->do_pointeraccess." -= __tinc1_$ord->[$_] * __tdims1 + __offsp[$_];\n", 0..$#$ord ]} | |||||||||||||||||||||||||||||||||||||||||
| 201 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 202 | EOF | ||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 5 | ▶ | sub sig {$_[0]->{Sig}} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sig: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | # This sub determines the index name for this index. | ||||||||||||||||||||||||||||||||||||||||||
| 208 | # For example, a(x,y) and x0 becomes [x,x0] | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 30 | ▶ | sub make_loopind { my($this,$ind) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_loopind: called CC=4 SCAR=16.6
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 30 | ($ind, my $cntrlval) = split /\s*=\s*/, $ind; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 30 | my $orig = $ind; | |||||||||||||||||||||||||||||||||||||||||
| 212 | 30 | ▶ | while(!$this->{IndObjs}{$ind}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | if(!((chop $ind) =~ /[0-9]/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | confess("Index not found for $_ ($ind)!\n"); | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 30 | ▶ | my ($initval, $endval, $inc) = split /\s*:\s*/, $cntrlval//''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$cntrlval // ""
MC/DC0%0/1
$cntrlval // ""
$cntrlval
Truth table50%1/2
A
A= $cntrlval
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 30 | [$ind,$orig,$initval,$endval,$inc]; | |||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 5 | my %access2class = ( | |||||||||||||||||||||||||||||||||||||||||
| 222 | GENERIC => 'PDL::PP::GentypeAccess', | ||||||||||||||||||||||||||||||||||||||||||
| 223 | PPSYM => 'PDL::PP::PpsymAccess', | ||||||||||||||||||||||||||||||||||||||||||
| 224 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | 40 | ▶ | sub process { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process: called CC=10 SCAR=23.5
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 40 | my ($this, $code, $stack_ref, $broadcastloops_ref, $sizeprivs) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 228 | 40 | ▶ | while($code) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | # Parse next statement | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 102 | ▶ | $code =~ s/^(.*?) # First, some noise is allowed. This may be bad. | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | ( \$(ISBAD|ISGOOD|SETBAD)\s*\(\s*\$?[a-zA-Z_]\w*\s*\([^)]*\)\s*\) # $ISBAD($a(..)), ditto for ISGOOD and SETBAD | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |\$[a-zA-Z_]\w*\s*\([^)]*\) # $a(...): access | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |\bloop\s*\([^)]+\)\s*%\{ # loop(..) %{ | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |\btypes\s*\([^)]+\)\s*%\{ # types(..) %{ | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |\b(?:thread|broadcast)loop\s*%\{ # broadcastloop %{ | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |%} # %} | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |$)//xs | ||||||||||||||||||||||||||||||||||||||||||
| 238 | or confess("Invalid program $code"); | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 102 | my $control = $2; | |||||||||||||||||||||||||||||||||||||||||
| 240 | # Store the user code. | ||||||||||||||||||||||||||||||||||||||||||
| 241 | # Some day we shall parse everything. | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 102 | push @{$stack_ref->[-1]},$1; | |||||||||||||||||||||||||||||||||||||||||
| 243 | # Then, our control. | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 102 | ▶ | if (!$control) { print("No \$2!\n") if $::PP_VERBOSE; next; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 62 | ▶ | if($control =~ /^loop\s*\(([^)]+)\)\s*%\{/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 5 | my $ob = PDL::PP::Loop->new([split ',',$1], $sizeprivs,$this); | |||||||||||||||||||||||||||||||||||||||||
| 247 | 5 | ▶ | print "SIZEPRIVSXX: $sizeprivs,",(join ',',%$sizeprivs),"\n" if $::PP_VERBOSE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 5 | push @{$stack_ref->[-1]},$ob; | |||||||||||||||||||||||||||||||||||||||||
| 249 | 5 | push @$stack_ref,$ob; | |||||||||||||||||||||||||||||||||||||||||
| 250 | } elsif($control =~ /^types\s*\(([^)]+)\)\s*%\{/) { | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my $ob = PDL::PP::Types->new($1,$this); | |||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | push @{$stack_ref->[-1]},$ob; | |||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | push @$stack_ref,$ob; | |||||||||||||||||||||||||||||||||||||||||
| 254 | } elsif($control =~ /^(?:thread|broadcast)loop\s*%\{/) { | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 3 | my $ob = PDL::PP::BroadcastLoop->new; | |||||||||||||||||||||||||||||||||||||||||
| 256 | 3 | push @{$stack_ref->[-1]},$ob; | |||||||||||||||||||||||||||||||||||||||||
| 257 | 3 | push @$stack_ref,$ob; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 3 | $$broadcastloops_ref++; | |||||||||||||||||||||||||||||||||||||||||
| 259 | } elsif($control =~ /^%}/) { | ||||||||||||||||||||||||||||||||||||||||||
| 260 | 8 | pop @$stack_ref; | |||||||||||||||||||||||||||||||||||||||||
| 261 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 262 | 46 | my ($rest, @add) = $this->expand($control.$code); | |||||||||||||||||||||||||||||||||||||||||
| 263 | 46 | push @{$stack_ref->[-1]}, @add; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 46 | $code = $rest; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | } # while: $code | ||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | # my ( $broadcastloops, $coderef, $sizeprivs ) = $this->separate_code( $code ); | ||||||||||||||||||||||||||||||||||||||||||
| 270 | # | ||||||||||||||||||||||||||||||||||||||||||
| 271 | # separates the code into an array of C fragments (strings), | ||||||||||||||||||||||||||||||||||||||||||
| 272 | # variable references (strings starting with $) and | ||||||||||||||||||||||||||||||||||||||||||
| 273 | # loops (array references, 1. item = variable. | ||||||||||||||||||||||||||||||||||||||||||
| 274 | # | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 41 | ▶ | sub separate_code { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
separate_code: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 41 | my ( $this, $code ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 277 | # First check for standard code errors: | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 41 | $this->catch_code_errors($code); | |||||||||||||||||||||||||||||||||||||||||
| 279 | 40 | my @stack = my $coderef = PDL::PP::Block->new; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 40 | my $broadcastloops = 0; | |||||||||||||||||||||||||||||||||||||||||
| 281 | 40 | my $sizeprivs = {}; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 40 | $this->process($code, \@stack, \$broadcastloops, $sizeprivs); | |||||||||||||||||||||||||||||||||||||||||
| 283 | 40 | ( $broadcastloops, $coderef, $sizeprivs ); | |||||||||||||||||||||||||||||||||||||||||
| 284 | } # sub: separate_code() | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 5 | my $macro_pat = qr/\w+/; | |||||||||||||||||||||||||||||||||||||||||
| 287 | 46 | ▶ | sub expand { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand: called CC=8 SCAR=22.8
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 46 | my ($this, $text) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 289 | 46 | my (undef, $pdl, $inds, $rest) = PDL::PP::Rule::Substitute::macro_extract($text, $macro_pat); | |||||||||||||||||||||||||||||||||||||||||
| 290 | 46 | my @add; | |||||||||||||||||||||||||||||||||||||||||
| 291 | 46 | ▶ | if($pdl =~ /^T/) {@add = PDL::PP::MacroAccess->new($pdl,$inds, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 1 | $this->{Generictypes},$this->{Name});} | |||||||||||||||||||||||||||||||||||||||||
| 293 | 3 | elsif(my $c = $access2class{$pdl}) {@add = $c->new($pdl,$inds)} | |||||||||||||||||||||||||||||||||||||||||
| 294 | elsif($pdl =~ /^(P|)(ISBAD|ISGOOD|SETBAD)(VAR|)$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 8 | my ($opcode, $name) = ($2); | |||||||||||||||||||||||||||||||||||||||||
| 296 | 8 | ▶ | my $get = $1 || $3; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$1 || $3
MC/DC0%0/2
$1 || $3
$1
$3
Truth table33%1/3
A || B
A= $1B= $3
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 8 | ▶ | if (!$get) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $inds =~ s/^\$?([a-zA-Z_]\w*)\s*//; # $ is optional | |||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | $name = $1; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $inds = substr $inds, 1, -1; # chop off brackets | |||||||||||||||||||||||||||||||||||||||||
| 301 | } elsif ($get eq 'P') { | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 8 | ($name, $inds) = PDL::PP::Rule::Substitute::split_cpp($inds); | |||||||||||||||||||||||||||||||||||||||||
| 303 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ($inds, $name) = PDL::PP::Rule::Substitute::split_cpp($inds); | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 8 | @add = PDL::PP::BadAccess->new($opcode,$get,$name,$inds,$this); | |||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 34 | elsif($this->{ParObjs}{$pdl}) {@add = PDL::PP::Access->new($pdl,$inds)} | |||||||||||||||||||||||||||||||||||||||||
| 309 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | confess "unknown construct $pdl($inds)"; | |||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 46 | ($rest, @add); | |||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | # This is essentially a collection of regexes that look for standard code | ||||||||||||||||||||||||||||||||||||||||||
| 316 | # errors and croaks with an explanation if they are found. | ||||||||||||||||||||||||||||||||||||||||||
| 317 | 41 | ▶ | sub catch_code_errors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
catch_code_errors: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | 41 | my ($this, $code_string) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 319 | 41 | my $prefix = "pp_def($this->{Name}): "; | |||||||||||||||||||||||||||||||||||||||||
| 320 | 41 | ▶ | report_error("${prefix}Expected dimension name after 'loop' and before '%{'", $1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | if $code_string =~ /(.*\bloop\s*%\{)/s; | ||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | # Report an error as precisely as possible. If they have #line directives | ||||||||||||||||||||||||||||||||||||||||||
| 325 | # in the code string, use that in the reporting; otherwise, use standard | ||||||||||||||||||||||||||||||||||||||||||
| 326 | # Carp mechanisms | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 5 | my $line_re = qr/(?:PDL_LINENO_START|#\s*line)\s+(\d+)\s+"([^"]*)"/; | |||||||||||||||||||||||||||||||||||||||||
| 328 | 1 | ▶ | sub report_error { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
report_error: called CC=4 SCAR=24.6
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | my ($message, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 330 | # Just croak if they didn't supply a #line directive: | ||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | ▶ | croak($message) if $code !~ $line_re; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | # Find the line at which the error occurred: | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | my $line = 0; | |||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my $filename; | |||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | LINE: foreach (split /\n/, $code) { | |||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $line++; | |||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if (/$line_re/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $line = $1; | |||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | $filename = $2; | |||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | die "$message at $filename line $line\n"; | |||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | ##################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 346 | # | ||||||||||||||||||||||||||||||||||||||||||
| 347 | # Encapsulate the parsing code objects | ||||||||||||||||||||||||||||||||||||||||||
| 348 | # | ||||||||||||||||||||||||||||||||||||||||||
| 349 | # All objects have two methods: | ||||||||||||||||||||||||||||||||||||||||||
| 350 | # new - constructor | ||||||||||||||||||||||||||||||||||||||||||
| 351 | # get_str - get the string to be put into the xsub. | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | package # hide from PAUSE/MetaCPAN | ||||||||||||||||||||||||||||||||||||||||||
| 354 | PDL::PP::Block; | ||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | 40 | ▶ | sub new { my($type) = @_; bless [],$type; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 209 | ▶ | sub myoffs { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
myoffs: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 382 | ▶ | sub myextraindent { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
myextraindent: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | 209 | ▶ | sub myprelude {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
myprelude: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 207 | ▶ | sub mypostlude {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mypostlude: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | 422 | ▶ | sub get_str { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_str: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | 422 | my ($this,$parent,$context) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 365 | 422 | my $str = $this->myprelude($parent,$context); | |||||||||||||||||||||||||||||||||||||||||
| 366 | 422 | ▶ | $str .= PDL::PP::indent 2, $this->get_str_int($parent,$context)//''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$this->get_str_int($parent, $context) // ""
MC/DC0%0/1
$this->get_str_int($parent, $context) // ""
$this->get_str_int($parent, $context)
Truth table50%1/2
A
A= $this->get_str_int($parent, $context)
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 416 | ▶ | $str .= $this->mypostlude($parent,$context)//''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$this->mypostlude($parent, $context) // ""
MC/DC100%1/1
$this->mypostlude($parent, $context) // ""
$this->mypostlude($parent, $context)
Truth table100%2/2
A
A= $this->mypostlude($parent, $context)
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 416 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | 422 | ▶ | sub get_str_int { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_str_int: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | 422 | my ( $this, $parent, $context ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 373 | 422 | my $nth=0; | |||||||||||||||||||||||||||||||||||||||||
| 374 | 422 | my $str = ""; | |||||||||||||||||||||||||||||||||||||||||
| 375 | 422 | MYLOOP: while(1) { | |||||||||||||||||||||||||||||||||||||||||
| 376 | 1007 | ▶ | my $it = $this->can('myitemstart') && $this->myitemstart($parent,$nth); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$this->can('myitemstart') && $this->myitemstart($parent, $nth)
MC/DC100%2/2
$this->can('myitemstart') && $this->myitemstart($parent, $nth)
$this->can('myitemstart')
$this->myitemstart($parent, $nth)
Truth table100%3/3
A && B
A= $this->can('myitemstart')B= $this->myitemstart($parent, $nth)
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | 1007 | ▶ | last MYLOOP if $nth and !$it; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$nth and not $it
MC/DC100%2/2
$nth and not $it
$nth
not $it
Truth table100%3/3
A and not(B)
A= $nthB= not $it
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 591 | ▶ | $str .= $it//''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$it // ""
MC/DC100%1/1
$it // ""
$it
Truth table100%2/2
A
A= $it
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 591 | $str .= PDL::PP::indent $this->myextraindent, join '', $this->get_contained($parent,$context); | |||||||||||||||||||||||||||||||||||||||||
| 380 | 585 | ▶ | $str .= $it if $it = $this->can('myitemend') && $this->myitemend($parent,$nth); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$this->can('myitemend') && $this->myitemend($parent, $nth)
MC/DC50%1/2
$this->can('myitemend') && $this->myitemend($parent, $nth)
$this->can('myitemend')
$this->myitemend($parent, $nth)
Truth table66%2/3
A && B
A= $this->can('myitemend')B= $this->myitemend($parent, $nth)
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 585 | $nth++; | |||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 416 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 384 | } # get_str_int() | ||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | 591 | ▶ | sub get_contained { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_contained: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | 591 | my ($this, $parent, $context) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 388 | 591 | ▶ | map ref($_) ? $_->get_str($parent, $context) : $_, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | @$this[$this->myoffs..$#$this]; | ||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 72 | ▶ | sub enter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enter: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 72 | my ($this, $new) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 394 | 72 | push @$new, $this; | |||||||||||||||||||||||||||||||||||||||||
| 395 | 72 | $new; | |||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | ########################### | ||||||||||||||||||||||||||||||||||||||||||
| 399 | # | ||||||||||||||||||||||||||||||||||||||||||
| 400 | # Deal with bad code | ||||||||||||||||||||||||||||||||||||||||||
| 401 | # - ie create something like | ||||||||||||||||||||||||||||||||||||||||||
| 402 | # if ( badflag ) { badcode } else { goodcode } | ||||||||||||||||||||||||||||||||||||||||||
| 403 | # | ||||||||||||||||||||||||||||||||||||||||||
| 404 | package # hide from PAUSE/MetaCPAN | ||||||||||||||||||||||||||||||||||||||||||
| 405 | PDL::PP::BadSwitch; | ||||||||||||||||||||||||||||||||||||||||||
| 406 | 5 | our @ISA = "PDL::PP::Block"; | |||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 38 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | 38 | my($type,$good,$bad) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 410 | 38 | return bless [$good,$bad], $type; | |||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | 38 | ▶ | sub get_str { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_str: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 38 | my ($this,$parent,$context) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 415 | 38 | my $good = $this->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 416 | 38 | my $good_str = <<EOF; | |||||||||||||||||||||||||||||||||||||||||
| 417 | #define PDL_IF_BAD(t,f) f | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 38 | @{[ $good->get_str($parent,$context) | |||||||||||||||||||||||||||||||||||||||||
| 419 | ]}#undef PDL_IF_BAD | ||||||||||||||||||||||||||||||||||||||||||
| 420 | EOF | ||||||||||||||||||||||||||||||||||||||||||
| 421 | 36 | ▶ | return $good_str if !defined(my $bad = $this->[1]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | 2 | my $str = <<EOF; | |||||||||||||||||||||||||||||||||||||||||
| 423 | if ( \$PRIV(bvalflag) ) { /* ** do 'bad' Code ** */ | ||||||||||||||||||||||||||||||||||||||||||
| 424 | #define PDL_BAD_CODE | ||||||||||||||||||||||||||||||||||||||||||
| 425 | #define PDL_IF_BAD(t,f) t | ||||||||||||||||||||||||||||||||||||||||||
| 426 | 2 | @{[ PDL::PP::indent 2, $bad->get_str($parent,$context) | |||||||||||||||||||||||||||||||||||||||||
| 427 | ]} #undef PDL_BAD_CODE | ||||||||||||||||||||||||||||||||||||||||||
| 428 | #undef PDL_IF_BAD | ||||||||||||||||||||||||||||||||||||||||||
| 429 | } else { /* ** else do 'good' Code ** */ | ||||||||||||||||||||||||||||||||||||||||||
| 430 | 2 | @{[ PDL::PP::indent 2, $good_str | |||||||||||||||||||||||||||||||||||||||||
| 431 | ]}} | ||||||||||||||||||||||||||||||||||||||||||
| 432 | EOF | ||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | package # hide from PAUSE/MetaCPAN | ||||||||||||||||||||||||||||||||||||||||||
| 436 | PDL::PP::Loop; | ||||||||||||||||||||||||||||||||||||||||||
| 437 | 5 | our @ISA = "PDL::PP::Block"; | |||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | 5 | ▶ | sub new { my($type,$args,$sizeprivs,$parent) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 5 | my $this = bless [$args],$type; | |||||||||||||||||||||||||||||||||||||||||
| 441 | 5 | for (@$args) { | |||||||||||||||||||||||||||||||||||||||||
| 442 | 5 | ▶ | print "SIZP $sizeprivs, $_\n" if $::PP_VERBOSE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 443 | 5 | my $i = $parent->make_loopind($_); | |||||||||||||||||||||||||||||||||||||||||
| 444 | 5 | my $i_size = $parent->sig->dims_obj->ind_obj($i->[0])->get_size; | |||||||||||||||||||||||||||||||||||||||||
| 445 | 5 | $sizeprivs->{$i->[0]} = "register PDL_Indx __$i->[0]_size = $i_size;\n"; | |||||||||||||||||||||||||||||||||||||||||
| 446 | 5 | ▶ | print "SP :",(join ',',%$sizeprivs),"\n" if $::PP_VERBOSE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 448 | 5 | return $this; | |||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | 25 | ▶ | sub myoffs { return 1; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
myoffs: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | 25 | ▶ | sub myprelude { my($this,$parent,$context) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
myprelude: called CC=13 SCAR=36.5
| |||||||||||||||||||||||||||||||||||||||||||
| 453 | 25 | my $text = ""; | |||||||||||||||||||||||||||||||||||||||||
| 454 | push @$context, map { | ||||||||||||||||||||||||||||||||||||||||||
| 455 | 25 | my $i = $parent->make_loopind($_); | |||||||||||||||||||||||||||||||||||||||||
| 456 | 25 | my ($loopdim, $loopvar, $loopstart, $loopend, $loopinc) = @$i; | |||||||||||||||||||||||||||||||||||||||||
| 457 | 25 | my $loopstopvar = "__${loopvar}_stop"; | |||||||||||||||||||||||||||||||||||||||||
| 458 | 25 | ▶ | $loopinc ||= 1; my $cmp; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$loopinc ||= 1
MC/DC0%0/1
$loopinc ||= 1
$loopinc
Truth table50%1/2
A
A= $loopinc
| |||||||||||||||||||||||||||||||||||||||||||
| 459 | 25 | ▶ | if ($loopinc =~ /^-/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | $loopstart = !(defined $loopstart && length $loopstart) ? "(__${loopdim}_size-1)" : | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $loopstart && length $loopstart
MC/DC0%0/2
defined $loopstart && length $loopstart
defined $loopstart
length $loopstart
Truth table0%0/3
A && B
A= defined $loopstartB= length $loopstart
| |||||||||||||||||||||||||||||||||||||||||||
| 461 | $loopstart =~ /^-/ ? "PDLMIN((__${loopdim}_size$loopstart), (__${loopdim}_size-1))" : | ||||||||||||||||||||||||||||||||||||||||||
| 462 | "PDLMIN($loopstart, (__${loopdim}_size-1))"; | ||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $cmp = ">="; | |||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | $loopend = !$loopend ? 0 : | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 465 | $loopend =~ /^-/ ? "PDLMAX((__${loopdim}_size$loopend),0)" : | ||||||||||||||||||||||||||||||||||||||||||
| 466 | "PDLMAX(($loopend),0)"; | ||||||||||||||||||||||||||||||||||||||||||
| 467 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 468 | # count upwards | ||||||||||||||||||||||||||||||||||||||||||
| 469 | 25 | ▶ | $loopstart = !$loopstart ? 0 : | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 470 | $loopstart =~ /^-/ ? "PDLMAX((__${loopdim}_size$loopstart),0)" : | ||||||||||||||||||||||||||||||||||||||||||
| 471 | "PDLMAX(($loopstart),0)"; | ||||||||||||||||||||||||||||||||||||||||||
| 472 | 25 | $cmp = "<"; | |||||||||||||||||||||||||||||||||||||||||
| 473 | 25 | ▶ | $loopend = !(defined $loopend && length $loopend) ? "(__${loopdim}_size)" : | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
defined $loopend && length $loopend
MC/DC0%0/2
defined $loopend && length $loopend
defined $loopend
length $loopend
Truth table33%1/3
A && B
A= defined $loopendB= length $loopend
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | $loopend =~ /^-/ ? "(__${loopdim}_size$loopend)" : | ||||||||||||||||||||||||||||||||||||||||||
| 475 | "PDLMIN($loopend, (__${loopdim}_size))"; | ||||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||
| 477 | 25 | $text .= "{/* Open $_ */ PDL_EXPAND2(register PDL_Indx $loopvar=$loopstart, $loopstopvar=$loopend); for(; $loopvar$cmp$loopstopvar; $loopvar+=$loopinc) {"; | |||||||||||||||||||||||||||||||||||||||||
| 478 | 25 | $i; | |||||||||||||||||||||||||||||||||||||||||
| 479 | 25 | } @{$this->[0]}; | |||||||||||||||||||||||||||||||||||||||||
| 480 | 25 | $text; | |||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||
| 482 | 25 | ▶ | sub mypostlude { my($this,$parent,$context) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mypostlude: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 483 | 25 | splice @$context, - ($#{$this->[0]}+1); | |||||||||||||||||||||||||||||||||||||||||
| 484 | 25 | return join '', map "}} /* Close $_ */", @{$this->[0]}; | |||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | package # hide from PAUSE/MetaCPAN | ||||||||||||||||||||||||||||||||||||||||||
| 488 | PDL::PP::GenericSwitch; | ||||||||||||||||||||||||||||||||||||||||||
| 489 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 490 | 5 | our @ISA = "PDL::PP::Block"; | |||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | # make the typetable from info in PDL::Types | ||||||||||||||||||||||||||||||||||||||||||
| 493 | 5 | ▶ | use PDL::Types ':All'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 494 | 5 | my %type2canonical = map +($_->ppsym=>$_,$_->identifier=>$_), types(); | |||||||||||||||||||||||||||||||||||||||||
| 495 | 5 | my @typetable = map [$_->ppsym, $_], types(); | |||||||||||||||||||||||||||||||||||||||||
| 496 | 40 | ▶ | sub get_generictyperecs { my($types) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_generictyperecs: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | 40 | my @bad = grep !$type2canonical{$_}, @$types; | |||||||||||||||||||||||||||||||||||||||||
| 498 | 40 | ▶ | confess "Invalid GenericType (@bad)!" if @bad; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 499 | 40 | my %wanted; @wanted{map $type2canonical{$_}->ppsym, @$types} = (); | |||||||||||||||||||||||||||||||||||||||||
| 500 | 40 | [ map $_->[1], grep exists $wanted{$_->[0]}, @typetable ]; | |||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | # Types: BSULFD | ||||||||||||||||||||||||||||||||||||||||||
| 504 | 40 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 505 | 40 | my ($type,$types,$name,$varnames,$whattype,$if_gentype) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 506 | 40 | my %vars; @vars{@$varnames} = (); | |||||||||||||||||||||||||||||||||||||||||
| 507 | 40 | bless [get_generictyperecs($types), $name, \%vars, $whattype, $if_gentype], $type; | |||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | 209 | ▶ | sub myoffs {5} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
myoffs: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | 209 | ▶ | sub myextraindent { 2 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
myextraindent: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | 40 | ▶ | sub myprelude { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
myprelude: called CC=3 SCAR=11.8
| |||||||||||||||||||||||||||||||||||||||||||
| 514 | 40 | my ($this,$parent,$context) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 515 | 40 | push @{$parent->{Gencurtype}}, undef; # so that $GENERIC can get at it | |||||||||||||||||||||||||||||||||||||||||
| 516 | die "ERROR: need to rethink NaN support in GenericSwitch\n" | ||||||||||||||||||||||||||||||||||||||||||
| 517 | 40 | ▶ | if defined $this->[1] and $parent->{ftypes_type}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $this->[1] and $parent->{"ftypes_type"}
MC/DC0%0/2
defined $this->[1] and $parent->{"ftypes_type"}
defined $this->[1]
$parent->{"ftypes_type"}
Truth table33%1/3
A and B
A= defined $this->[1]B= $parent->{"ftypes_type"}
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | 40 | qq[switch ($this->[3]) { /* Start generic switch */\n]; | |||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||
| 521 | 5 | my @GENTYPE_ATTRS = qw(integer real unsigned); | |||||||||||||||||||||||||||||||||||||||||
| 522 | 247 | ▶ | sub myitemstart { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
myitemstart: called CC=6 SCAR=18.8
| |||||||||||||||||||||||||||||||||||||||||||
| 523 | 247 | my ($this,$parent,$nth) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 524 | 247 | ▶ | my $item = $this->[0][$nth] || return ""; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$this->[0][$nth] || (return '')
MC/DC100%1/1
$this->[0][$nth] || (return '')
$this->[0][$nth]
Truth table100%2/2
A
A= $this->[0][$nth]
| |||||||||||||||||||||||||||||||||||||||||||
| 525 | 209 | $parent->{Gencurtype}[-1] = $item; | |||||||||||||||||||||||||||||||||||||||||
| 526 | 209 | ▶ | @$parent{qw(ftypes_type ftypes_vars)} = ($item, $this->[2]) if defined $this->[1]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 527 | 209 | my ($ord,$pdls) = $parent->get_pdls; | |||||||||||||||||||||||||||||||||||||||||
| 528 | 209 | my %istyped = map +($_=>1), grep $pdls->{$_}{FlagTypeOverride}, @$ord; | |||||||||||||||||||||||||||||||||||||||||
| 529 | my @param_ctypes = ($item->ctype, $item->ppsym, | ||||||||||||||||||||||||||||||||||||||||||
| 530 | map +($pdls->{$_}->adjusted_type($item)->ctype, | ||||||||||||||||||||||||||||||||||||||||||
| 531 | $pdls->{$_}->adjusted_type($item)->ppsym), | ||||||||||||||||||||||||||||||||||||||||||
| 532 | 209 | grep $istyped{$_}, @$ord); | |||||||||||||||||||||||||||||||||||||||||
| 533 | 209 | my $decls = keys %{$this->[2]} == @$ord | |||||||||||||||||||||||||||||||||||||||||
| 534 | 209 | ? "PDL_DECLARE_PARAMS_$parent->{Name}_$parent->{NullDataCheck}(@{[join ',', @param_ctypes]})\n" | |||||||||||||||||||||||||||||||||||||||||
| 535 | : join '', map $_->get_xsdatapdecl($_->adjusted_type($item)->ctype, $parent->{NullDataCheck}, $_->adjusted_type($item)->ppsym, $parent->{BadFlag}), | ||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | map $parent->{ParObjs}{$_}, sort keys %{$this->[2]}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 537 | 209 | ▶ | my @gentype_decls = !$this->[4] ? () : map "#define PDL_IF_GENTYPE_".uc($_)."(t,f) ". | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 538 | ($item->$_ ? 't' : 'f')."\n", | ||||||||||||||||||||||||||||||||||||||||||
| 539 | @GENTYPE_ATTRS; | ||||||||||||||||||||||||||||||||||||||||||
| 540 | 209 | "case @{[$item->sym]}: {\n" . | |||||||||||||||||||||||||||||||||||||||||
| 541 | PDL::PP::indent 2, join '', | ||||||||||||||||||||||||||||||||||||||||||
| 542 | @gentype_decls, | ||||||||||||||||||||||||||||||||||||||||||
| 543 | $decls; | ||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||
| 546 | 207 | ▶ | sub myitemend { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
myitemend: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||
| 547 | 207 | my ($this,$parent,$nth) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 548 | 207 | ▶ | my $item = $this->[0][$nth] || return ""; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$this->[0][$nth] || (return '')
MC/DC0%0/1
$this->[0][$nth] || (return '')
$this->[0][$nth]
Truth table50%1/2
A
A= $this->[0][$nth]
| |||||||||||||||||||||||||||||||||||||||||||
| 549 | 207 | ▶ | join '', | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | "\n", | ||||||||||||||||||||||||||||||||||||||||||
| 551 | (!$this->[4] ? () : map "#undef PDL_IF_GENTYPE_".uc($_)."\n", @GENTYPE_ATTRS), | ||||||||||||||||||||||||||||||||||||||||||
| 552 | "} break;\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | 38 | ▶ | sub mypostlude { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mypostlude: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | 38 | my($this,$parent,$context) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 557 | 38 | pop @{$parent->{Gencurtype}}; # and clean up the Gentype stack | |||||||||||||||||||||||||||||||||||||||||
| 558 | 38 | ▶ | $parent->{ftypes_type} = undef if defined $this->[1]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 559 | 38 | my $supported = join '', map $_->ppsym, @{$this->[0]}; | |||||||||||||||||||||||||||||||||||||||||
| 560 | 38 | " default: return PDL->make_error(PDL_EUSERERROR, \"PP INTERNAL ERROR in $parent->{Name}: unhandled datatype(%d), only handles ($supported)! PLEASE MAKE A BUG REPORT\\n\", $this->[3]);\n}\n"; | |||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | #### | ||||||||||||||||||||||||||||||||||||||||||
| 564 | # | ||||||||||||||||||||||||||||||||||||||||||
| 565 | # This relies on PP.pm making sure that initbroadcaststruct always sets | ||||||||||||||||||||||||||||||||||||||||||
| 566 | # up the two first dimensions even when they are not necessary. | ||||||||||||||||||||||||||||||||||||||||||
| 567 | # | ||||||||||||||||||||||||||||||||||||||||||
| 568 | package # hide from PAUSE/MetaCPAN | ||||||||||||||||||||||||||||||||||||||||||
| 569 | PDL::PP::BroadcastLoop; | ||||||||||||||||||||||||||||||||||||||||||
| 570 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 571 | 5 | our @ISA = "PDL::PP::Block"; | |||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | 35 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 574 | 35 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 575 | 35 | bless [],$type; | |||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||
| 577 | 148 | ▶ | sub myoffs { return 0; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
myoffs: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 578 | 148 | ▶ | sub myprelude { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
myprelude: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 579 | 148 | my($this,$parent,$context,$backcode) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 580 | 148 | $parent->broadcastloop_macroname($backcode, 'START'); | |||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||
| 583 | 146 | ▶ | sub mypostlude {my($this,$parent,$context,$backcode) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mypostlude: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 584 | 146 | $parent->broadcastloop_macroname($backcode, 'END'); | |||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||
| 587 | # Simple subclass of BroadcastLoop to implement writeback code | ||||||||||||||||||||||||||||||||||||||||||
| 588 | # | ||||||||||||||||||||||||||||||||||||||||||
| 589 | # | ||||||||||||||||||||||||||||||||||||||||||
| 590 | package # hide from PAUSE/MetaCPAN | ||||||||||||||||||||||||||||||||||||||||||
| 591 | PDL::PP::BackCodeBroadcastLoop; | ||||||||||||||||||||||||||||||||||||||||||
| 592 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 593 | 5 | our @ISA = "PDL::PP::BroadcastLoop"; | |||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||
| 595 | 12 | ▶ | sub myprelude { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
myprelude: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||
| 596 | 12 | my($this,$parent,$context,$backcode) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 597 | # Set backcode flag if not defined. This will make the parent | ||||||||||||||||||||||||||||||||||||||||||
| 598 | # myprelude emit proper writeback code | ||||||||||||||||||||||||||||||||||||||||||
| 599 | 12 | ▶ | $this->SUPER::myprelude($parent, $context, $backcode // 1); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$backcode // 1
MC/DC0%0/1
$backcode // 1
$backcode
Truth table50%1/2
A
A= $backcode
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||
| 602 | 12 | ▶ | sub mypostlude { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mypostlude: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||
| 603 | 12 | my($this,$parent,$context,$backcode) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 604 | # Set backcode flag if not defined. This will make the parent | ||||||||||||||||||||||||||||||||||||||||||
| 605 | # mypostlude emit proper writeback code | ||||||||||||||||||||||||||||||||||||||||||
| 606 | 12 | ▶ | $this->SUPER::mypostlude($parent, $context, $backcode // 1); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$backcode // 1
MC/DC0%0/1
$backcode // 1
$backcode
Truth table50%1/2
A
A= $backcode
| |||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||
| 609 | ########################### | ||||||||||||||||||||||||||||||||||||||||||
| 610 | # | ||||||||||||||||||||||||||||||||||||||||||
| 611 | # Encapsulate a types() switch | ||||||||||||||||||||||||||||||||||||||||||
| 612 | # | ||||||||||||||||||||||||||||||||||||||||||
| 613 | package # hide from PAUSE/MetaCPAN | ||||||||||||||||||||||||||||||||||||||||||
| 614 | PDL::PP::Types; | ||||||||||||||||||||||||||||||||||||||||||
| 615 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 616 | 5 | ▶ | use PDL::Types ':All'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 617 | 5 | our @ISA = "PDL::PP::Block"; | |||||||||||||||||||||||||||||||||||||||||
| 618 | 5 | my %types = map +($_=>1), ppdefs_all; # BSUL.... | |||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | my($type,$ts,$parent) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | my @bad = grep !$types{$_}, my @ts = split '', $ts; | |||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | ▶ | confess "Invalid type access (@bad) in '$ts'!" if @bad; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | bless [+{map +($_=>1), @ts}],$type; } | |||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | sub myoffs { return 1; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
myoffs: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | ▶ | sub get_str { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_str: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | my ($this,$parent,$context) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 629 | confess "types() outside a generic switch" | ||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | unless defined(my $type = $parent->{Gencurtype}[-1]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | ▶ | return '' if !$this->[0]{$type->ppsym}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | join '', $this->get_contained($parent,$context); | |||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||
| 636 | package # hide from PAUSE/MetaCPAN | ||||||||||||||||||||||||||||||||||||||||||
| 637 | PDL::PP::Access; | ||||||||||||||||||||||||||||||||||||||||||
| 638 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||
| 640 | 34 | ▶ | sub new { my($type,$pdl,$inds) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 641 | 34 | bless [$pdl,$inds],$type; | |||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | 104 | ▶ | sub get_str { my($this,$parent,$context) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_str: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||
| 645 | $parent->{ParObjs}{$this->[0]}->do_access($this->[1],$context) | ||||||||||||||||||||||||||||||||||||||||||
| 646 | 104 | ▶ | if defined($parent->{ParObjs}{$this->[0]}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | ########################### | ||||||||||||||||||||||||||||||||||||||||||
| 650 | # Encapsulate a check on whether a value is good or bad | ||||||||||||||||||||||||||||||||||||||||||
| 651 | # handles both checking (good/bad) and setting (bad) | ||||||||||||||||||||||||||||||||||||||||||
| 652 | package # hide from PAUSE/MetaCPAN | ||||||||||||||||||||||||||||||||||||||||||
| 653 | PDL::PP::BadAccess; | ||||||||||||||||||||||||||||||||||||||||||
| 654 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | 8 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 657 | 8 | my ( $type, $opcode, $get, $name, $inds, $parent ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 658 | die "\nIt looks like you have tried a $get \$${opcode}() macro on an" . | ||||||||||||||||||||||||||||||||||||||||||
| 659 | " unknown ndarray <$name($inds)>\n" | ||||||||||||||||||||||||||||||||||||||||||
| 660 | 8 | ▶ | unless defined($parent->{ParObjs}{$name}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 661 | 8 | bless [$opcode, $get, $name, $inds], $type; | |||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||
| 664 | 60 | ▶ | sub _isbad { "PDL_ISBAD2($_[0],$_[1],$_[2],$_[3])" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_isbad: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 665 | our %ops = ( | ||||||||||||||||||||||||||||||||||||||||||
| 666 | ISBAD => \&_isbad, | ||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | ISGOOD => sub {'!'.&_isbad}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 668 | 60 | ▶ | SETBAD => sub{join '=', @_[0,1]}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 669 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 670 | my %getters = ( | ||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | ▶ | '' => sub {my ($obj, $inds, $context)=@_; $obj->do_access($inds,$context)}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 672 | 120 | ▶ | P => sub {my ($obj, $inds)=@_; $obj->do_pointeraccess.$inds}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | VAR => sub {my ($obj, $inds)=@_; $inds}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 674 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||
| 676 | 120 | ▶ | sub get_str { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_str: called CC=7 SCAR=20.6
| |||||||||||||||||||||||||||||||||||||||||||
| 677 | 120 | my ($this,$parent,$context) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 678 | 120 | my ($opcode, $get, $name, $inds) = @$this; | |||||||||||||||||||||||||||||||||||||||||
| 679 | confess "generic type access outside a generic switch in $name" | ||||||||||||||||||||||||||||||||||||||||||
| 680 | 120 | ▶ | unless defined $parent->{Gencurtype}[-1]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 681 | 120 | ▶ | print "PDL::PP::BadAccess sent [$opcode] [$name] [$inds]\n" if $::PP_VERBOSE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 682 | die "ERROR: unknown check <$opcode> sent to PDL::PP::BadAccess\n" | ||||||||||||||||||||||||||||||||||||||||||
| 683 | 120 | ▶ | unless defined( my $op = $ops{$opcode} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 684 | die "ERROR: something screwy in PDL::PP::BadAccess (PP/PDLCode.pm)\n" | ||||||||||||||||||||||||||||||||||||||||||
| 685 | 120 | ▶ | unless defined( my $obj = $parent->{ParObjs}{$name} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 686 | 120 | my $lhs = $getters{$get}->($obj, $inds, $context); | |||||||||||||||||||||||||||||||||||||||||
| 687 | 120 | my $rhs = "${name}_badval"; | |||||||||||||||||||||||||||||||||||||||||
| 688 | 120 | ▶ | print "DBG: [$lhs $op $rhs]\n" if $::PP_VERBOSE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 689 | my $type = exists $parent->{ftypes_vars}{$name} | ||||||||||||||||||||||||||||||||||||||||||
| 690 | ? $parent->{ftypes_type} | ||||||||||||||||||||||||||||||||||||||||||
| 691 | 120 | ▶ | : $obj->adjusted_type($parent->{Gencurtype}[-1]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 692 | 120 | $op->($lhs, $rhs, $type->ppsym, $rhs."_isnan"); | |||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||
| 696 | package # hide from PAUSE/MetaCPAN | ||||||||||||||||||||||||||||||||||||||||||
| 697 | PDL::PP::MacroAccess; | ||||||||||||||||||||||||||||||||||||||||||
| 698 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 699 | 5 | ▶ | use PDL::Types ':All'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 700 | 5 | my $types = join '',ppdefs_all; | |||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||
| 702 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.6
| |||||||||||||||||||||||||||||||||||||||||||
| 703 | 1 | my ($type, $pdl, $inds, $gentypes, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 704 | 1 | my @normalised = map PDL::Type->new($_)->ppsym, @$gentypes; | |||||||||||||||||||||||||||||||||||||||||
| 705 | 1 | ▶ | $pdl =~ /^\s*T([A-Z]+)\s*$/ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 706 | or confess("Macroaccess wrong in $name (allowed types $types): was '$pdl'\n"); | ||||||||||||||||||||||||||||||||||||||||||
| 707 | 1 | my @ilst = split '', $1; | |||||||||||||||||||||||||||||||||||||||||
| 708 | 1 | my @lst = PDL::PP::Rule::Substitute::split_cpp($inds); | |||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | ▶ | confess "Macroaccess: different nos of args $pdl (@{[scalar @lst]}=@lst) vs (@{[scalar @ilst]}=@ilst)\n" if @lst != @ilst; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 710 | 1 | my %type2value; @type2value{@ilst} = @lst; | |||||||||||||||||||||||||||||||||||||||||
| 711 | confess "$name has no Macro for generic type $_ (has $pdl)\n" | ||||||||||||||||||||||||||||||||||||||||||
| 712 | 1 | for grep !exists $type2value{$_}, @normalised; | |||||||||||||||||||||||||||||||||||||||||
| 713 | 1 | my %gts; @gts{@normalised} = (); | |||||||||||||||||||||||||||||||||||||||||
| 714 | warn "Macro for unsupported generic type identifier $_\n" | ||||||||||||||||||||||||||||||||||||||||||
| 715 | 1 | for grep !exists $gts{$_}, @ilst; | |||||||||||||||||||||||||||||||||||||||||
| 716 | 1 | bless [\%type2value, $name], $type; | |||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||
| 719 | 4 | ▶ | sub get_str { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_str: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 720 | 4 | my ($this, $parent, $context) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 721 | 4 | my ($type2value, $name) = @{$this}; | |||||||||||||||||||||||||||||||||||||||||
| 722 | confess "generic type access outside a generic switch in $name" | ||||||||||||||||||||||||||||||||||||||||||
| 723 | 4 | ▶ | unless defined $parent->{Gencurtype}[-1]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 724 | 4 | $type2value->{$parent->{Gencurtype}[-1]->ppsym}; | |||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||
| 727 | package # hide from PAUSE/MetaCPAN | ||||||||||||||||||||||||||||||||||||||||||
| 728 | PDL::PP::GentypeAccess; | ||||||||||||||||||||||||||||||||||||||||||
| 729 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||
| 731 | 2 | ▶ | sub new { my($type,$pdl,$inds) = @_; bless [$inds],$type; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||
| 733 | 21 | ▶ | sub get_str {my($this,$parent,$context) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_str: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||||||||||||||||
| 734 | confess "generic type access outside a generic switch" | ||||||||||||||||||||||||||||||||||||||||||
| 735 | 21 | ▶ | unless defined(my $type = $parent->{Gencurtype}[-1]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 736 | 21 | ▶ | return $type->ctype if !$this->[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 737 | 21 | ▶ | my $pobj = $parent->{ParObjs}{$this->[0]} // confess "not a defined parname"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$parent->{"ParObjs"}{$this->[0]} // confess("not a defined parname")
MC/DC0%0/1
$parent->{"ParObjs"}{$this->[0]} // confess("not a defined parname")
$parent->{"ParObjs"}{$this->[0]}
Truth table50%1/2
A
A= $parent->{"ParObjs"}{$this->[0]}
| |||||||||||||||||||||||||||||||||||||||||||
| 738 | 21 | $pobj->adjusted_type($type)->ctype; | |||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||
| 741 | package # hide from PAUSE/MetaCPAN | ||||||||||||||||||||||||||||||||||||||||||
| 742 | PDL::PP::PpsymAccess; | ||||||||||||||||||||||||||||||||||||||||||
| 743 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||
| 745 | 1 | ▶ | sub new { my($type,$pdl,$inds) = @_; bless [$inds],$type; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||
| 747 | 15 | ▶ | sub get_str {my($this,$parent,$context) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_str: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||||||||||||||||
| 748 | confess "generic type access outside a generic switch" | ||||||||||||||||||||||||||||||||||||||||||
| 749 | 15 | ▶ | unless defined(my $type = $parent->{Gencurtype}[-1]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 750 | 15 | ▶ | return $type->ppsym if !$this->[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 751 | 15 | ▶ | my $pobj = $parent->{ParObjs}{$this->[0]} // confess "not a defined parname"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$parent->{"ParObjs"}{$this->[0]} // confess("not a defined parname")
MC/DC0%0/1
$parent->{"ParObjs"}{$this->[0]} // confess("not a defined parname")
$parent->{"ParObjs"}{$this->[0]}
Truth table50%1/2
A
A= $parent->{"ParObjs"}{$this->[0]}
| |||||||||||||||||||||||||||||||||||||||||||
| 752 | 15 | $pobj->adjusted_type($type)->ppsym; | |||||||||||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||
| 755 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||