| 1 | package YATT::Lite::CGen; sub MY () {__PACKAGE__} | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 74 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 74 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 74 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 74 | ▶ | use constant DEBUG_REBUILD => $ENV{DEBUG_YATT_REBUILD}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 74 | ▶ | use YATT::Lite::Util::AsBase qw/-as_base import/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 74 | ▶ | use base qw(YATT::Lite::VarMaker); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 74 | ▶ | use YATT::Lite::MFields qw/_curtmpl _curwidget _curtoks | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | _altgen _needs_escaping _depth | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | cgen_loader | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | only_parse | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | no_lineinfo check_lineno | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | yatt_no_last_newline | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | vfs parser sink | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | _scope | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | lcmsg_sink | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | prefer_call_for_entity | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | no_conditional_call | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | pagevars | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | / | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 74 | ; | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 74 | ▶ | use YATT::Lite::Core qw(Template Part Folder); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 74 | ▶ | use YATT::Lite::Constants; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 74 | ▶ | use YATT::Lite::Util qw(callerinfo numLines); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 589 | ▶ | sub ensure_generated_for_folders { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_generated_for_folders: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 589 | (my MY $self, my $spec) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 32 | 589 | foreach my Folder $folder (@_) { | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | 605 | ▶ | if ($folder->can_generate_code) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 35 | $self->ensure_generated($spec, $folder); | |||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 880 | ▶ | sub ensure_generated { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_generated: called CC=11 SCAR=25.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 880 | (my MY $self, my $spec, my Template $tmpl) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | 880 | ▶ | my ($type, $kind) = ref $spec ? @$spec : $spec; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 880 | ▶ | $self->{vfs}->error(q{sink is empty}) unless $self->{sink}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 880 | ▶ | return if defined $tmpl->{_product}{$type}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 581 | ▶ | local $self->{_depth} = 1 + ($self->{_depth} // 0); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"_depth"} // 0
MC/DC100%1/1
$self->{"_depth"} // 0
$self->{"_depth"}
Truth table100%2/2
A
A= $self->{"_depth"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 581 | my $pkg = $tmpl->{_product}{$type} = $tmpl->{entns}; | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | 581 | ▶ | if (not defined $tmpl->{_product}{$type}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | croak "package for product $type of $tmpl->{path} is not defined!"; | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | print STDERR "# generating $pkg for $type code of " | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 581 | . ($tmpl->{path} // "(undef)") . "\n" | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | if DEBUG_REBUILD; | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | $self->{parser}->parse_body($tmpl) | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | if not $kind or not $self->{only_parse} | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 581 | ▶ | or $self->{only_parse}{$kind}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not $kind && $self->{"only_parse"} or $self->{"only_parse"}{$kind}
$kind && $self->{'only_parse'}
MC/DC0%0/3
not $kind && $self->{"only_parse"} or $self->{"only_parse"}{$kind}
$kind
$self->{'only_parse'}
$self->{"only_parse"}{$kind}
Truth table25%1/4
not(A && B) or C
A= $kindB= $self->{'only_parse'}C= $self->{"only_parse"}{$kind}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 572 | $self->setup_inheritance_for($spec, $tmpl); | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | # <!yatt:import> のソースも先に generate しておく。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # (子の glob 代入が eval される時点でソース側の sub が必要) GH-256 | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 572 | ▶ | if (my @import_srcs = $tmpl->list_import_sources) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 17 | $self->ensure_generated_for_folders($spec, @import_srcs); | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 572 | my @res = $self->generate($tmpl, $kind); | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | 506 | ▶ | if (my $sub = $self->{sink}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | $sub->({folder => $tmpl, package => $pkg, kind => 'body' | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | , depth => $self->{_depth}} | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 506 | , @res); | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 504 | $pkg; | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 79 | ▶ | sub with_template { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
with_template: called CC=4 SCAR=14.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 79 | (my MY $self, my Template $tmpl, my ($task, @args)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | 79 | local $self->{_curtmpl} = $tmpl; | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | 79 | local $self->{_curline} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | 79 | ▶ | if (ref $task eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 48 | $task->($self, @args); | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 31 | my ($meth, @rest) = YATT::Lite::Util::lexpand($task); | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | 31 | ▶ | unless ($meth) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | Carp::croak "meth is undef"; | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 31 | ▶ | my $sub = $self->can($meth) or do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | Carp::croak "No such method $meth"; | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 31 | $sub->($self, @rest, @args); | |||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 572 | ▶ | sub generate { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate: called CC=5 SCAR=17.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 572 | (my MY $self, my Template $tmpl) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | 572 | ▶ | my $kind = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # XXX: Rewrite this with with_template | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 572 | local $self->{_curtmpl} = $tmpl; | |||||||||||||||||||||||||||||||||||||||||||||
| 94 | 572 | local $self->{_curline} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | 572 | local $self->{_scope} = $self->generate_page_scope($tmpl); | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | ($self->generate_preamble($self->{_curtmpl}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | , map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 882 | my Part $part = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | 882 | ▶ | if (not $kind or not $self->{only_parse} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not $kind && $self->{"only_parse"} or $kind eq $part->{"kind"}
$kind && $self->{'only_parse'}
MC/DC0%0/3
not $kind && $self->{"only_parse"} or $kind eq $part->{"kind"}
$kind
$self->{'only_parse'}
$kind eq $part->{"kind"}
Truth table25%1/4
not(A && B) or C
A= $kindB= $self->{'only_parse'}C= $kind eq $part->{"kind"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | or $kind eq $part->{kind}) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 882 | $self->generate_part($tmpl, $part); | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | (); | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 572 | } @{$tmpl->{_partlist}}); | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 882 | ▶ | sub generate_part { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_part: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 882 | (my MY $self, my Template $tmpl, my Part $part) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | my $sub = $self->can("generate_$part->{kind}") | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | or die $self->generror("Can't generate part type: '%s'" | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 882 | ▶ | , $part->{kind}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 882 | local $self->{yatt_no_last_newline} = $part->{yatt_no_last_newline}; | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | 882 | $sub->($self, $part, $part->{name}, $tmpl->{path}); | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | sub generate_page_scope { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_page_scope: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | +{} | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub setup_inheritance_for { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_inheritance_for: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | (my MY $self, my $spec, my Template $tmpl) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $self->ensure_generated_for_folders($spec, $tmpl->list_base); | |||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 488 | ▶ | sub altgen { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
altgen: called CC=3 SCAR=11.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 488 | (my MY $self, my $ns) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | # ns 一つに付き 高々 1回しか、can しないで済むように... と言っても、cgen 自体が複数個作られたら.. | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 488 | ▶ | unless (exists $self->{_altgen}{$ns}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 304 | $self->{_altgen}{$ns} = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | 304 | ▶ | if (my $sub = $self->can("create_altgen_$ns")) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # 毎回, new し直す。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $sub->($self)->generate_node(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 488 | $self->{_altgen}{$ns}; | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub create_altgen_js { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_altgen_js: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | require YATT::Lite::CGen::JS; | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my MY $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | new YATT::Lite::CGen::JS | |||||||||||||||||||||||||||||||||||||||||||||
| 146 | ($self->cf_delegate(qw(vfs parser no_lineinfo check_lineno))); | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1433 | ▶ | sub find_var { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_var: called CC=6 SCAR=18.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1433 | (my MY $self, my $varName, my $check) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1433 | ▶ | confess "Undefined varName for find_var!" unless defined $varName; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 1433 | ▶ | for (my $scope = $self->{_scope}; $scope; $scope = $scope->[1]) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 5811 | ▶ | if (defined (my $var = $scope->[0]{$varName})) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 673 | ▶ | next if $check and not $check->($var); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$check and not &$check($var)
MC/DC0%0/2
$check and not &$check($var)
$check
not &$check($var)
Truth table66%2/3
A and not(B)
A= $checkB= not &$check($var)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 673 | return $var; | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 732 | ▶ | sub find_callable_var { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_callable_var: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 732 | (my MY $self, my $varName) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 161 | 732 | ▶ | $self->find_var($varName, sub {shift->callable}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 317 | ▶ | sub lookup_widget { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_widget: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 317 | (my MY $self, my ($ns, @path)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 165 | # ns 抜きと、有りで一回ずつ検索する | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | $self->{vfs}->find_part_from($self->{_curtmpl}, @path) | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 317 | ▶ | || $self->{vfs}->find_part_from($self->{_curtmpl}, $ns, @path); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 53 | ▶ | sub generror { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generror: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 53 | my MY $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 172 | 53 | my Template $tmpl = $self->{_curtmpl}; | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | 53 | my ($pkg, $file, $line) = caller; | |||||||||||||||||||||||||||||||||||||||||||||
| 174 | 53 | my %opts = ($self->_tmpl_file_line($self->{_curline}), callerinfo()); | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | 53 | $self->_error(\%opts, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # generror の行番号指定版 (LRXML の synerror_at に相当)。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # 例: die $cgen->generror_at($node->[NODE_LNO], ...) | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 12 | ▶ | sub generror_at { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generror_at: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 12 | (my MY $self, my $ln) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | 12 | ▶ | my %opts = ($self->_tmpl_file_line($ln // $self->{_curline}), callerinfo()); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ln // $self->{"_curline"}
MC/DC0%0/2
$ln // $self->{"_curline"}
$ln
$self->{"_curline"}
Truth table33%1/3
A // B
A= $lnB= $self->{"_curline"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 12 | $self->_error(\%opts, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 65 | ▶ | sub _error { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_error: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 65 | my MY $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 186 | 65 | $self->{vfs}->error(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 65 | ▶ | sub _tmpl_file_line { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tmpl_file_line: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 65 | (my MY $self, my $ln) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 190 | 65 | my Template $tmpl = $self->{_curtmpl}; | |||||||||||||||||||||||||||||||||||||||||||||
| 191 | (tmpl_file => $tmpl->{path} // $tmpl->{name} | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 65 | ▶ | , defined $ln ? (tmpl_line => $ln) : ()); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$tmpl->{"path"} // $tmpl->{"name"}
MC/DC0%0/2
$tmpl->{"path"} // $tmpl->{"name"}
$tmpl->{"path"}
$tmpl->{"name"}
Truth table66%2/3
A // B
A= $tmpl->{"path"}B= $tmpl->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 198 | ▶ | sub add_curline { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_curline: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 198 | (my MY $self, my $text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 197 | 198 | $self->{_curline} += numLines($text); | |||||||||||||||||||||||||||||||||||||||||||||
| 198 | 198 | $text; | |||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 4532 | ▶ | sub sync_curline { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sync_curline: called CC=6 SCAR=18.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 4532 | (my MY $self, my $lineno) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 203 | 4532 | ▶ | return unless defined $lineno; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 3895 | my $diff = $lineno - $self->{_curline}; | |||||||||||||||||||||||||||||||||||||||||||||
| 205 | 3895 | ▶ | die "curline exceeds expected lineno! expect $lineno, curline=$self->{_curline}\n" if $self->{check_lineno} and $diff < 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"check_lineno"} and $diff < 0
MC/DC0%0/2
$self->{"check_lineno"} and $diff < 0
$self->{"check_lineno"}
$diff < 0
Truth table33%1/3
A and B
A= $self->{"check_lineno"}B= $diff < 0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 3895 | ▶ | $self->{_curline} = $lineno if $lineno > $self->{_curline}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 3895 | ▶ | $diff > 0 ? "\n" x $diff : (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # <!yatt:widget ...> や <yatt:call ...> の直後の改行を, | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # ソース上のみの(出力しない)改行に変換する。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1518 | ▶ | sub cut_next_nl { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cut_next_nl: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 1518 | my MY $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 213 | # undef は返したくないので。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | return wantarray ? () : '' | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | unless $self->{_curtoks} | ||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 1518 | ▶ | and @{$self->{_curtoks}} and $self->{_curtoks}[0] =~ /^\r?\n$/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%6/6
$self->{"_curtoks"} and @{$self->{"_curtoks"};} and $self->{"_curtoks"}[0] =~ /^\r?\n$/
$self->{"_curtoks"} and @{$self->{"_curtoks"};}
MC/DC100%3/3
$self->{"_curtoks"} and @{$self->{"_curtoks"};} and $self->{"_curtoks"}[0] =~ /^\r?\n$/
$self->{"_curtoks"}
@{$self->{"_curtoks"};}
$self->{"_curtoks"}[0] =~ /^\r?\n$/
Truth table100%4/4
A and B and C
A= $self->{"_curtoks"}B= @{$self->{"_curtoks"};}C= $self->{"_curtoks"}[0] =~ /^\r?\n$/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | return wantarray ? () : '' | ||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 449 | ▶ | if @{$self->{_curtoks}} == 1; # 最後の一個の改行は、残す。これは "}\n" のため | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 189 | $self->{_curline}++; | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | 189 | shift @{$self->{_curtoks}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 1040 | ▶ | sub mkscope { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mkscope: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 1040 | my MY $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | 1040 | ▶ | return unless @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 1040 | ▶ | my $scope = ref $_[-1] eq 'ARRAY' ? pop : [pop]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 1040 | ▶ | while (@_) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 3603 | $scope = [pop, $scope]; | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1040 | $scope; | |||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | sub terse_dump { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
terse_dump: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my MY $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | YATT::Lite::Util::terse_dump(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | sub node_sync_curline { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
node_sync_curline: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | (my MY $self, my $node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $self->sync_curline($node->[NODE_LNO]); | |||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 74 | 1; | |||||||||||||||||||||||||||||||||||||||||||||