| 1 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 3 | package YAML::PP::Schema::Perl; | ||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||
| 5 | 7 | our $VERSION = 'v0.43.0'; # VERSION | |||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use Scalar::Util qw/ blessed reftype /; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||
| 9 | 7 | my $qr_prefix; | |||||||||||||||||||||||||||||||||||
| 10 | # workaround to avoid growing regexes when repeatedly loading and dumping | ||||||||||||||||||||||||||||||||||||
| 11 | # e.g. (?^:(?^:regex)) | ||||||||||||||||||||||||||||||||||||
| 12 | { | ||||||||||||||||||||||||||||||||||||
| 13 | 7 | $qr_prefix = qr{\(\?-xism\:}; | |||||||||||||||||||||||||||||||||||
| 14 | 7 | ▶ | if ($] >= 5.014) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 15 | 7 | $qr_prefix = qr{\(\?\^(?:[uadl])?\:}; | |||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||
| 19 | 6 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 20 | 6 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||
| 21 | 6 | ▶ | my $tags = $args{tags} || []; | ||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{'tags'} || []
MC/DC0%0/1
$args{'tags'} || []
$args{'tags'}
Truth table50%1/2
A
A= $args{'tags'}
| |||||||||||||||||||||||||||||||||||||
| 22 | 6 | ▶ | my $loadcode = $args{loadcode} || 0; | ||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{'loadcode'} || 0
MC/DC100%1/1
$args{'loadcode'} || 0
$args{'loadcode'}
Truth table100%2/2
A
A= $args{'loadcode'}
| |||||||||||||||||||||||||||||||||||||
| 23 | 6 | my $dumpcode = $args{dumpcode}; | |||||||||||||||||||||||||||||||||||
| 24 | 6 | ▶ | $dumpcode = 1 unless defined $dumpcode; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 25 | 6 | my $classes = $args{classes}; | |||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||
| 27 | 6 | my $self = bless { | |||||||||||||||||||||||||||||||||||
| 28 | tags => $tags, | ||||||||||||||||||||||||||||||||||||
| 29 | loadcode => $loadcode, | ||||||||||||||||||||||||||||||||||||
| 30 | dumpcode => $dumpcode, | ||||||||||||||||||||||||||||||||||||
| 31 | classes => $classes, | ||||||||||||||||||||||||||||||||||||
| 32 | }, $class; | ||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||
| 35 | 24 | ▶ | sub register { | ||||||||||||||||||||||||||||||||||
|
Subroutine
register: called CC=29 SCAR=33.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 36 | 24 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||
| 37 | 24 | my $schema = $args{schema}; | |||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||
| 39 | 24 | my $tags; | |||||||||||||||||||||||||||||||||||
| 40 | 24 | my $loadcode = 0; | |||||||||||||||||||||||||||||||||||
| 41 | 24 | my $dumpcode = 1; | |||||||||||||||||||||||||||||||||||
| 42 | 24 | my $classes; | |||||||||||||||||||||||||||||||||||
| 43 | 24 | ▶ | if (blessed($self)) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 44 | 6 | $tags = $self->{tags}; | |||||||||||||||||||||||||||||||||||
| 45 | 6 | ▶ | @$tags = ('!perl') unless @$tags; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 46 | 6 | $loadcode = $self->{loadcode}; | |||||||||||||||||||||||||||||||||||
| 47 | 6 | $dumpcode = $self->{dumpcode}; | |||||||||||||||||||||||||||||||||||
| 48 | 6 | $classes = $self->{classes}; | |||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||
| 50 | else { | ||||||||||||||||||||||||||||||||||||
| 51 | 18 | my $options = $args{options}; | |||||||||||||||||||||||||||||||||||
| 52 | 18 | my $tagtype = '!perl'; | |||||||||||||||||||||||||||||||||||
| 53 | 18 | for my $option (@$options) { | |||||||||||||||||||||||||||||||||||
| 54 | 12 | ▶ | if ($option =~ m/^tags?=(.+)$/) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||
| 55 | 7 | $tagtype = $1; | |||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||
| 57 | elsif ($option eq '+loadcode') { | ||||||||||||||||||||||||||||||||||||
| 58 | 4 | $loadcode = 1; | |||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||
| 60 | elsif ($option eq '-dumpcode') { | ||||||||||||||||||||||||||||||||||||
| 61 | 1 | $dumpcode = 0; | |||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||
| 64 | 18 | $tags = [split m/\+/, $tagtype]; | |||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||
| 68 | 24 | my $perl_tag; | |||||||||||||||||||||||||||||||||||
| 69 | my %tagtypes; | ||||||||||||||||||||||||||||||||||||
| 70 | 24 | my @perl_tags; | |||||||||||||||||||||||||||||||||||
| 71 | 24 | for my $type (@$tags) { | |||||||||||||||||||||||||||||||||||
| 72 | 28 | ▶ | if ($type eq '!perl') { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 73 | 22 | ▶ | $perl_tag ||= $type; | ||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$perl_tag ||= $type
MC/DC0%0/2
$perl_tag ||= $type
$perl_tag
$type
Truth table66%2/3
A ||= B
A= $perl_tagB= $type
| |||||||||||||||||||||||||||||||||||||
| 74 | 22 | push @perl_tags, '!perl'; | |||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||
| 76 | elsif ($type eq '!!perl') { | ||||||||||||||||||||||||||||||||||||
| 77 | 6 | ▶ | $perl_tag ||= 'tag:yaml.org,2002:perl'; | ||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$perl_tag ||= "tag:yaml.org,2002:perl"
MC/DC100%1/1
$perl_tag ||= "tag:yaml.org,2002:perl"
$perl_tag
Truth table100%2/2
A
A= $perl_tag
| |||||||||||||||||||||||||||||||||||||
| 78 | 6 | push @perl_tags, 'tag:yaml.org,2002:perl'; | |||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||
| 80 | else { | ||||||||||||||||||||||||||||||||||||
| 81 | 0 | die "Invalid tagtype '$type'"; | |||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||
| 83 | 28 | $tagtypes{ $type } = 1; | |||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||
| 86 | 24 | my $perl_regex = '!perl'; | |||||||||||||||||||||||||||||||||||
| 87 | 24 | ▶ | if ($tagtypes{'!perl'} and $tagtypes{'!!perl'}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$tagtypes{"!perl"} and $tagtypes{"!!perl"}
MC/DC100%2/2
$tagtypes{"!perl"} and $tagtypes{"!!perl"}
$tagtypes{"!perl"}
$tagtypes{"!!perl"}
Truth table100%3/3
A and B
A= $tagtypes{"!perl"}B= $tagtypes{"!!perl"}
| |||||||||||||||||||||||||||||||||||||
| 88 | 4 | $perl_regex = '(?:tag:yaml\\.org,2002:|!)perl'; | |||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||
| 90 | elsif ($tagtypes{'!perl'}) { | ||||||||||||||||||||||||||||||||||||
| 91 | 18 | $perl_regex = '!perl'; | |||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||
| 93 | elsif ($tagtypes{'!!perl'}) { | ||||||||||||||||||||||||||||||||||||
| 94 | 2 | $perl_regex = 'tag:yaml\\.org,2002:perl'; | |||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||
| 97 | 24 | my $class_regex = qr{.+}; | |||||||||||||||||||||||||||||||||||
| 98 | 24 | my $no_objects = 0; | |||||||||||||||||||||||||||||||||||
| 99 | 24 | ▶ | if ($classes) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 100 | 5 | ▶ | if (@$classes) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 101 | 1 | $class_regex = '(' . join( '|', map "\Q$_\E", @$classes ) . ')'; | |||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||
| 103 | else { | ||||||||||||||||||||||||||||||||||||
| 104 | 4 | $no_objects = 1; | |||||||||||||||||||||||||||||||||||
| 105 | 4 | $class_regex = ''; | |||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||
| 109 | # Code | ||||||||||||||||||||||||||||||||||||
| 110 | 24 | ▶ | if ($loadcode) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 111 | 6 | ▶ | my $load_code = sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 112 | 6 | my ($constructor, $event) = @_; | |||||||||||||||||||||||||||||||||||
| 113 | 6 | return $self->evaluate_code($event->{value}); | |||||||||||||||||||||||||||||||||||
| 114 | 5 | }; | |||||||||||||||||||||||||||||||||||
| 115 | 6 | ▶ | my $load_code_blessed = sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 116 | 6 | my ($constructor, $event) = @_; | |||||||||||||||||||||||||||||||||||
| 117 | 6 | my $class = $event->{tag}; | |||||||||||||||||||||||||||||||||||
| 118 | 6 | $class =~ s{^$perl_regex/code:}{}; | |||||||||||||||||||||||||||||||||||
| 119 | 6 | my $sub = $self->evaluate_code($event->{value}); | |||||||||||||||||||||||||||||||||||
| 120 | 4 | return $self->object($sub, $class); | |||||||||||||||||||||||||||||||||||
| 121 | 5 | }; | |||||||||||||||||||||||||||||||||||
| 122 | $schema->add_resolver( | ||||||||||||||||||||||||||||||||||||
| 123 | tag => "$_/code", | ||||||||||||||||||||||||||||||||||||
| 124 | match => [ all => $load_code], | ||||||||||||||||||||||||||||||||||||
| 125 | implicit => 0, | ||||||||||||||||||||||||||||||||||||
| 126 | 5 | ) for @perl_tags; | |||||||||||||||||||||||||||||||||||
| 127 | 5 | $schema->add_resolver( | |||||||||||||||||||||||||||||||||||
| 128 | tag => qr{^$perl_regex/code:$class_regex$}, | ||||||||||||||||||||||||||||||||||||
| 129 | match => [ all => $load_code_blessed ], | ||||||||||||||||||||||||||||||||||||
| 130 | implicit => 0, | ||||||||||||||||||||||||||||||||||||
| 131 | ); | ||||||||||||||||||||||||||||||||||||
| 132 | 5 | ▶ | $schema->add_resolver( | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 133 | tag => qr{^$perl_regex/code:.+}, | ||||||||||||||||||||||||||||||||||||
| 134 | match => [ all => $load_code ], | ||||||||||||||||||||||||||||||||||||
| 135 | implicit => 0, | ||||||||||||||||||||||||||||||||||||
| 136 | ) if $no_objects; | ||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||
| 138 | else { | ||||||||||||||||||||||||||||||||||||
| 139 | 19 | ▶ | my $loadcode_dummy = sub { return sub {} }; | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 140 | 2 | ▶ | my $loadcode_blessed_dummy = sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 141 | 2 | my ($constructor, $event) = @_; | |||||||||||||||||||||||||||||||||||
| 142 | 2 | my $class = $event->{tag}; | |||||||||||||||||||||||||||||||||||
| 143 | 2 | $class =~ s{^$perl_regex/code:}{}; | |||||||||||||||||||||||||||||||||||
| 144 | 2 | ▶ | return $self->object(sub {}, $class); | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 145 | 19 | }; | |||||||||||||||||||||||||||||||||||
| 146 | $schema->add_resolver( | ||||||||||||||||||||||||||||||||||||
| 147 | tag => "$_/code", | ||||||||||||||||||||||||||||||||||||
| 148 | match => [ all => $loadcode_dummy ], | ||||||||||||||||||||||||||||||||||||
| 149 | implicit => 0, | ||||||||||||||||||||||||||||||||||||
| 150 | 19 | ) for @perl_tags; | |||||||||||||||||||||||||||||||||||
| 151 | 19 | $schema->add_resolver( | |||||||||||||||||||||||||||||||||||
| 152 | tag => qr{^$perl_regex/code:$class_regex$}, | ||||||||||||||||||||||||||||||||||||
| 153 | match => [ all => $loadcode_blessed_dummy ], | ||||||||||||||||||||||||||||||||||||
| 154 | implicit => 0, | ||||||||||||||||||||||||||||||||||||
| 155 | ); | ||||||||||||||||||||||||||||||||||||
| 156 | 19 | $schema->add_resolver( | |||||||||||||||||||||||||||||||||||
| 157 | tag => qr{^$perl_regex/code:.+}, | ||||||||||||||||||||||||||||||||||||
| 158 | match => [ all => $loadcode_dummy ], | ||||||||||||||||||||||||||||||||||||
| 159 | implicit => 0, | ||||||||||||||||||||||||||||||||||||
| 160 | ); | ||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||
| 163 | # Glob | ||||||||||||||||||||||||||||||||||||
| 164 | 8 | ▶ | my $load_glob = sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 165 | 8 | my $value = undef; | |||||||||||||||||||||||||||||||||||
| 166 | 8 | return \$value; | |||||||||||||||||||||||||||||||||||
| 167 | 24 | }; | |||||||||||||||||||||||||||||||||||
| 168 | 2 | ▶ | my $load_glob_blessed = sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 169 | 2 | my ($constructor, $event) = @_; | |||||||||||||||||||||||||||||||||||
| 170 | 2 | my $class = $event->{tag}; | |||||||||||||||||||||||||||||||||||
| 171 | 2 | $class =~ s{^$perl_regex/glob:}{}; | |||||||||||||||||||||||||||||||||||
| 172 | 2 | my $value = undef; | |||||||||||||||||||||||||||||||||||
| 173 | 2 | return $self->object(\$value, $class); | |||||||||||||||||||||||||||||||||||
| 174 | 24 | }; | |||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||
| 176 | $schema->add_mapping_resolver( | ||||||||||||||||||||||||||||||||||||
| 177 | tag => "$_/glob", | ||||||||||||||||||||||||||||||||||||
| 178 | on_create => $load_glob, | ||||||||||||||||||||||||||||||||||||
| 179 | 6 | ▶ | on_data => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 180 | 6 | my ($constructor, $ref, $list) = @_; | |||||||||||||||||||||||||||||||||||
| 181 | 6 | $$ref = $self->construct_glob($list); | |||||||||||||||||||||||||||||||||||
| 182 | }, | ||||||||||||||||||||||||||||||||||||
| 183 | 24 | ) for @perl_tags; | |||||||||||||||||||||||||||||||||||
| 184 | 24 | ▶ | if ($no_objects) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 185 | $schema->add_mapping_resolver( | ||||||||||||||||||||||||||||||||||||
| 186 | tag => qr{^$perl_regex/glob:.+$}, | ||||||||||||||||||||||||||||||||||||
| 187 | on_create => $load_glob, | ||||||||||||||||||||||||||||||||||||
| 188 | 2 | ▶ | on_data => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 189 | 2 | my ($constructor, $ref, $list) = @_; | |||||||||||||||||||||||||||||||||||
| 190 | 2 | $$ref = $self->construct_glob($list); | |||||||||||||||||||||||||||||||||||
| 191 | }, | ||||||||||||||||||||||||||||||||||||
| 192 | 4 | ); | |||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||
| 194 | else { | ||||||||||||||||||||||||||||||||||||
| 195 | $schema->add_mapping_resolver( | ||||||||||||||||||||||||||||||||||||
| 196 | tag => qr{^$perl_regex/glob:$class_regex$}, | ||||||||||||||||||||||||||||||||||||
| 197 | on_create => $load_glob_blessed, | ||||||||||||||||||||||||||||||||||||
| 198 | 2 | ▶ | on_data => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 199 | 2 | my ($constructor, $ref, $list) = @_; | |||||||||||||||||||||||||||||||||||
| 200 | 2 | $$$ref = $self->construct_glob($list); | |||||||||||||||||||||||||||||||||||
| 201 | }, | ||||||||||||||||||||||||||||||||||||
| 202 | 20 | ); | |||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||
| 205 | # Regex | ||||||||||||||||||||||||||||||||||||
| 206 | 5 | ▶ | my $load_regex = sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 207 | 5 | my ($constructor, $event) = @_; | |||||||||||||||||||||||||||||||||||
| 208 | 5 | return $self->construct_regex($event->{value}); | |||||||||||||||||||||||||||||||||||
| 209 | 24 | }; | |||||||||||||||||||||||||||||||||||
| 210 | 2 | ▶ | my $load_regex_dummy = sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 211 | 2 | my ($constructor, $event) = @_; | |||||||||||||||||||||||||||||||||||
| 212 | 2 | return $event->{value}; | |||||||||||||||||||||||||||||||||||
| 213 | 24 | }; | |||||||||||||||||||||||||||||||||||
| 214 | 6 | ▶ | my $load_regex_blessed = sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 215 | 6 | my ($constructor, $event) = @_; | |||||||||||||||||||||||||||||||||||
| 216 | 6 | my $class = $event->{tag}; | |||||||||||||||||||||||||||||||||||
| 217 | 6 | $class =~ s{^$perl_regex/regexp:}{}; | |||||||||||||||||||||||||||||||||||
| 218 | 6 | my $qr = $self->construct_regex($event->{value}); | |||||||||||||||||||||||||||||||||||
| 219 | 6 | return $self->object($qr, $class); | |||||||||||||||||||||||||||||||||||
| 220 | 24 | }; | |||||||||||||||||||||||||||||||||||
| 221 | $schema->add_resolver( | ||||||||||||||||||||||||||||||||||||
| 222 | tag => "$_/regexp", | ||||||||||||||||||||||||||||||||||||
| 223 | match => [ all => $load_regex ], | ||||||||||||||||||||||||||||||||||||
| 224 | implicit => 0, | ||||||||||||||||||||||||||||||||||||
| 225 | 24 | ) for @perl_tags; | |||||||||||||||||||||||||||||||||||
| 226 | 24 | $schema->add_resolver( | |||||||||||||||||||||||||||||||||||
| 227 | tag => qr{^$perl_regex/regexp:$class_regex$}, | ||||||||||||||||||||||||||||||||||||
| 228 | match => [ all => $load_regex_blessed ], | ||||||||||||||||||||||||||||||||||||
| 229 | implicit => 0, | ||||||||||||||||||||||||||||||||||||
| 230 | ); | ||||||||||||||||||||||||||||||||||||
| 231 | 24 | $schema->add_resolver( | |||||||||||||||||||||||||||||||||||
| 232 | tag => qr{^$perl_regex/regexp:.*$}, | ||||||||||||||||||||||||||||||||||||
| 233 | match => [ all => $load_regex_dummy ], | ||||||||||||||||||||||||||||||||||||
| 234 | implicit => 0, | ||||||||||||||||||||||||||||||||||||
| 235 | ); | ||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||
| 237 | 24 | ▶ | my $load_sequence = sub { return [] }; | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 238 | 13 | ▶ | my $load_sequence_blessed = sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 239 | 13 | my ($constructor, $event) = @_; | |||||||||||||||||||||||||||||||||||
| 240 | 13 | my $class = $event->{tag}; | |||||||||||||||||||||||||||||||||||
| 241 | 13 | $class =~ s{^$perl_regex/array:}{}; | |||||||||||||||||||||||||||||||||||
| 242 | 13 | return $self->object([], $class); | |||||||||||||||||||||||||||||||||||
| 243 | 24 | }; | |||||||||||||||||||||||||||||||||||
| 244 | $schema->add_sequence_resolver( | ||||||||||||||||||||||||||||||||||||
| 245 | tag => "$_/array", | ||||||||||||||||||||||||||||||||||||
| 246 | on_create => $load_sequence, | ||||||||||||||||||||||||||||||||||||
| 247 | 24 | ) for @perl_tags; | |||||||||||||||||||||||||||||||||||
| 248 | 24 | $schema->add_sequence_resolver( | |||||||||||||||||||||||||||||||||||
| 249 | tag => qr{^$perl_regex/array:$class_regex$}, | ||||||||||||||||||||||||||||||||||||
| 250 | on_create => $load_sequence_blessed, | ||||||||||||||||||||||||||||||||||||
| 251 | ); | ||||||||||||||||||||||||||||||||||||
| 252 | 24 | $schema->add_sequence_resolver( | |||||||||||||||||||||||||||||||||||
| 253 | tag => qr{^$perl_regex/array:.+$}, | ||||||||||||||||||||||||||||||||||||
| 254 | on_create => $load_sequence, | ||||||||||||||||||||||||||||||||||||
| 255 | );# if $no_objects; | ||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||
| 257 | 24 | ▶ | my $load_mapping = sub { return {} }; | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 258 | 7 | ▶ | my $load_mapping_blessed = sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 259 | 7 | my ($constructor, $event) = @_; | |||||||||||||||||||||||||||||||||||
| 260 | 7 | my $class = $event->{tag}; | |||||||||||||||||||||||||||||||||||
| 261 | 7 | $class =~ s{^$perl_regex/hash:}{}; | |||||||||||||||||||||||||||||||||||
| 262 | 7 | return $self->object({}, $class); | |||||||||||||||||||||||||||||||||||
| 263 | 24 | }; | |||||||||||||||||||||||||||||||||||
| 264 | $schema->add_mapping_resolver( | ||||||||||||||||||||||||||||||||||||
| 265 | tag => "$_/hash", | ||||||||||||||||||||||||||||||||||||
| 266 | on_create => $load_mapping, | ||||||||||||||||||||||||||||||||||||
| 267 | 24 | ) for @perl_tags; | |||||||||||||||||||||||||||||||||||
| 268 | 24 | $schema->add_mapping_resolver( | |||||||||||||||||||||||||||||||||||
| 269 | tag => qr{^$perl_regex/hash:$class_regex$}, | ||||||||||||||||||||||||||||||||||||
| 270 | on_create => $load_mapping_blessed, | ||||||||||||||||||||||||||||||||||||
| 271 | ); | ||||||||||||||||||||||||||||||||||||
| 272 | 24 | $schema->add_mapping_resolver( | |||||||||||||||||||||||||||||||||||
| 273 | tag => qr{^$perl_regex/hash:.+$}, | ||||||||||||||||||||||||||||||||||||
| 274 | on_create => $load_mapping, | ||||||||||||||||||||||||||||||||||||
| 275 | ); # if $no_objects; | ||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||
| 277 | # Ref | ||||||||||||||||||||||||||||||||||||
| 278 | 8 | ▶ | my $load_ref = sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 279 | 8 | my $value = undef; | |||||||||||||||||||||||||||||||||||
| 280 | 8 | return \$value; | |||||||||||||||||||||||||||||||||||
| 281 | 24 | }; | |||||||||||||||||||||||||||||||||||
| 282 | 7 | ▶ | my $load_ref_blessed = sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 283 | 7 | my ($constructor, $event) = @_; | |||||||||||||||||||||||||||||||||||
| 284 | 7 | my $class = $event->{tag}; | |||||||||||||||||||||||||||||||||||
| 285 | 7 | $class =~ s{^$perl_regex/ref:}{}; | |||||||||||||||||||||||||||||||||||
| 286 | 7 | my $value = undef; | |||||||||||||||||||||||||||||||||||
| 287 | 7 | return $self->object(\$value, $class); | |||||||||||||||||||||||||||||||||||
| 288 | 24 | }; | |||||||||||||||||||||||||||||||||||
| 289 | $schema->add_mapping_resolver( | ||||||||||||||||||||||||||||||||||||
| 290 | tag => "$_/ref", | ||||||||||||||||||||||||||||||||||||
| 291 | on_create => $load_ref, | ||||||||||||||||||||||||||||||||||||
| 292 | 6 | ▶ | on_data => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 293 | 6 | my ($constructor, $ref, $list) = @_; | |||||||||||||||||||||||||||||||||||
| 294 | 6 | $$$ref = $self->construct_ref($list); | |||||||||||||||||||||||||||||||||||
| 295 | }, | ||||||||||||||||||||||||||||||||||||
| 296 | 24 | ) for @perl_tags; | |||||||||||||||||||||||||||||||||||
| 297 | $schema->add_mapping_resolver( | ||||||||||||||||||||||||||||||||||||
| 298 | tag => qr{^$perl_regex/ref:$class_regex$}, | ||||||||||||||||||||||||||||||||||||
| 299 | on_create => $load_ref_blessed, | ||||||||||||||||||||||||||||||||||||
| 300 | 7 | ▶ | on_data => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 301 | 7 | my ($constructor, $ref, $list) = @_; | |||||||||||||||||||||||||||||||||||
| 302 | 7 | $$$ref = $self->construct_ref($list); | |||||||||||||||||||||||||||||||||||
| 303 | }, | ||||||||||||||||||||||||||||||||||||
| 304 | 24 | ); | |||||||||||||||||||||||||||||||||||
| 305 | $schema->add_mapping_resolver( | ||||||||||||||||||||||||||||||||||||
| 306 | tag => qr{^$perl_regex/ref:.+$}, | ||||||||||||||||||||||||||||||||||||
| 307 | on_create => $load_ref, | ||||||||||||||||||||||||||||||||||||
| 308 | 2 | ▶ | on_data => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 309 | 2 | my ($constructor, $ref, $list) = @_; | |||||||||||||||||||||||||||||||||||
| 310 | 2 | $$$ref = $self->construct_ref($list); | |||||||||||||||||||||||||||||||||||
| 311 | }, | ||||||||||||||||||||||||||||||||||||
| 312 | 24 | ); # if $no_objects; | |||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||
| 314 | # Scalar ref | ||||||||||||||||||||||||||||||||||||
| 315 | 8 | ▶ | my $load_scalar_ref = sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 316 | 8 | my $value = undef; | |||||||||||||||||||||||||||||||||||
| 317 | 8 | return \$value; | |||||||||||||||||||||||||||||||||||
| 318 | 24 | }; | |||||||||||||||||||||||||||||||||||
| 319 | 7 | ▶ | my $load_scalar_ref_blessed = sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 320 | 7 | my ($constructor, $event) = @_; | |||||||||||||||||||||||||||||||||||
| 321 | 7 | my $class = $event->{tag}; | |||||||||||||||||||||||||||||||||||
| 322 | 7 | $class =~ s{^$perl_regex/scalar:}{}; | |||||||||||||||||||||||||||||||||||
| 323 | 7 | my $value = undef; | |||||||||||||||||||||||||||||||||||
| 324 | 7 | return $self->object(\$value, $class); | |||||||||||||||||||||||||||||||||||
| 325 | 24 | }; | |||||||||||||||||||||||||||||||||||
| 326 | $schema->add_mapping_resolver( | ||||||||||||||||||||||||||||||||||||
| 327 | tag => "$_/scalar", | ||||||||||||||||||||||||||||||||||||
| 328 | on_create => $load_scalar_ref, | ||||||||||||||||||||||||||||||||||||
| 329 | 6 | ▶ | on_data => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 330 | 6 | my ($constructor, $ref, $list) = @_; | |||||||||||||||||||||||||||||||||||
| 331 | 6 | $$$ref = $self->construct_scalar($list); | |||||||||||||||||||||||||||||||||||
| 332 | }, | ||||||||||||||||||||||||||||||||||||
| 333 | 24 | ) for @perl_tags; | |||||||||||||||||||||||||||||||||||
| 334 | $schema->add_mapping_resolver( | ||||||||||||||||||||||||||||||||||||
| 335 | tag => qr{^$perl_regex/scalar:$class_regex$}, | ||||||||||||||||||||||||||||||||||||
| 336 | on_create => $load_scalar_ref_blessed, | ||||||||||||||||||||||||||||||||||||
| 337 | 7 | ▶ | on_data => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 338 | 7 | my ($constructor, $ref, $list) = @_; | |||||||||||||||||||||||||||||||||||
| 339 | 7 | $$$ref = $self->construct_scalar($list); | |||||||||||||||||||||||||||||||||||
| 340 | }, | ||||||||||||||||||||||||||||||||||||
| 341 | 24 | ); | |||||||||||||||||||||||||||||||||||
| 342 | $schema->add_mapping_resolver( | ||||||||||||||||||||||||||||||||||||
| 343 | tag => qr{^$perl_regex/scalar:.+$}, | ||||||||||||||||||||||||||||||||||||
| 344 | on_create => $load_scalar_ref, | ||||||||||||||||||||||||||||||||||||
| 345 | 2 | ▶ | on_data => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 346 | 2 | my ($constructor, $ref, $list) = @_; | |||||||||||||||||||||||||||||||||||
| 347 | 2 | $$$ref = $self->construct_scalar($list); | |||||||||||||||||||||||||||||||||||
| 348 | }, | ||||||||||||||||||||||||||||||||||||
| 349 | 24 | ); # if $no_objects; | |||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||
| 351 | $schema->add_representer( | ||||||||||||||||||||||||||||||||||||
| 352 | scalarref => 1, | ||||||||||||||||||||||||||||||||||||
| 353 | 4 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 354 | 4 | my ($rep, $node) = @_; | |||||||||||||||||||||||||||||||||||
| 355 | 4 | $node->{tag} = $perl_tag . "/scalar"; | |||||||||||||||||||||||||||||||||||
| 356 | 4 | $node->{data} = $self->represent_scalar($node->{value}); | |||||||||||||||||||||||||||||||||||
| 357 | }, | ||||||||||||||||||||||||||||||||||||
| 358 | 24 | ); | |||||||||||||||||||||||||||||||||||
| 359 | $schema->add_representer( | ||||||||||||||||||||||||||||||||||||
| 360 | refref => 1, | ||||||||||||||||||||||||||||||||||||
| 361 | 4 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 362 | 4 | my ($rep, $node) = @_; | |||||||||||||||||||||||||||||||||||
| 363 | 4 | $node->{tag} = $perl_tag . "/ref"; | |||||||||||||||||||||||||||||||||||
| 364 | 4 | $node->{data} = $self->represent_ref($node->{value}); | |||||||||||||||||||||||||||||||||||
| 365 | }, | ||||||||||||||||||||||||||||||||||||
| 366 | 24 | ); | |||||||||||||||||||||||||||||||||||
| 367 | $schema->add_representer( | ||||||||||||||||||||||||||||||||||||
| 368 | coderef => 1, | ||||||||||||||||||||||||||||||||||||
| 369 | 5 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||
| 370 | 5 | my ($rep, $node) = @_; | |||||||||||||||||||||||||||||||||||
| 371 | 5 | $node->{tag} = $perl_tag . "/code"; | |||||||||||||||||||||||||||||||||||
| 372 | 5 | ▶ | $node->{data} = $dumpcode ? $self->represent_code($node->{value}) : '{ "DUMMY" }'; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 373 | }, | ||||||||||||||||||||||||||||||||||||
| 374 | 24 | ); | |||||||||||||||||||||||||||||||||||
| 375 | $schema->add_representer( | ||||||||||||||||||||||||||||||||||||
| 376 | glob => 1, | ||||||||||||||||||||||||||||||||||||
| 377 | 6 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 378 | 6 | my ($rep, $node) = @_; | |||||||||||||||||||||||||||||||||||
| 379 | 6 | $node->{tag} = $perl_tag . "/glob"; | |||||||||||||||||||||||||||||||||||
| 380 | 6 | $node->{data} = $self->represent_glob($node->{value}); | |||||||||||||||||||||||||||||||||||
| 381 | }, | ||||||||||||||||||||||||||||||||||||
| 382 | 24 | ); | |||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||
| 384 | $schema->add_representer( | ||||||||||||||||||||||||||||||||||||
| 385 | class_matches => 1, | ||||||||||||||||||||||||||||||||||||
| 386 | 40 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=15 SCAR=29.9
| |||||||||||||||||||||||||||||||||||||
| 387 | 40 | my ($rep, $node) = @_; | |||||||||||||||||||||||||||||||||||
| 388 | 40 | my $blessed = blessed $node->{value}; | |||||||||||||||||||||||||||||||||||
| 389 | 40 | my $tag_blessed = ":$blessed"; | |||||||||||||||||||||||||||||||||||
| 390 | 40 | ▶ | if ($blessed !~ m/^$class_regex$/) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 391 | 0 | $tag_blessed = ''; | |||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||
| 393 | $node->{tag} = sprintf "$perl_tag/%s%s", | ||||||||||||||||||||||||||||||||||||
| 394 | 40 | lc($node->{reftype}), $tag_blessed; | |||||||||||||||||||||||||||||||||||
| 395 | 40 | ▶ | if ($node->{reftype} eq 'HASH') { | ||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||
| 396 | 6 | $node->{data} = $node->{value}; | |||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||
| 398 | elsif ($node->{reftype} eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||
| 399 | 10 | $node->{data} = $node->{value}; | |||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||
| 402 | # Fun with regexes in perl versions! | ||||||||||||||||||||||||||||||||||||
| 403 | elsif ($node->{reftype} eq 'REGEXP') { | ||||||||||||||||||||||||||||||||||||
| 404 | 8 | ▶ | if ($blessed eq 'Regexp') { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 405 | 4 | $node->{tag} = $perl_tag . "/regexp"; | |||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||
| 407 | 8 | $node->{data} = $self->represent_regex($node->{value}); | |||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||
| 409 | elsif ($node->{reftype} eq 'SCALAR') { | ||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||
| 411 | # in perl <= 5.10 regex reftype(regex) was SCALAR | ||||||||||||||||||||||||||||||||||||
| 412 | 4 | ▶ | if ($blessed eq 'Regexp') { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 413 | 0 | $node->{tag} = $perl_tag . '/regexp'; | |||||||||||||||||||||||||||||||||||
| 414 | 0 | $node->{data} = $self->represent_regex($node->{value}); | |||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||
| 417 | # In perl <= 5.10 there seemed to be no better pure perl | ||||||||||||||||||||||||||||||||||||
| 418 | # way to detect a blessed regex? | ||||||||||||||||||||||||||||||||||||
| 419 | ▶ | elsif ( | |||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$] <= "5.010001" and not defined ${$$node{"value"};} and $node->{"value"} =~ /^\(\?/
$] <= "5.010001" and not defined ${$$node{"value"};}
MC/DC0%0/3
$] <= "5.010001" and not defined ${$$node{"value"};} and $node->{"value"} =~ /^\(\?/
$] <= "5.010001"
not defined ${$$node{"value"};}
$node->{"value"} =~ /^\(\?/
Truth table25%1/4
A and not(B) and C
A= $] <= "5.010001"B= not defined ${$$node{"value"};}C= $node->{"value"} =~ /^\(\?/
| |||||||||||||||||||||||||||||||||||||
| 420 | $] <= 5.010001 | ||||||||||||||||||||||||||||||||||||
| 421 | 0 | and not defined ${ $node->{value} } | |||||||||||||||||||||||||||||||||||
| 422 | and $node->{value} =~ m/^\(\?/ | ||||||||||||||||||||||||||||||||||||
| 423 | ) { | ||||||||||||||||||||||||||||||||||||
| 424 | 0 | $node->{tag} = $perl_tag . '/regexp' . $tag_blessed; | |||||||||||||||||||||||||||||||||||
| 425 | 0 | $node->{data} = $self->represent_regex($node->{value}); | |||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||
| 427 | else { | ||||||||||||||||||||||||||||||||||||
| 428 | # phew, just a simple scalarref | ||||||||||||||||||||||||||||||||||||
| 429 | 4 | $node->{data} = $self->represent_scalar($node->{value}); | |||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||
| 432 | elsif ($node->{reftype} eq 'REF') { | ||||||||||||||||||||||||||||||||||||
| 433 | 4 | $node->{data} = $self->represent_ref($node->{value}); | |||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||
| 436 | elsif ($node->{reftype} eq 'CODE') { | ||||||||||||||||||||||||||||||||||||
| 437 | 5 | ▶ | $node->{data} = $dumpcode ? $self->represent_code($node->{value}) : '{ "DUMMY" }'; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||
| 439 | elsif ($node->{reftype} eq 'GLOB') { | ||||||||||||||||||||||||||||||||||||
| 440 | 3 | $node->{data} = $self->represent_glob($node->{value}); | |||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||
| 442 | else { | ||||||||||||||||||||||||||||||||||||
| 443 | 0 | die "Reftype '$node->{reftype}' not implemented"; | |||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||
| 446 | 40 | return 1; | |||||||||||||||||||||||||||||||||||
| 447 | }, | ||||||||||||||||||||||||||||||||||||
| 448 | 24 | ); | |||||||||||||||||||||||||||||||||||
| 449 | 24 | return; | |||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||
| 452 | 12 | ▶ | sub evaluate_code { | ||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate_code: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 453 | 12 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||
| 454 | 12 | ▶ | unless ($code =~ m/^ \s* \{ .* \} \s* \z/xs) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 455 | 2 | die "Malformed code"; | |||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||
| 457 | 10 | $code = "sub $code"; | |||||||||||||||||||||||||||||||||||
| 458 | 10 | ▶ | my $sub = eval $code; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 459 | 10 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 460 | 2 | die "Couldn't eval code: $@>>$code<<"; | |||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||
| 462 | 8 | return $sub; | |||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||
| 465 | 11 | ▶ | sub construct_regex { | ||||||||||||||||||||||||||||||||||
|
Subroutine
construct_regex: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 466 | 11 | my ($self, $regex) = @_; | |||||||||||||||||||||||||||||||||||
| 467 | 11 | ▶ | if ($regex =~ m/^$qr_prefix(.*)\)\z/s) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 468 | 2 | $regex = $1; | |||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||
| 470 | 11 | my $qr = qr{$regex}; | |||||||||||||||||||||||||||||||||||
| 471 | 11 | return $qr; | |||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||
| 474 | 10 | ▶ | sub construct_glob { | ||||||||||||||||||||||||||||||||||
|
Subroutine
construct_glob: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 475 | 10 | my ($self, $list) = @_; | |||||||||||||||||||||||||||||||||||
| 476 | 10 | ▶ | if (@$list % 2) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 477 | 0 | die "Unexpected data in perl/glob construction"; | |||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||
| 479 | 10 | my %globdata = @$list; | |||||||||||||||||||||||||||||||||||
| 480 | 10 | ▶ | my $name = delete $globdata{NAME} or die "Missing NAME in perl/glob"; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 481 | 9 | my $pkg = delete $globdata{PACKAGE}; | |||||||||||||||||||||||||||||||||||
| 482 | 9 | ▶ | $pkg = 'main' unless defined $pkg; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 483 | 9 | my @allowed = qw(SCALAR ARRAY HASH CODE IO); | |||||||||||||||||||||||||||||||||||
| 484 | 9 | delete @globdata{ @allowed }; | |||||||||||||||||||||||||||||||||||
| 485 | 9 | ▶ | if (my @keys = keys %globdata) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 486 | 1 | die "Unexpected keys in perl/glob: @keys"; | |||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||
| 488 | 7 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 489 | 8 | return *{"${pkg}::$name"}; | |||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||
| 492 | 30 | ▶ | sub construct_scalar { | ||||||||||||||||||||||||||||||||||
|
Subroutine
construct_scalar: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 493 | 30 | my ($self, $list) = @_; | |||||||||||||||||||||||||||||||||||
| 494 | 30 | ▶ | if (@$list != 2) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 495 | 4 | die "Unexpected data in perl/scalar construction"; | |||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||
| 497 | 26 | my ($key, $value) = @$list; | |||||||||||||||||||||||||||||||||||
| 498 | 26 | ▶ | unless ($key eq '=') { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 499 | 4 | die "Unexpected data in perl/scalar construction"; | |||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||
| 501 | 22 | return $value; | |||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||
| 504 | 15 | ▶ | sub construct_ref { | ||||||||||||||||||||||||||||||||||
|
Subroutine
construct_ref: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 505 | 15 | &construct_scalar; | |||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||
| 508 | 16 | ▶ | sub represent_scalar { | ||||||||||||||||||||||||||||||||||
|
Subroutine
represent_scalar: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 509 | 16 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||
| 510 | 16 | return { '=' => $$value }; | |||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||
| 513 | 8 | ▶ | sub represent_ref { | ||||||||||||||||||||||||||||||||||
|
Subroutine
represent_ref: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 514 | 8 | &represent_scalar; | |||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||
| 517 | 8 | ▶ | sub represent_code { | ||||||||||||||||||||||||||||||||||
|
Subroutine
represent_code: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 518 | 8 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||
| 519 | 8 | require B::Deparse; | |||||||||||||||||||||||||||||||||||
| 520 | 8 | my $deparse = B::Deparse->new("-p", "-sC"); | |||||||||||||||||||||||||||||||||||
| 521 | 8 | return $deparse->coderef2text($code); | |||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||
| 525 | 7 | my @stats = qw/ device inode mode links uid gid rdev size | |||||||||||||||||||||||||||||||||||
| 526 | atime mtime ctime blksize blocks /; | ||||||||||||||||||||||||||||||||||||
| 527 | 9 | ▶ | sub represent_glob { | ||||||||||||||||||||||||||||||||||
|
Subroutine
represent_glob: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 528 | 9 | my ($self, $glob) = @_; | |||||||||||||||||||||||||||||||||||
| 529 | 9 | my %glob; | |||||||||||||||||||||||||||||||||||
| 530 | 9 | for my $type (qw/ PACKAGE NAME SCALAR ARRAY HASH CODE IO /) { | |||||||||||||||||||||||||||||||||||
| 531 | 63 | my $value = *{ $glob }{ $type }; | |||||||||||||||||||||||||||||||||||
| 532 | 63 | ▶ | if ($type eq 'SCALAR') { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 533 | 9 | $value = $$value; | |||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||
| 535 | elsif ($type eq 'IO') { | ||||||||||||||||||||||||||||||||||||
| 536 | 9 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 537 | 5 | undef $value; | |||||||||||||||||||||||||||||||||||
| 538 | 5 | $value->{stat} = {}; | |||||||||||||||||||||||||||||||||||
| 539 | 5 | ▶ | if ($value->{fileno} = fileno(*{ $glob })) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 540 | 5 | @{ $value->{stat} }{ @stats } = stat(*{ $glob }); | |||||||||||||||||||||||||||||||||||
| 541 | 5 | $value->{tell} = tell *{ $glob }; | |||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||
| 545 | 63 | ▶ | $glob{ $type } = $value if defined $value; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||
| 547 | 9 | return \%glob; | |||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||
| 550 | 8 | ▶ | sub represent_regex { | ||||||||||||||||||||||||||||||||||
|
Subroutine
represent_regex: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 551 | 8 | my ($self, $regex) = @_; | |||||||||||||||||||||||||||||||||||
| 552 | 8 | $regex = "$regex"; | |||||||||||||||||||||||||||||||||||
| 553 | 8 | ▶ | if ($regex =~ m/^$qr_prefix(.*)\)\z/s) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 554 | 8 | $regex = $1; | |||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||
| 556 | 8 | return $regex; | |||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||
| 559 | 48 | ▶ | sub object { | ||||||||||||||||||||||||||||||||||
|
Subroutine
object: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 560 | 48 | my ($self, $data, $class) = @_; | |||||||||||||||||||||||||||||||||||
| 561 | 48 | return bless $data, $class; | |||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||
| 564 | 7 | 1; | |||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||
| 566 | __END__ | ||||||||||||||||||||||||||||||||||||