blib/lib/Magpie/SymbolTable.pm

filter: Statementstmt 68.5% 24 / 35 Branchbran 58.3% 7 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod 0.0% 0 / 8 totaltotal 58.4% 38 / 65 CC 7 SCAR 9.5
CC
7
Cov
66%
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 49 $Magpie::SymbolTable::VERSION = '1.141660';
3 #ABSTRACT: Core Magpie Event Symbol Table Object
4 49 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 49 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 sub new {
8 306 ▶ return bless [], shift;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
9 }
10  
11 # for reference
12 # $self = [ [$name, [...]], ];
13  
14 sub get_symbol {
15 2213 ▶ my $idx = $_[0]->symbol_index($_[1]);
Subroutine get_symbol: called CC=2 SCAR=7.6
Pod undocumented
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 sub has_symbol {
23 4442 ▶ my $idx = $_[0]->symbol_index($_[1]);
Subroutine has_symbol: called CC=2 SCAR=8.1
Pod undocumented
24 4442 ▶ return 1 if defined($idx);
Branch: 1 branch
BranchTrueFalseTotal
if defined $idx 4442 0 4442
25 0 return undef;
26 }
27  
28 sub add_symbol {
29 3410 ▶ my $idx = $_[0]->symbol_index($_[1]);
Subroutine add_symbol: called CC=2 SCAR=7.9
Pod undocumented
30 3410 ▶ if ( defined( $idx ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $idx) { } 0 3410 3410
31 0 push @{$_[0]->[$idx]->[1]}, $_[2];
32 }
33 else {
34 3410 push @{$_[0]}, [ $_[1], [ $_[2] ] ];
35 }
36 }
37  
38 sub reset_symbol {
39 0 ▶ my $idx = $_[0]->symbol_index($_[1]);
Subroutine reset_symbol: not called CC=2 SCAR=17.9
Pod undocumented
40 0 ▶ if ( defined( $idx ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $idx) 0 0 0
41 0 $_[0]->[$idx]->[1] = [];
42 }
43 }
44  
45 sub reset_table {
46 0 ▶ $_[0] = bless [];
Subroutine reset_table: not called CC=1 SCAR=6.9
Pod undocumented
47 }
48  
49 sub symbol_names {
50 0 ▶ return map { $_->[0] } @{$_[0]};
Subroutine symbol_names: not called CC=1 SCAR=6.9
Pod undocumented
51 }
52  
53 sub symbol_index {
54 10065 ▶ my $self = shift;
Subroutine symbol_index: called CC=3 SCAR=11.0
Pod undocumented
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) 56089 3410 59499
58 56089 ▶ return $i if $self->[$i]->[0] eq $name;
Branch: 1 branch
BranchTrueFalseTotal
if $self->[$i][0] eq $name 6655 49434 56089
59 }
60 3410 return undef;
61 }
62  
63 # SEEALSO: Magpie
64  
65 49 1;
66 __END__
67 =pod
68  
69 =head1 NAME
70  
71 Magpie::SymbolTable - Core Magpie Event Symbol Table Object
72  
73 =head1 VERSION
74  
75 version 1.141660
76  
77 =head1 AUTHORS
78  
79 =over 4
80  
81 =item *
82  
83 Kip Hampton <kip.hampton@tamarou.com>
84  
85 =item *
86  
87 Chris Prather <chris.prather@tamarou.com>
88  
89 =back
90  
91 =head1 COPYRIGHT AND LICENSE
92  
93 This software is copyright (c) 2011 by Tamarou, LLC.
94  
95 This is free software; you can redistribute it and/or modify it under
96 the same terms as the Perl 5 programming language system itself.
97  
98 =cut
99  
« blib/lib/Magpie/Resource.pm ↑ Summary blib/lib/Magpie/Constants.pm »