blib/lib/Magpie/SymbolTable.pm

filter: Statementstmt 74.2% 26 / 35 Branchbran 66.6% 8 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod 0.0% 0 / 8 totaltotal 63.0% 41 / 65 CC 7 SCAR 9.4
CC
7
Cov
72%
reset_symbol
6.0
symbol_index
3.0
has_symbol
2.3
CRAP 2.6
« blib/lib/Magpie/Resource.pm ↑ Summary blib/lib/Magpie/Constants.pm »
1 package Magpie::SymbolTable;
2 50 $Magpie::SymbolTable::VERSION = '1.163200';
3 #ABSTRACT: Core Magpie Event Symbol Table Object
4 50 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 50 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 306 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
8 306 return bless [], shift;
9 }
10  
11 # for reference
12 # $self = [ [$name, [...]], ];
13  
14 2213 ▶sub get_symbol {
Subroutine get_symbol: called CC=2 SCAR=7.6
Pod undocumented
15 2213 my $idx = $_[0]->symbol_index($_[1]);
16 2213 ▶ if ( defined( $idx ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $idx) 2213 0 2213
17 2213 return $_[0]->[$idx]->[1];
18 }
19 0 return undef;
20 }
21  
22 4442 ▶sub has_symbol {
Subroutine has_symbol: called CC=2 SCAR=8.1
Pod undocumented
23 4442 my $idx = $_[0]->symbol_index($_[1]);
24 4442 ▶ return 1 if defined($idx);
Branch: 1 branch
BranchTrueFalseTotal
if defined $idx 4442 0 4442
25 0 return undef;
26 }
27  
28 3410 ▶sub add_symbol {
Subroutine add_symbol: called CC=2 SCAR=6.9
Pod undocumented
29 3410 my $idx = $_[0]->symbol_index($_[1]);
30 3410 ▶ if ( defined( $idx ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $idx) { } 4 3406 3410
31 4 push @{$_[0]->[$idx]->[1]}, $_[2];
32 }
33 else {
34 3406 push @{$_[0]}, [ $_[1], [ $_[2] ] ];
35 }
36 }
37  
38 0 ▶sub reset_symbol {
Subroutine reset_symbol: not called CC=2 SCAR=17.9
Pod undocumented
39 0 my $idx = $_[0]->symbol_index($_[1]);
40 0 ▶ if ( defined( $idx ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $idx) 0 0 0
41 0 $_[0]->[$idx]->[1] = [];
42 }
43 }
44  
45 0 ▶sub reset_table {
Subroutine reset_table: not called CC=1 SCAR=6.9
Pod undocumented
46 0 $_[0] = bless [];
47 }
48  
49 0 ▶sub symbol_names {
Subroutine symbol_names: not called CC=1 SCAR=6.9
Pod undocumented
50 0 return map { $_->[0] } @{$_[0]};
51 }
52  
53 10065 ▶sub symbol_index {
Subroutine symbol_index: called CC=3 SCAR=11.0
Pod undocumented
54 10065 my $self = shift;
55 10065 my $name = shift;
56 10065 my $i;
57 10065 ▶ for ($i=0;$i<scalar(@$self);$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$self) 56977 3406 60383
58 56977 ▶ return $i if $self->[$i]->[0] eq $name;
Branch: 1 branch
BranchTrueFalseTotal
if $self->[$i][0] eq $name 6659 50318 56977
59 }
60 3406 return undef;
61 }
62  
63 # SEEALSO: Magpie
64  
65 50 1;
66  
67 __END__
« blib/lib/Magpie/Resource.pm ↑ Summary blib/lib/Magpie/Constants.pm »