| 1 | package Ref::Store::Dumper; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Scalar::Util qw(isweak looks_like_number); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Log::Fu; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | our $IndentChar = ' '; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 10 | 0 | my $cls = shift; | |||||||||||||||||||||||||||
| 11 | 0 | my $self = { Indent => 0, Buf => "" }; | |||||||||||||||||||||||||||
| 12 | 0 | bless $self, $cls; | |||||||||||||||||||||||||||
| 13 | 0 | return $self; | |||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub print { | ||||||||||||||||||||||||||
|
Subroutine
print: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 18 | 0 | $self->{Buf} .= $IndentChar x $self->{Indent}; | |||||||||||||||||||||||||||
| 19 | 0 | my $fmt = shift @_; | |||||||||||||||||||||||||||
| 20 | 0 | $self->{Buf} .= sprintf($fmt, @_); | |||||||||||||||||||||||||||
| 21 | 0 | $self->{Buf} .= "\n"; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub fmt_ptr { | ||||||||||||||||||||||||||
|
Subroutine
fmt_ptr: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | shift @_ if @_ == 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 0 | my $s = ""; | |||||||||||||||||||||||||||
| 27 | 0 | my $ptr = $_[0]; | |||||||||||||||||||||||||||
| 28 | 0 | ▶ | if (ref $ptr || looks_like_number($ptr)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $ptr or &looks_like_number($ptr)
MC/DC0%0/2
ref $ptr or &looks_like_number($ptr)
ref $ptr
&looks_like_number($ptr)
Truth table0%0/3
A or B
A= ref $ptrB= &looks_like_number($ptr)
| |||||||||||||||||||||||||||||
| 29 | 0 | $s .= sprintf("[%d 0x%x]", $ptr+0, $ptr+0); | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if(ref $ptr) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 32 | 0 | $s .= sprintf(" SV=0x%x WEAK=%d ISA=%s", \$_[0], isweak($_[0]), ref $ptr); | |||||||||||||||||||||||||||
| 33 | } elsif(!looks_like_number($ptr)) { | ||||||||||||||||||||||||||||
| 34 | 0 | $s .= $ptr; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | 0 | return $s; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub flush { | ||||||||||||||||||||||||||
|
Subroutine
flush: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 40 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 41 | 0 | print $self->{Buf}; | |||||||||||||||||||||||||||
| 42 | 0 | $self->{Buf} = ""; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub iprint { | ||||||||||||||||||||||||||
|
Subroutine
iprint: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 46 | 0 | my ($self,@pargs) = @_; | |||||||||||||||||||||||||||
| 47 | 0 | $self->{Indent}++; | |||||||||||||||||||||||||||
| 48 | 0 | $self->print(@pargs); | |||||||||||||||||||||||||||
| 49 | 0 | $self->{Indent}--; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub hdr { | ||||||||||||||||||||||||||
|
Subroutine
hdr: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 53 | 0 | my ($self,@pargs) = @_; | |||||||||||||||||||||||||||
| 54 | 0 | my $old_indent = $self->{Indent}; | |||||||||||||||||||||||||||
| 55 | 0 | ▶ | $self->{Indent}-- if $old_indent; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 0 | $self->{Buf} .= "\n"; | |||||||||||||||||||||||||||
| 57 | 0 | $self->print(@pargs); | |||||||||||||||||||||||||||
| 58 | 0 | $self->{Buf} .= "\n"; | |||||||||||||||||||||||||||
| 59 | 0 | $self->{Indent}++; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub dump { | ||||||||||||||||||||||||||
|
Subroutine
dump: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 63 | 0 | my ($self,$table) = @_; | |||||||||||||||||||||||||||
| 64 | 0 | $self->hdr("Values"); | |||||||||||||||||||||||||||
| 65 | 0 | ▶ | while ( my($v,$rhash) = each %{$table->reverse}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 0 | $self->print("V: %s", $self->fmt_ptr($v)); | |||||||||||||||||||||||||||
| 67 | 0 | ▶ | while (my ($lk,$lo) = each %$rhash) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | $self->iprint("L: %s, %s", $lo->kstring, | ||||||||||||||||||||||||||||
| 69 | 0 | $self->fmt_ptr($rhash->{$lk})); | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | $self->hdr("Forward Lookups"); | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | while ( my ($k,$vobj) = each %{$table->forward}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 0 | $self->iprint("L: %s", $self->fmt_ptr($k)); | |||||||||||||||||||||||||||
| 78 | 0 | $self->{Indent}++; | |||||||||||||||||||||||||||
| 79 | 0 | $self->iprint("V: %s", $self->fmt_ptr($table->forward->{$k})); | |||||||||||||||||||||||||||
| 80 | 0 | $self->{Indent}--; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | $self->hdr("Scalar to key object mappings"); | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | while (my ($ustr,$ko) = each %{$table->scalar_lookup}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if(!defined $ko) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 0 | $self->iprint("UKEY=%s, KO=undef", $self->fmt_ptr($ustr)); | |||||||||||||||||||||||||||
| 88 | 0 | next; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | $self->iprint("UKEY=%s KO=%s", | ||||||||||||||||||||||||||||
| 91 | $self->fmt_ptr($ustr), | ||||||||||||||||||||||||||||
| 92 | 0 | $self->fmt_ptr($table->scalar_lookup->{$ustr})); | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if($ko->can("dump")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 0 | $self->{Indent}++; | |||||||||||||||||||||||||||
| 96 | 0 | $ko->dump($self); | |||||||||||||||||||||||||||
| 97 | 0 | $self->{Indent}--; | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 0 | $self->hdr("Attribute mappings"); | |||||||||||||||||||||||||||
| 102 | 0 | ▶ | while (my ($astr,$aobj) = each %{$table->attr_lookup}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | $self->iprint("ASTR=%s ATTR=%s", $astr, | ||||||||||||||||||||||||||||
| 104 | 0 | $self->fmt_ptr($table->attr_lookup->{$astr})); | |||||||||||||||||||||||||||
| 105 | 0 | ▶ | if($aobj->can("dump")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 0 | $self->{Indent}++; | |||||||||||||||||||||||||||
| 107 | 0 | $aobj->dump($self); | |||||||||||||||||||||||||||
| 108 | 0 | $self->{Indent}--; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 2 | 1; | |||||||||||||||||||||||||||