| 1 | package Pugs::Runtime::Tracer; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 36 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 36 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 36 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | #use Smart::Comments; | ||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 36 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||
| 9 | trace_begin trace_end trace | ||||||||||||||||||||||||||||||||
| 10 | expand_tracing_code | ||||||||||||||||||||||||||||||||
| 11 | ); | ||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | sub trace_begin ($$$$) { | ||||||||||||||||||||||||||||||
|
Subroutine
trace_begin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 14 | 1 | my ($name, $from, $to, $pos) = @_; | |||||||||||||||||||||||||||||||
| 15 | 1 | trace(">>BEGIN $name<< $from..$to at $pos\n"); | |||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | sub trace_end ($$$) { | ||||||||||||||||||||||||||||||
|
Subroutine
trace_end: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 19 | 2 | my ($name, $res, $pos) = @_; | |||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | trace(">>END $name<< ", $res ? 'success' : 'fail', " at $pos\n"); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | 5 | ▶ | sub trace ($@) { | ||||||||||||||||||||||||||||||
|
Subroutine
trace: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 24 | 5 | ▶ | if (!defined $::PCR_TRACE_FH) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 25 | 0 | $::PCR_TRACE_FH = \*STDOUT; | |||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||
| 27 | 5 | print $::PCR_TRACE_FH @_; | |||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 3 | ▶ | sub expand_tracing_code { | ||||||||||||||||||||||||||||||
|
Subroutine
expand_tracing_code: called CC=10 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 31 | 3 | my $s = shift; | |||||||||||||||||||||||||||||||
| 32 | 3 | ▶ | open my $in, '<', \$s or die; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 33 | 3 | my (@names, $name, $new, @has_pos); | |||||||||||||||||||||||||||||||
| 34 | 3 | ▶ | while (<$in>) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 35 | 15 | chomp; | |||||||||||||||||||||||||||||||
| 36 | 15 | ▶ | if (/\s+## <(\w+)>$/) { | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 37 | 7 | $name = $1; | |||||||||||||||||||||||||||||||
| 38 | 7 | push @names, $name; | |||||||||||||||||||||||||||||||
| 39 | 7 | push @has_pos, 0; | |||||||||||||||||||||||||||||||
| 40 | ### begin: $name | ||||||||||||||||||||||||||||||||
| 41 | 7 | $new .= $_ . "\n"; | |||||||||||||||||||||||||||||||
| 42 | } elsif (/(\s+)## pos: (\d+) (\d+)$/) { | ||||||||||||||||||||||||||||||||
| 43 | 1 | my ($tab, $from, $to) = ($1, $2, $3); | |||||||||||||||||||||||||||||||
| 44 | 1 | $has_pos[-1] = 1; | |||||||||||||||||||||||||||||||
| 45 | 1 | $new .= <<"_EOC_"; | |||||||||||||||||||||||||||||||
| 46 | $_ | ||||||||||||||||||||||||||||||||
| 47 | $tab do { | ||||||||||||||||||||||||||||||||
| 48 | $tab Pugs::Runtime::Tracer::trace_begin('$name', $from, $to, \$pos); | ||||||||||||||||||||||||||||||||
| 49 | $tab my \$retval = | ||||||||||||||||||||||||||||||||
| 50 | _EOC_ | ||||||||||||||||||||||||||||||||
| 51 | } elsif (/(\s+)## <\/(\w+)>$/) { | ||||||||||||||||||||||||||||||||
| 52 | 6 | my ($tab, $n) = ($1, $2); | |||||||||||||||||||||||||||||||
| 53 | 6 | $name = pop @names; | |||||||||||||||||||||||||||||||
| 54 | 6 | my $has_pos = pop @has_pos; | |||||||||||||||||||||||||||||||
| 55 | ### end: $n . "<=>" . $name | ||||||||||||||||||||||||||||||||
| 56 | 6 | ▶ | if (!defined $name || $n ne $name) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
not defined $name or $n ne $name
MC/DC50%1/2
not defined $name or $n ne $name
not defined $name
$n ne $name
Truth table66%2/3
not(A) or B
A= not defined $nameB= $n ne $name
| |||||||||||||||||||||||||||||||||
| 57 | 1 | die "ERROR: unexpected closing tag </$n>"; | |||||||||||||||||||||||||||||||
| 58 | } elsif ($has_pos) { | ||||||||||||||||||||||||||||||||
| 59 | 1 | $new .= <<"_EOC_"; | |||||||||||||||||||||||||||||||
| 60 | $_ | ||||||||||||||||||||||||||||||||
| 61 | $tab ; | ||||||||||||||||||||||||||||||||
| 62 | $tab Pugs::Runtime::Tracer::trace_end('$name', \$retval, \$pos); | ||||||||||||||||||||||||||||||||
| 63 | $tab \$retval; | ||||||||||||||||||||||||||||||||
| 64 | $tab } | ||||||||||||||||||||||||||||||||
| 65 | _EOC_ | ||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||
| 67 | 5 | ▶ | if (!$has_pos) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 68 | #warn "No pos info found for <$n>"; | ||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||
| 70 | } else { | ||||||||||||||||||||||||||||||||
| 71 | 1 | $new .= $_ . "\n"; | |||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | 2 | return $new; | |||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | 36 | 1; | |||||||||||||||||||||||||||||||
| 78 | __END__ | ||||||||||||||||||||||||||||||||