| 1 | package CljPerl::Printer; | ||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||
| 6 | 2 | our $VERSION = '0.10'; | |||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||
| 8 | 224 | ▶ | sub to_string { | ||||||||||||||||||||||||
|
Subroutine
to_string: called CC=21 SCAR=30.5
Pod
undocumented
| |||||||||||||||||||||||||||
| 9 | 224 | my $obj = shift; | |||||||||||||||||||||||||
| 10 | 224 | ▶ | return "" if !defined $obj; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 11 | 224 | my $class = $obj->class(); | |||||||||||||||||||||||||
| 12 | 224 | my $type = $obj->type(); | |||||||||||||||||||||||||
| 13 | 224 | my $s = ""; | |||||||||||||||||||||||||
| 14 | 224 | ▶ | if($class eq "Seq") { | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 15 | 41 | ▶ | if($type eq "vector") { | ||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||
| 16 | 8 | $s = "["; | |||||||||||||||||||||||||
| 17 | } elsif(($type eq "map")) { | ||||||||||||||||||||||||||
| 18 | 0 | $s = "{"; | |||||||||||||||||||||||||
| 19 | } else { | ||||||||||||||||||||||||||
| 20 | 33 | $s = "("; | |||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||
| 22 | 41 | foreach my $i (@{$obj->value()}) { | |||||||||||||||||||||||||
| 23 | 91 | $s .= to_string($i) . " "; | |||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||
| 25 | 41 | ▶ | if($type eq "vector") { | ||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||
| 26 | 8 | $s .= "]"; | |||||||||||||||||||||||||
| 27 | } elsif(($type eq "map")) { | ||||||||||||||||||||||||||
| 28 | 0 | $s .= "}"; | |||||||||||||||||||||||||
| 29 | } else { | ||||||||||||||||||||||||||
| 30 | 33 | $s .= ")"; | |||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||
| 32 | 41 | $s =~ s/ ([\)\]\}])$/$1/; | |||||||||||||||||||||||||
| 33 | } else { | ||||||||||||||||||||||||||
| 34 | 183 | ▶ | if($type eq "vector") { | ||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||
| 35 | 3 | $s = "["; | |||||||||||||||||||||||||
| 36 | 3 | foreach my $i (@{$obj->value()}) { | |||||||||||||||||||||||||
| 37 | 10 | $s .= to_string($i) . " "; | |||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||
| 39 | 3 | $s .= "]"; | |||||||||||||||||||||||||
| 40 | 3 | $s =~ s/ \]$/\]/; | |||||||||||||||||||||||||
| 41 | ▶ | } elsif($type eq "map" or $type eq "meta") { | |||||||||||||||||||||||||
|
Condition100%3/3
$type eq "map" or $type eq "meta"
MC/DC100%2/2
$type eq "map" or $type eq "meta"
$type eq "map"
$type eq "meta"
Truth table100%3/3
A or B
A= $type eq "map"B= $type eq "meta"
| |||||||||||||||||||||||||||
| 42 | 8 | $s = "{"; | |||||||||||||||||||||||||
| 43 | 8 | foreach my $i (keys %{$obj->value()}) { | |||||||||||||||||||||||||
| 44 | 9 | $s .= $i . "=>" . to_string($obj->value()->{$i}) . " "; | |||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||
| 46 | 8 | $s .= "}"; | |||||||||||||||||||||||||
| 47 | 8 | $s =~ s/ \}$/\}/; | |||||||||||||||||||||||||
| 48 | } elsif($type eq "xml") { | ||||||||||||||||||||||||||
| 49 | 6 | $s = "<"; | |||||||||||||||||||||||||
| 50 | 6 | $s .= $obj->{name}; | |||||||||||||||||||||||||
| 51 | 6 | ▶ | if(defined $obj->{meta}) { | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 52 | 1 | my %meta = %{$obj->meta()->value()}; | |||||||||||||||||||||||||
| 53 | 1 | foreach my $i (keys %meta) { | |||||||||||||||||||||||||
| 54 | 1 | $s .= " " . $i . "=\"" . to_string($meta{$i}) . "\""; | |||||||||||||||||||||||||
| 55 | }; | ||||||||||||||||||||||||||
| 56 | }; | ||||||||||||||||||||||||||
| 57 | 6 | $s .= ">"; | |||||||||||||||||||||||||
| 58 | 6 | foreach my $i (@{$obj->value()}) { | |||||||||||||||||||||||||
| 59 | 7 | $s .= to_string($i) . " "; | |||||||||||||||||||||||||
| 60 | }; | ||||||||||||||||||||||||||
| 61 | 6 | $s .= "</" . $obj->{name} . ">"; | |||||||||||||||||||||||||
| 62 | ▶ | } elsif($type eq "function" or $type eq "macro") { | |||||||||||||||||||||||||
|
Condition66%2/3
$type eq "function" or $type eq "macro"
MC/DC50%1/2
$type eq "function" or $type eq "macro"
$type eq "function"
$type eq "macro"
Truth table66%2/3
A or B
A= $type eq "function"B= $type eq "macro"
| |||||||||||||||||||||||||||
| 63 | 2 | $s = to_string($obj->value()); | |||||||||||||||||||||||||
| 64 | } elsif($type eq "exception") { | ||||||||||||||||||||||||||
| 65 | 2 | $s = "exception: "; | |||||||||||||||||||||||||
| 66 | 2 | $s .= $obj->{label} . " - "; | |||||||||||||||||||||||||
| 67 | 2 | $s .= $obj->value(); | |||||||||||||||||||||||||
| 68 | 2 | foreach my $c (@{$obj->{caller}}){ | |||||||||||||||||||||||||
| 69 | 3 | $s .= "\n\t" . to_string($c); | |||||||||||||||||||||||||
| 70 | 3 | $s .= "["; | |||||||||||||||||||||||||
| 71 | 3 | $s .= "file:" . $c->{pos}->{filename} . "; "; | |||||||||||||||||||||||||
| 72 | 3 | $s .= "line:" . $c->{pos}->{line} . "; "; | |||||||||||||||||||||||||
| 73 | 3 | $s .= "col:" . $c->{pos}->{col} . ";"; | |||||||||||||||||||||||||
| 74 | 3 | $s .= "]"; | |||||||||||||||||||||||||
| 75 | }; | ||||||||||||||||||||||||||
| 76 | } else { | ||||||||||||||||||||||||||
| 77 | 162 | $s = $obj->value(); | |||||||||||||||||||||||||
| 78 | }; | ||||||||||||||||||||||||||
| 79 | }; | ||||||||||||||||||||||||||
| 80 | 224 | return $s; | |||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||
| 83 | 2 | 1; | |||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||