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