| 1 | package ExtUtils::XSpp::Node::Type; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 21 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 21 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 21 | ▶ | use base 'ExtUtils::XSpp::Node'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # TODO: Document... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # normalized names for some integral C types | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 21 | my %normalize = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | ( 'unsigned' => 'unsigned int', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 'long int' => 'long', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 'unsigned long int' => 'unsigned long', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 'short int' => 'short', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 'unsigned short int' => 'unsigned short', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3468 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3468 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3468 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 3468 | ▶ | $this->{BASE} = $normalize{$args{base}} || $args{base}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$normalize{$args{'base'}} || $args{'base'}
MC/DC50%1/2
$normalize{$args{'base'}} || $args{'base'}
$normalize{$args{'base'}}
$args{'base'}
Truth table66%2/3
A || B
A= $normalize{$args{'base'}}B= $args{'base'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 3468 | ▶ | $this->{POINTER} = $args{pointer} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3468 | ▶ | $this->{REFERENCE} = $args{reference} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 3468 | ▶ | $this->{CONST} = $args{const} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3468 | ▶ | $this->{TEMPLATE_ARGS} = $args{template_args} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{'template_args'} || []
MC/DC100%1/1
$args{'template_args'} || []
$args{'template_args'}
Truth table100%2/2
A
A= $args{'template_args'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | ▶ | sub clone { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | my $clone = bless {%$this} => ref($this); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | $clone->{TEMPLATE_ARGS} = [map $_->clone, @{$clone->template_args}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | return $clone; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 5135 | ▶ | sub is_const { $_[0]->{CONST} } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_const: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 4737 | ▶ | sub is_reference { $_[0]->{REFERENCE} } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_reference: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 4741 | ▶ | sub is_pointer { $_[0]->{POINTER} } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_pointer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 4301 | ▶ | sub base_type { $_[0]->{BASE} } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
base_type: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 7612 | ▶ | sub template_args { $_[0]->{TEMPLATE_ARGS} } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
template_args: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 2414 | ▶ | sub equals { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
equals: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 2414 | my( $f, $s ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 2414 | ▶ | return 0 if @{$f->template_args} != @{$s->template_args}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 2396 | ▶ | for( my $i = 0; $i < @{$f->template_args}; ++$i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 7 | ▶ | return 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | unless $f->template_args->[$i]->equals( $s->template_args->[$i] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 2396 | ▶ | return $f->is_const == $s->is_const | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%9/9
$f->is_const == $s->is_const && $f->is_reference == $s->is_reference && $f->is_pointer == $s->is_pointer && $f->base_type eq $s->base_type
$f->is_const == $s->is_const and $f->is_reference == $s->is_reference and $f->is_pointer == $s->is_pointer
$f->is_const == $s->is_const and $f->is_reference == $s->is_reference
MC/DC100%4/4
$f->is_const == $s->is_const && $f->is_reference == $s->is_reference && $f->is_pointer == $s->is_pointer && $f->base_type eq $s->base_type
$f->is_const == $s->is_const
$f->is_reference == $s->is_reference
$f->is_pointer == $s->is_pointer
$f->base_type eq $s->base_type
Truth table100%5/5
A and B and C && D
A= $f->is_const == $s->is_constB= $f->is_reference == $s->is_referenceC= $f->is_pointer == $s->is_pointerD= $f->base_type eq $s->base_type
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | && $f->is_reference == $s->is_reference | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | && $f->is_pointer == $s->is_pointer | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | && $f->base_type eq $s->base_type; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 106 | ▶ | sub is_void { return $_[0]->base_type eq 'void' && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_void: called CC=3 SCAR=11.7
Pod
undocumented
Condition66%4/6
$_[0]->base_type eq 'void' && !$_[0]->is_pointer && !$_[0]->is_reference
$_[0]->base_type eq "void" and not $_[0]->is_pointer
MC/DC33%1/3
$_[0]->base_type eq 'void' && !$_[0]->is_pointer && !$_[0]->is_reference
$_[0]->base_type eq "void"
not $_[0]->is_pointer
!$_[0]->is_reference
Truth table50%2/4
A and not(B) && not(C)
A= $_[0]->base_type eq "void"B= not $_[0]->is_pointerC= !$_[0]->is_reference
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | !$_[0]->is_pointer && !$_[0]->is_reference } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 359 | ▶ | sub print_tmpl_args { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_tmpl_args: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 359 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 359 | my $state = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 359 | my $tmpl_args = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 359 | ▶ | if( @{$this->template_args} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | $tmpl_args = '< ' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | . join( ', ', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 5 | map $_->print( $state ), @{$this->template_args} ) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | . ' >'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 359 | return $tmpl_args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 343 | ▶ | sub print { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 343 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 343 | my $state = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 343 | ▶ | return join( '', | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | ( $this->is_const ? 'const ' : '' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | $this->base_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | $this->print_tmpl_args, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ( $this->is_pointer ? ( '*' x $this->is_pointer ) : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | $this->is_reference ? '&' : '' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 21 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||