| 1 | package Scalar::ValueTags::LineageTracking 0.004; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use v5.44; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Scalar::ValueTags 0.004; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use feature 'class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | no warnings 'experimental::class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Carp 'croak'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Ref::Util qw( is_plain_ref is_ref ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Scalar::ValueTags qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | SVTAGS_UNIQUE_REF_ARRAY | ||||||||||||||||||||||||||||
| 16 | SVTAGS_UNIQUE_HASH | ||||||||||||||||||||||||||||
| 17 | add_value_tag | ||||||||||||||||||||||||||||
| 18 | clear_value_tags | ||||||||||||||||||||||||||||
| 19 | get_value_tags | ||||||||||||||||||||||||||||
| 20 | register_value_tags_type | ||||||||||||||||||||||||||||
| 21 | 1 | ); | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1 | class Scalar::ValueTags::LineageTracking { | |||||||||||||||||||||||||||
| 24 | 1 | field $tag_type :param :reader //= 'string'; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | field $vt_type :reader(_vt_type) :writer(_set_vt_type); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 6 | ▶ | ADJUST { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 29 | 6 | ▶ | croak "Invalid tag_type: must be 'ref' or 'string'" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | unless $self->&tag_type =~ m/\A(ref|string)\Z/n; | ||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 5 | ▶ | ADJUST { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 34 | 5 | ▶ | $self->_set_vt_type( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | register_value_tags_type( | ||||||||||||||||||||||||||||
| 36 | $self->&tag_type eq 'string' | ||||||||||||||||||||||||||||
| 37 | ? SVTAGS_UNIQUE_HASH | ||||||||||||||||||||||||||||
| 38 | : SVTAGS_UNIQUE_REF_ARRAY | ||||||||||||||||||||||||||||
| 39 | ) | ||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 2 | ▶ | method add_data_sources( $var_ref, $data_sources ) { | ||||||||||||||||||||||||||
|
Subroutine
add_data_sources: called CC=6 SCAR=18.8
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 2 | my $tag_type = $self->&tag_type; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 2 | for my $data_source ( $data_sources->@* ) { | |||||||||||||||||||||||||||
| 47 | 4 | ▶ | croak 'invalid data_source: must be string' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$tag_type eq "string" and is_ref($data_source)
MC/DC0%0/2
$tag_type eq "string" and is_ref($data_source)
$tag_type eq "string"
is_ref($data_source)
Truth table66%2/3
A and B
A= $tag_type eq "string"B= is_ref($data_source)
| |||||||||||||||||||||||||||||
| 48 | if $tag_type eq 'string' && is_ref($data_source); | ||||||||||||||||||||||||||||
| 49 | 4 | ▶ | croak 'invalid data_source: must be unblessed ref' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$tag_type eq "ref" and not is_plain_ref($data_source)
MC/DC0%0/2
$tag_type eq "ref" and not is_plain_ref($data_source)
$tag_type eq "ref"
not is_plain_ref($data_source)
Truth table66%2/3
A and not(B)
A= $tag_type eq "ref"B= not is_plain_ref($data_source)
| |||||||||||||||||||||||||||||
| 50 | if $tag_type eq 'ref' && !is_plain_ref($data_source); | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 4 | add_value_tag( $self->&_vt_type, $var_ref, $data_source ); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 2 | return; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 30 | ▶ | method get_data_sources($var_ref) { | ||||||||||||||||||||||||||
|
Subroutine
get_data_sources: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 59 | 30 | my $tags = get_value_tags( $self->&_vt_type, $var_ref ); | |||||||||||||||||||||||||||
| 60 | 30 | ▶ | $tags = [ keys $tags->%* ] | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | if $self->&tag_type eq 'string'; | ||||||||||||||||||||||||||||
| 62 | 30 | return $tags; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 16 | ▶ | method set_data_sources( $var_ref, $data_sources ) { | ||||||||||||||||||||||||||
|
Subroutine
set_data_sources: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 16 | my $tag_type = $self->&tag_type; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 16 | my $prev_data_sources = $self->get_data_sources($var_ref); | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 16 | clear_value_tags( $vt_type, $var_ref ); | |||||||||||||||||||||||||||
| 71 | 16 | for my $data_source ( $data_sources->@* ) { | |||||||||||||||||||||||||||
| 72 | 20 | ▶ | croak 'invalid data_source: must be string' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$tag_type eq "string" and is_ref($data_source)
MC/DC100%2/2
$tag_type eq "string" and is_ref($data_source)
$tag_type eq "string"
is_ref($data_source)
Truth table100%3/3
A and B
A= $tag_type eq "string"B= is_ref($data_source)
| |||||||||||||||||||||||||||||
| 73 | if $tag_type eq 'string' && is_ref($data_source); | ||||||||||||||||||||||||||||
| 74 | 19 | ▶ | croak 'invalid data_source: must be unblessed ref' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$tag_type eq "ref" and not is_plain_ref($data_source)
MC/DC100%2/2
$tag_type eq "ref" and not is_plain_ref($data_source)
$tag_type eq "ref"
not is_plain_ref($data_source)
Truth table100%3/3
A and not(B)
A= $tag_type eq "ref"B= not is_plain_ref($data_source)
| |||||||||||||||||||||||||||||
| 75 | if $tag_type eq 'ref' && !is_plain_ref($data_source); | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 18 | add_value_tag( $vt_type, $var_ref, $data_source ); | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 14 | return $prev_data_sources; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 2 | ▶ | method clear_data_sources($var_ref) { | ||||||||||||||||||||||||||
|
Subroutine
clear_data_sources: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 84 | 2 | my $prev_data_sources = $self->get_data_sources($var_ref); | |||||||||||||||||||||||||||
| 85 | 2 | clear_value_tags( $self->&_vt_type, $var_ref ); | |||||||||||||||||||||||||||
| 86 | 2 | return $prev_data_sources; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 1 | 1; | |||||||||||||||||||||||||||
| 91 | __END__ | ||||||||||||||||||||||||||||