| 1 | 53 | ▶ | 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 | 53 | ▶ | use Lingy::Common; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 100572 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=10 SCAR=23.1
Pod
undocumented
| |||||||||||||||||||||
| 7 | 100572 | my ($class, %args) = @_; | |||||||||||||||||||
| 8 | my $self = bless { | ||||||||||||||||||||
| 9 | outer => $args{outer}, | ||||||||||||||||||||
| 10 | space => $args{space} // {}, | ||||||||||||||||||||
| 11 | 100572 | ▶ | }, $class; | ||||||||||||||||||
|
Condition50%1/2
$args{"space"} // {}
MC/DC0%0/1
$args{"space"} // {}
$args{"space"}
Truth table50%1/2
A
A= $args{"space"}
| |||||||||||||||||||||
| 12 | 100572 | ▶ | my $binds = [ @{$args{binds} // []} ]; | ||||||||||||||||||
|
Condition100%2/2
$args{"binds"} // []
MC/DC100%1/1
$args{"binds"} // []
$args{"binds"}
Truth table100%2/2
A
A= $args{"binds"}
| |||||||||||||||||||||
| 13 | 100572 | ▶ | my $exprs = $args{exprs} // []; | ||||||||||||||||||
|
Condition100%2/2
$args{"exprs"} // []
MC/DC100%1/1
$args{"exprs"} // []
$args{"exprs"}
Truth table100%2/2
A
A= $args{"exprs"}
| |||||||||||||||||||||
| 14 | 100572 | ▶ | while (@$binds) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 15 | 177623 | ▶ | if ("$binds->[0]" eq '&') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 16 | 24208 | shift @$binds; | |||||||||||||||||||
| 17 | 24208 | $exprs = [list([@$exprs])]; | |||||||||||||||||||
| 18 | } | ||||||||||||||||||||
| 19 | 177623 | ▶ | $self->{space}{shift(@$binds)} = (shift(@$exprs) // nil); | ||||||||||||||||||
|
Condition33%1/3
shift @$exprs // nil()
MC/DC0%0/2
shift @$exprs // nil()
shift @$exprs
nil()
Truth table33%1/3
A // B
A= shift @$exprsB= nil()
| |||||||||||||||||||||
| 20 | } | ||||||||||||||||||||
| 21 | 100572 | ▶ | if (my $outer = $self->{outer}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 22 | 100518 | ▶ | $self->{LOOP} = $outer->{LOOP} if $outer->{LOOP}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 23 | 100518 | ▶ | $self->{RECUR} = $outer->{RECUR} if $outer->{RECUR}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | 100572 | return $self; | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 1197 | ▶ | sub set { | ||||||||||||||||||
|
Subroutine
set: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 29 | 1197 | my ($self, $symbol, $value) = @_; | |||||||||||||||||||
| 30 | 1197 | my $space = $self->{space}; | |||||||||||||||||||
| 31 | 1197 | $space->{$symbol} = $value; | |||||||||||||||||||
| 32 | 1197 | ▶ | return ref($space) eq 'HASH' | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | ? $symbol | ||||||||||||||||||||
| 34 | : symbol($space->_name . "/$symbol"); | ||||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 649410 | ▶ | sub get { | ||||||||||||||||||
|
Subroutine
get: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||
| 38 | 649410 | my ($self, $symbol, $optional) = @_; | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | # XXX Temporary hack until Vars | ||||||||||||||||||||
| 41 | 649410 | ▶ | if ("$symbol" eq '*ns*') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 42 | 22 | return RT->current_ns; | |||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 649388 | ▶ | return $self->get_qualified($symbol, $optional) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 46 | if $symbol =~ m{./.}; | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 599687 | ▶ | while ($self) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 49 | 971251 | my $space = $self->{space}; | |||||||||||||||||||
| 50 | 971251 | ▶ | if (defined(my $value = $space->{$symbol})) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | 493174 | return $value; | |||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | 478077 | $self = $self->{outer}; | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 106513 | ▶ | if (my $class = RT->current_ns->{"$symbol"}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | 0 | return $class; | |||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 106513 | ▶ | return if $optional; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 10 | ▶ | err "Class not found: '$symbol'" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | if $symbol =~ /\w\.\w/; | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 9 | err "Unable to resolve symbol: '$symbol' in this context"; | |||||||||||||||||||
| 66 | } | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | 49701 | ▶ | sub get_qualified { | ||||||||||||||||||
|
Subroutine
get_qualified: called CC=8 SCAR=20.9
Pod
undocumented
| |||||||||||||||||||||
| 69 | 49701 | my ($self, $symbol, $optional) = @_; | |||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 49701 | ▶ | $symbol =~ m{^(.*)/(.*)$} or die; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 72 | 49701 | my $space_name = $1; | |||||||||||||||||||
| 73 | 49701 | my $symbol_name = $2; | |||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 49701 | ▶ | if (my $ns = RT->core_ns) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 76 | 43447 | ▶ | if (my $class = RT->core_ns->{$space_name}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 77 | 43428 | return \&{"${class}::$symbol_name"}; | |||||||||||||||||||
| 78 | } | ||||||||||||||||||||
| 79 | } | ||||||||||||||||||||
| 80 | 6273 | ▶ | if (my $class = RT->current_ns->{$space_name}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 81 | 6254 | return \&{"${class}::$symbol_name"}; | |||||||||||||||||||
| 82 | } | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | 19 | ▶ | my $ns = RT->namespaces->{$space_name} | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 85 | or err "No such namespace: '$space_name'"; | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | 19 | ▶ | if (defined(my $value = $ns->{$symbol_name})) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 88 | 18 | return $value; | |||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | 1 | ▶ | return if $optional; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | 1 | err "Unable to resolve symbol: '$symbol' in this context"; | |||||||||||||||||||
| 94 | } | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | 53 | 1; | |||||||||||||||||||