| 1 | package Outthentic::DSL::Context::TextBlock; | ||||||||||||||
| 2 | 2 | ▶ | use Data::Dumper; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | |||||||||||||||
| 4 | |||||||||||||||
| 5 | 0 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 0 | bless { succeeded => [] }, __PACKAGE__ | |||||||||||||
| 8 | } | ||||||||||||||
| 9 | |||||||||||||||
| 10 | 0 | ▶ | sub change_context { | ||||||||||||
|
Subroutine
change_context: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||
| 11 | |||||||||||||||
| 12 | 0 | my $self = shift; | |||||||||||||
| 13 | 0 | my $cur_ctx = shift; # current search context | |||||||||||||
| 14 | 0 | my $orig_ctx = shift; # original search context | |||||||||||||
| 15 | 0 | my $succ = shift; # latest succeeded items | |||||||||||||
| 16 | |||||||||||||||
| 17 | #warn Dumper($cur_ctx); | ||||||||||||||
| 18 | #warn Dumper($succ); | ||||||||||||||
| 19 | |||||||||||||||
| 20 | 0 | my $new_ctx = []; # new context | |||||||||||||
| 21 | |||||||||||||||
| 22 | 0 | ▶ | if (scalar @{$succ}){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 23 | |||||||||||||||
| 24 | 0 | for my $c (@{$succ}){ | |||||||||||||
| 25 | 0 | ▶ | push @$new_ctx, $orig_ctx->[$c->[1]] if defined($orig_ctx->[$c->[1]]); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 26 | } | ||||||||||||||
| 27 | }else{ | ||||||||||||||
| 28 | 0 | $new_ctx = $cur_ctx; | |||||||||||||
| 29 | } | ||||||||||||||
| 30 | |||||||||||||||
| 31 | 0 | $new_ctx; | |||||||||||||
| 32 | |||||||||||||||
| 33 | } | ||||||||||||||
| 34 | |||||||||||||||
| 35 | |||||||||||||||
| 36 | 0 | ▶ | sub update_stream { | ||||||||||||
|
Subroutine
update_stream: not called CC=21 SCAR=60.3
Pod
undocumented
| |||||||||||||||
| 37 | |||||||||||||||
| 38 | 0 | ▶ | print "\n\nxxxx start of text block update stream \n \n \n" if $ENV{OUTH_DBG}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 39 | |||||||||||||||
| 40 | 0 | my $self = shift; | |||||||||||||
| 41 | 0 | my $cur_ctx = shift; # current search context | |||||||||||||
| 42 | 0 | my $orig_ctx = shift; # original search context | |||||||||||||
| 43 | 0 | my $succ = shift; # latest succeeded items | |||||||||||||
| 44 | 0 | my $stream_ref = shift; # reference to stream object to update | |||||||||||||
| 45 | |||||||||||||||
| 46 | 2 | ▶ | use Data::Dumper; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 47 | |||||||||||||||
| 48 | 0 | my %live_chains = (); | |||||||||||||
| 49 | |||||||||||||||
| 50 | |||||||||||||||
| 51 | 0 | ▶ | if (scalar @{$succ}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 52 | |||||||||||||||
| 53 | 0 | ▶ | unless ($self->{chains}){ # chain initialization | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 54 | 0 | for my $c ( @{$succ} ){ | |||||||||||||
| 55 | 0 | ▶ | print "[OTX_DEBUG] init chain $c[0]($c[1]) )...\n" if $ENV{OUTH_DBG}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 56 | 0 | $self->{chains}->{$c->[1]} = [$c]; | |||||||||||||
| 57 | } | ||||||||||||||
| 58 | }; | ||||||||||||||
| 59 | |||||||||||||||
| 60 | |||||||||||||||
| 61 | |||||||||||||||
| 62 | 0 | for my $c (@{$succ}){ | |||||||||||||
| 63 | 0 | my @k = keys %{$self->{chains}}; | |||||||||||||
| 64 | 0 | CHAIN: for my $cid (sort { $a <=> $b } @k ){ | |||||||||||||
| 65 | |||||||||||||||
| 66 | 0 | ▶ | next CHAIN if $live_chains{$cid}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 67 | |||||||||||||||
| 68 | 0 | ▶ | print "[OTX_DEBUG] chain end at ".($self->{chains}->{$cid}->[-1]->[1])."\n" if $ENV{OUTH_DBG}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 69 | |||||||||||||||
| 70 | 0 | ▶ | if ( $self->{chains}->{$cid}->[-1]->[1] == $c->[1]-1 ){ | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 71 | 0 | $live_chains{$cid} = 1; | |||||||||||||
| 72 | 0 | push @{$self->{chains}->{$cid}}, $c; | |||||||||||||
| 73 | 0 | ▶ | print "[OTX_DEBUG] push $c->[0]($c->[1]) to chain $cid ...\n" if $ENV{OUTH_DBG}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 74 | 0 | ▶ | print "[OTX_DEBUG] new chain end at ".($self->{chains}->{$cid}->[-1]->[0])."\n" if $ENV{OUTH_DBG}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 75 | 0 | last CHAIN; | |||||||||||||
| 76 | }elsif ( $self->{chains}->{$cid}->[-1]->[1] == $c->[1] ) { | ||||||||||||||
| 77 | 0 | $live_chains{$cid} = 1; | |||||||||||||
| 78 | 0 | ▶ | print "[OTX_DEBUG] keep chain $cid ...\n" if $ENV{OUTH_DBG}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 79 | 0 | last CHAIN; | |||||||||||||
| 80 | }else{ | ||||||||||||||
| 81 | 0 | ▶ | print "[OTX_DEBUG] skip $c->[0] [ $c->[1] ] ...\n" if $ENV{OUTH_DBG}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 82 | } | ||||||||||||||
| 83 | } | ||||||||||||||
| 84 | } | ||||||||||||||
| 85 | } | ||||||||||||||
| 86 | |||||||||||||||
| 87 | #warn Dumper([sort { $a <=> $b } keys %live_chains]) if $ENV{OUTH_DBG}; | ||||||||||||||
| 88 | |||||||||||||||
| 89 | # delete failed chains | ||||||||||||||
| 90 | |||||||||||||||
| 91 | 0 | ${$stream_ref} = {}; | |||||||||||||
| 92 | |||||||||||||||
| 93 | 0 | ▶ | print "\n\nxxxx generating text block stream xxxx \n \n \n" if $ENV{OUTH_DBG}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 94 | |||||||||||||||
| 95 | 0 | for my $cid (sort { $a <=> $b } keys %{$self->{chains}}){ | |||||||||||||
| 96 | 0 | ▶ | if ($live_chains{$cid}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 97 | 0 | ${$stream_ref}->{$cid} = $self->{chains}->{$cid}; | |||||||||||||
| 98 | 0 | ▶ | print "[OTX_DEBUG] chain end at ".($self->{chains}->{$cid}->[-1]->[1])."\n" if $ENV{OUTH_DBG}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 99 | } else { | ||||||||||||||
| 100 | 0 | delete @{$self->{chains}}{$cid}; | |||||||||||||
| 101 | } | ||||||||||||||
| 102 | } | ||||||||||||||
| 103 | |||||||||||||||
| 104 | 0 | ▶ | print "\n\nxxxx end of text block update stream \n \n \n" if $ENV{OUTH_DBG}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 105 | |||||||||||||||
| 106 | } | ||||||||||||||
| 107 | |||||||||||||||
| 108 | |||||||||||||||
| 109 | 2 | 1; | |||||||||||||
| 110 | |||||||||||||||