lib/Lingy/Env.pm

filter: Statementstmt 14.0% 10 / 71 Branchbran 0.0% 0 / 52 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 30.0% 3 / 10 Podpod 0.0% 0 / 6 totaltotal 8.5% 13 / 153 CC 31 SCAR 41.3
CC
31
Cov
8%
new
110.0
get_qualified
72.0
get
56.0
CRAP 62.2
« lib/Lingy/ClojureREPL.pm ↑ Summary lib/Lingy/Lang/HashMap.pm »
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"} // {}
l!l
00
MC/DC0%0/1
$args{"space"} // {}
$args{"space"}
Truth table0%0/2
A
A= $args{"space"}
Aresult
11
00
14 0 ▶ my $binds = [ @{$args{binds} // []} ];
Condition0%0/2
$args{"binds"} // []
l!l
00
MC/DC0%0/1
$args{"binds"} // []
$args{"binds"}
Truth table0%0/2
A
A= $args{"binds"}
Aresult
11
00
15 0 ▶ my $exprs = $args{exprs} // [];
Condition0%0/2
$args{"exprs"} // []
l!l
00
MC/DC0%0/1
$args{"exprs"} // []
$args{"exprs"}
Truth table0%0/2
A
A= $args{"exprs"}
Aresult
11
00
16 0 ▶ while (@$binds) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$binds) 0 0 0
17 0 ▶ if ("$binds->[0]" eq '&') {
Branch: 1 branch
BranchTrueFalseTotal
if ("$binds->[0]" eq "&") 0 0 0
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()
l!l&&r!l&&!r
000
MC/DC0%0/2
shift @$exprs // nil()
shift @$exprs nil()
Truth table0%0/3
A // B
A= shift @$exprsB= nil()
ABresult
1X1
011
000
22 }
23 0 ▶ if (my $outer = $self->{outer}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $outer = $self->{"outer"}) 0 0 0
24 0 ▶ $self->{LOOP} = $outer->{LOOP} if $outer->{LOOP};
Branch: 1 branch
BranchTrueFalseTotal
if $outer->{"LOOP"} 0 0 0
25 0 ▶ $self->{RECUR} = $outer->{RECUR} if $outer->{RECUR};
Branch: 1 branch
BranchTrueFalseTotal
if $outer->{"RECUR"} 0 0 0
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
BranchTrueFalseTotal
ref $space eq 'HASH' ? : 0 0 0
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
BranchTrueFalseTotal
ref $space eq 'HASH' ? : 0 0 0
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
BranchTrueFalseTotal
if $symbol =~ m[./.] 0 0 0
52 if $symbol =~ m{./.};
53  
54 0 ▶ while ($self) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self) 0 0 0
55 0 my $ns = $self->space;
56 0 ▶ if (defined(my $value = _referred($ns, $symbol))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $value = _referred($ns, $symbol))) 0 0 0
57 0 return $value;
58 }
59 0 $self = $self->{outer};
60 }
61  
62 0 ▶ if (my $class = RT->current_ns->{"$symbol"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $class = "Lingy::Lang::RT"->current_ns->{"$symbol"}) 0 0 0
63 0 return $class;
64 }
65  
66 0 ▶ err "Class not found: '$symbol'"
Branch: 1 branch
BranchTrueFalseTotal
if $symbol =~ /\w\.\w/ 0 0 0
67 if $symbol =~ /\w\.\w/;
68  
69 0 ▶ return if $optional;
Branch: 1 branch
BranchTrueFalseTotal
if $optional 0 0 0
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
BranchTrueFalseTotal
$symbol =~ m[^(.*)/(.*)$] or die 0 0 0
78 0 my $space_name = $1;
79 0 my $symbol_name = $2;
80  
81 0 ▶ if (my $ns = RT->core_ns) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ns = "Lingy::Lang::RT"->core_ns) 0 0 0
82 0 ▶ if (my $class = RT->core_ns->{$space_name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $class = "Lingy::Lang::RT"->core_ns->{$space_name}) 0 0 0
83 0 return \&{"${class}::$symbol_name"};
84 }
85 }
86 0 ▶ if (my $class = RT->current_ns->{$space_name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $class = "Lingy::Lang::RT"->current_ns->{$space_name}) 0 0 0
87 0 return \&{"${class}::$symbol_name"};
88 }
89  
90 0 ▶ my $ns = RT->namespaces->{$space_name}
Branch: 1 branch
BranchTrueFalseTotal
my $ns = "Lingy::Lang::RT"->namespaces->{$space_name} or err("No such namespace: '${space_name}'") 0 0 0
91 or err "No such namespace: '$space_name'";
92  
93 0 ▶ if (defined(my $value = _referred($ns, $symbol_name))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $value = _referred($ns, $symbol_name))) 0 0 0
94 0 return $value;
95 }
96  
97 0 ▶ return if $optional;
Branch: 1 branch
BranchTrueFalseTotal
if $optional 0 0 0
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
BranchTrueFalseTotal
if (defined(my $value = $ns->{$symbol})) 0 0 0
105 0 return $value;
106 }
107 0 ▶ if (ref($ns) ne 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ns ne "HASH") 0 0 0
108 0 ▶ if (my $refer_ns_map = RT->ns_refers->{$ns->NAME}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $refer_ns_map = "Lingy::Lang::RT"->ns_refers->{$ns->NAME}) 0 0 0
109 0 ▶ if (my $refer_ns_name = $refer_ns_map->{$symbol}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $refer_ns_name = $refer_ns_map->{$symbol}) 0 0 0
110 0 ▶ if (my $refer_ns =
Branch: 1 branch
BranchTrueFalseTotal
if (my $refer_ns = "Lingy::Lang::RT"->namespaces->{$refer_ns_name}) 0 0 0
111 RT->namespaces->{$refer_ns_name}
112 ) {
113 0 ▶ if (defined(my $value = $refer_ns->{$symbol})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $value = $refer_ns->{$symbol})) 0 0 0
114 0 return $value;
115 }
116 }
117 }
118 }
119 }
120 0 return;
121 }
122  
123 1 1;
« lib/Lingy/ClojureREPL.pm ↑ Summary lib/Lingy/Lang/HashMap.pm »