| 1 | 1 | ▶ | use strict; use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 2 | package Lingy::Env; | ||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 1 | ▶ | use Lingy::Common; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 0 | ▶ | sub space { shift->{space} } | ||||||||||||||||||
|
Subroutine
space: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | sub new { | ||||||||||||||||||||
| 9 | 0 | ▶ | my ($class, %args) = @_; | ||||||||||||||||||
|
Subroutine
new: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||
| 10 | my $self = bless { | ||||||||||||||||||||
| 11 | outer => $args{outer}, | ||||||||||||||||||||
| 12 | space => $args{space} // {}, | ||||||||||||||||||||
| 13 | 0 | ▶ | }, $class; | ||||||||||||||||||
|
Condition0%0/2
$args{"space"} // {}
MC/DC0%0/1
$args{"space"} // {}
$args{"space"}
Truth table0%0/2
A
A= $args{"space"}
| |||||||||||||||||||||
| 14 | 0 | ▶ | my $binds = [ @{$args{binds} // []} ]; | ||||||||||||||||||
|
Condition0%0/2
$args{"binds"} // []
MC/DC0%0/1
$args{"binds"} // []
$args{"binds"}
Truth table0%0/2
A
A= $args{"binds"}
| |||||||||||||||||||||
| 15 | 0 | ▶ | my $exprs = $args{exprs} // []; | ||||||||||||||||||
|
Condition0%0/2
$args{"exprs"} // []
MC/DC0%0/1
$args{"exprs"} // []
$args{"exprs"}
Truth table0%0/2
A
A= $args{"exprs"}
| |||||||||||||||||||||
| 16 | 0 | ▶ | while (@$binds) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 17 | 0 | ▶ | if ("$binds->[0]" eq '&') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 18 | 0 | shift @$binds; | |||||||||||||||||||
| 19 | 0 | $exprs = [list([@$exprs])]; | |||||||||||||||||||
| 20 | } | ||||||||||||||||||||
| 21 | 0 | ▶ | $self->{space}{shift(@$binds)} = (shift(@$exprs) // nil); | ||||||||||||||||||
|
Condition0%0/3
shift @$exprs // nil()
MC/DC0%0/2
shift @$exprs // nil()
shift @$exprs
nil()
Truth table0%0/3
A // B
A= shift @$exprsB= nil()
| |||||||||||||||||||||
| 22 | } | ||||||||||||||||||||
| 23 | 0 | ▶ | if (my $outer = $self->{outer}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | 0 | ▶ | $self->{LOOP} = $outer->{LOOP} if $outer->{LOOP}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 25 | 0 | ▶ | $self->{RECUR} = $outer->{RECUR} if $outer->{RECUR}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | 0 | return $self; | |||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | sub set { | ||||||||||||||||||||
| 31 | 0 | ▶ | my ($self, $symbol, $value) = @_; | ||||||||||||||||||
|
Subroutine
set: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 32 | 0 | my $space = $self->{space}; | |||||||||||||||||||
| 33 | 0 | $space->{$symbol} = $value; | |||||||||||||||||||
| 34 | 0 | ▶ | return ref($space) eq 'HASH' | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 35 | ? $symbol | ||||||||||||||||||||
| 36 | : symbol($space->NAME . "/$symbol"); | ||||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | sub ns_set { | ||||||||||||||||||||
| 40 | 0 | ▶ | my ($self, $symbol, $value) = @_; | ||||||||||||||||||
|
Subroutine
ns_set: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 41 | 0 | my $space = RT->current_ns(); | |||||||||||||||||||
| 42 | 0 | $space->{$symbol} = $value; | |||||||||||||||||||
| 43 | 0 | ▶ | return ref($space) eq 'HASH' | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 44 | ? $symbol | ||||||||||||||||||||
| 45 | : symbol($space->NAME . "/$symbol"); | ||||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | sub get { | ||||||||||||||||||||
| 49 | 0 | ▶ | my ($self, $symbol, $optional) = @_; | ||||||||||||||||||
|
Subroutine
get: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 0 | ▶ | return $self->get_qualified($symbol, $optional) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 52 | if $symbol =~ m{./.}; | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 0 | ▶ | while ($self) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 55 | 0 | my $ns = $self->space; | |||||||||||||||||||
| 56 | 0 | ▶ | if (defined(my $value = _referred($ns, $symbol))) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | 0 | return $value; | |||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | 0 | $self = $self->{outer}; | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | ▶ | if (my $class = RT->current_ns->{"$symbol"}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | 0 | return $class; | |||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 0 | ▶ | err "Class not found: '$symbol'" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 67 | if $symbol =~ /\w\.\w/; | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 0 | ▶ | return if $optional; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 0 | err "Unable to resolve symbol: '$symbol' in this context"; | |||||||||||||||||||
| 72 | } | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | sub get_qualified { | ||||||||||||||||||||
| 75 | 0 | ▶ | my ($self, $symbol, $optional) = @_; | ||||||||||||||||||
|
Subroutine
get_qualified: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | 0 | ▶ | $symbol =~ m{^(.*)/(.*)$} or die; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 78 | 0 | my $space_name = $1; | |||||||||||||||||||
| 79 | 0 | my $symbol_name = $2; | |||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | 0 | ▶ | if (my $ns = RT->core_ns) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 82 | 0 | ▶ | if (my $class = RT->core_ns->{$space_name}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 83 | 0 | return \&{"${class}::$symbol_name"}; | |||||||||||||||||||
| 84 | } | ||||||||||||||||||||
| 85 | } | ||||||||||||||||||||
| 86 | 0 | ▶ | if (my $class = RT->current_ns->{$space_name}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 87 | 0 | return \&{"${class}::$symbol_name"}; | |||||||||||||||||||
| 88 | } | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | 0 | ▶ | my $ns = RT->namespaces->{$space_name} | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 91 | or err "No such namespace: '$space_name'"; | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | 0 | ▶ | if (defined(my $value = _referred($ns, $symbol_name))) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 94 | 0 | return $value; | |||||||||||||||||||
| 95 | } | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | 0 | ▶ | return if $optional; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | 0 | err "Unable to resolve symbol: '$symbol' in this context"; | |||||||||||||||||||
| 100 | } | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | sub _referred { | ||||||||||||||||||||
| 103 | 0 | ▶ | my ($ns, $symbol) = @_; | ||||||||||||||||||
|
Subroutine
_referred: not called CC=7 SCAR=40.3
| |||||||||||||||||||||
| 104 | 0 | ▶ | if (defined(my $value = $ns->{$symbol})) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 105 | 0 | return $value; | |||||||||||||||||||
| 106 | } | ||||||||||||||||||||
| 107 | 0 | ▶ | if (ref($ns) ne 'HASH') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 108 | 0 | ▶ | if (my $refer_ns_map = RT->ns_refers->{$ns->NAME}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 109 | 0 | ▶ | if (my $refer_ns_name = $refer_ns_map->{$symbol}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 110 | 0 | ▶ | if (my $refer_ns = | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 111 | RT->namespaces->{$refer_ns_name} | ||||||||||||||||||||
| 112 | ) { | ||||||||||||||||||||
| 113 | 0 | ▶ | if (defined(my $value = $refer_ns->{$symbol})) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 114 | 0 | return $value; | |||||||||||||||||||
| 115 | } | ||||||||||||||||||||
| 116 | } | ||||||||||||||||||||
| 117 | } | ||||||||||||||||||||
| 118 | } | ||||||||||||||||||||
| 119 | } | ||||||||||||||||||||
| 120 | 0 | return; | |||||||||||||||||||
| 121 | } | ||||||||||||||||||||
| 122 | |||||||||||||||||||||
| 123 | 1 | 1; | |||||||||||||||||||