| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 58 | 56977 | ▶ | return $i if $self->[$i]->[0] eq $name; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | } | ||||||||||
| 60 | 3406 | return undef; | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | # SEEALSO: Magpie | ||||||||||
| 64 | |||||||||||
| 65 | 50 | 1; | |||||||||
| 66 | |||||||||||
| 67 | __END__ | ||||||||||