| 1 | # -*- mode: perl; coding: utf-8 -*- | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 3 | ▶ | package YATT::Translator::Perl; use YATT::Inc; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | our %TYPE_MAP; | |||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use base qw(YATT::Registry); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use YATT::Fields [cf_mode => 'render'] | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | , [cf_product => sub {[]}] | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | , qw(target_cache | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | delayed_target | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | generating_widget | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | cf_pagevars | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | cf_debug_translator); | |||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | ▶ | BEGIN {require Exporter; *import = \&Exporter::import} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | our @EXPORT_OK = qw(qqvalue qparen); | |||||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | our @EXPORT = @EXPORT_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | ▶ | use YATT::Registry::NS; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | use YATT::Widget; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | ▶ | use YATT::Util qw(checked_eval add_arg_order_in terse_dump coalesce); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | ▶ | use YATT::LRXML::Node qw(node_path node_body node_name | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | node_size node_flag | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | node_children | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | create_node | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | stringify_node | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | TEXT_TYPE ELEMENT_TYPE ENTITY_TYPE); | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | ▶ | use YATT::LRXML::EntityPath; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 3 | ▶ | use YATT::Util::Taint; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 3 | ▶ | use YATT::Util::Symbol qw(declare_alias); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 3 | require YATT::ArgMacro; | |||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | sub qqvalue ($); | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | sub qparen ($); | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 14 | ▶ | sub after_configure { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_configure: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 14 | my MY $trans = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 14 | $trans->SUPER::after_configure; | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | 14 | ▶ | $trans->{cf_type_map} ||= \%TYPE_MAP; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$trans->{"cf_type_map"} ||= \%YATT::Translator::Perl::TYPE_MAP
MC/DC0%0/1
$trans->{"cf_type_map"} ||= \%YATT::Translator::Perl::TYPE_MAP
$trans->{"cf_type_map"}
Truth table50%1/2
A
A= $trans->{"cf_type_map"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 142 | ▶ | sub emit { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emit: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 142 | my MY $gen = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | 142 | my $script = join "", @{$gen->{cf_product}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | 142 | $gen->{cf_product} = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | 142 | $script; | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 31 | ▶ | sub call_handler { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
call_handler: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 31 | (my MY $trans, my ($method, $widget_path)) = splice @_, 0, 3; | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | 31 | ▶ | my ($handler, $pkg) = $trans->get_handler_to | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ($method, ref $widget_path ? @$widget_path : split /[:\.]/, $widget_path); | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 11 | &YATT::break_handler; | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | 11 | $handler->($pkg, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 161 | ▶ | sub parse_elempath { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_elempath: called CC=5 SCAR=18.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 161 | my ($pack, @elpath) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | 161 | ▶ | if (@elpath == 1) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 142 | ▶ | if (ref $elpath[0]) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | @elpath = @{$elpath[0]}; | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 142 | @elpath = split '/', $elpath[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # root dir should be ignored. | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 161 | ▶ | shift @elpath if !defined $elpath[0] || $elpath[0] eq ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $elpath[0] or $elpath[0] eq ""
MC/DC0%0/2
not defined $elpath[0] or $elpath[0] eq ""
not defined $elpath[0]
$elpath[0] eq ""
Truth table33%1/3
not(A) or B
A= not defined $elpath[0]B= $elpath[0] eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 161 | @elpath; | |||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 161 | ▶ | sub get_handler_to { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_handler_to: called CC=4 SCAR=15.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 161 | (my MY $trans, my ($method)) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | 161 | my @elpath = $trans->parse_elempath(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 161 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | 161 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 161 | @result = $trans->lookup_handler_to($method, @elpath); | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $result[0] = $trans->lookup_handler_to($method, @elpath); | |||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 141 | ▶ | unless (@result) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | croak "Can't find widget: " . join(":", @elpath); | |||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 141 | ▶ | wantarray ? @result : $result[0]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 161 | ▶ | sub lookup_handler_to { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_handler_to: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 161 | (my MY $trans, my ($method, @elpath)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 161 | $trans->{cf_mode} = $method; # XXX: local | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | 161 | @{$trans->{cf_product}} = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 161 | ▶ | my Widget $widget = $trans->get_widget(@elpath) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 156 | $trans->ensure_widget_is_generated($widget); | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | 142 | ▶ | if (my $script = $trans->emit) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 117 | ▶ | print STDERR $script if $trans->{cf_debug_translator}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 117 | $trans->checked_eval | |||||||||||||||||||||||||||||||||||||||||||||
| 116 | (join(";" | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | , 'use strict' | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | , 'use warnings FATAL => qw(all)' | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # XXX: 何が redefine されるかは分からないから… | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | , 'no warnings "redefine"' | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | , untaint_any($script))); | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 141 | my ($pkg, $funcname) = $trans->get_funcname_to($method, $widget); | |||||||||||||||||||||||||||||||||||||||||||||
| 125 | 141 | my $handler = $pkg->can($funcname); | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 141 | ▶ | return $handler unless wantarray; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 141 | ($handler | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | , scalar $trans->get_package_from_widget($widget) | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | , $widget); | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 436 | ▶ | sub get_funcname_to { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_funcname_to: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 436 | (my MY $trans, my ($mode), my Widget $widget) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | 436 | my $pkg = $trans->get_package_from_widget($widget); | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | 436 | my $fname = "${mode}_$$widget{cf_name}"; | |||||||||||||||||||||||||||||||||||||||||||||
| 137 | 436 | ▶ | wantarray ? ($pkg, $fname) : join("::", $pkg, $fname); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 593 | ▶ | sub get_package_from_widget { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_package_from_widget: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 593 | (my MY $trans, my Widget $widget) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 142 | my $primary = $trans->get_package | ||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 593 | (my Template $tmpl = $trans->nsobj($widget->{cf_template_nsid})); | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 593 | ▶ | return $primary unless wantarray; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 16 | ($primary, $trans->get_rc_package_from_template($tmpl)); | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 153 | ▶ | sub get_rc_package_from_template { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_rc_package_from_template: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 153 | (my MY $trans, my Template $tmpl) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | 153 | $trans->get_package($trans->nsobj($tmpl->{cf_parent_nsid})); | |||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | #---------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | sub generate { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my MY $gen = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | foreach my $elempath (@_) { | |||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if (my $widget = $gen->get_widget(@$elempath)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | $gen->ensure_widget_is_generated($widget); | |||||||||||||||||||||||||||||||||||||||||||||
| 161 | } elsif (my $ns = $gen->get_ns($elempath)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $gen->ensure_ns_is_generated($ns); | |||||||||||||||||||||||||||||||||||||||||||||
| 163 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | croak "Invalid widget path: " . join(":", @$elempath); | |||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $gen->emit; | |||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | sub mark_delayed_target { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mark_delayed_target: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | (my MY $gen, my Widget $widget) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $gen->{delayed_target}{$widget->{cf_template_nsid}}++; | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 243 | ▶ | sub ensure_widget_is_generated { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_widget_is_generated: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 243 | (my MY $gen, my Widget $widget) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | 243 | $gen->ensure_template_is_generated($widget->{cf_template_nsid}); | |||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 246 | ▶ | sub ensure_template_is_generated { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_template_is_generated: called CC=7 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # (my MY $gen, my $tmplid) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # $tmplid = $tmplid->cget('nsid') if ref $tmplid; | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 246 | (my MY $gen, my $id_or_obj) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 184 | 246 | (my $tmplid, my Template $tmpl) = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 185 | 246 | ▶ | if (ref $id_or_obj) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ($id_or_obj->cget('nsid'), $id_or_obj) | |||||||||||||||||||||||||||||||||||||||||||||
| 187 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 246 | ($id_or_obj, $gen->nsobj($id_or_obj)); | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 246 | ▶ | if (my $baseid = $tmpl->{cf_base_template}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 3 | $gen->ensure_template_is_generated($baseid); | |||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 246 | ▶ | unless ($gen->{target_cache}{$tmplid}++) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # eval は? | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 141 | push @{$$gen{cf_product}} | |||||||||||||||||||||||||||||||||||||||||||||
| 198 | , $gen->generate_template($gen->nsobj($tmplid)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 232 | ▶ | if (my @delayed = keys %{$gen->{delayed_target}}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | foreach my $nsid (@delayed) { | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | next if $gen->{target_cache}{$nsid}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | delete $gen->{delayed_target}{$nsid}; | |||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $gen->ensure_template_is_generated($nsid); | |||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 146 | ▶ | sub forget_template { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
forget_template: called CC=3 SCAR=11.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 146 | (my MY $gen, my $tmplid) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 211 | 146 | ▶ | $tmplid = $tmplid->cget('nsid') if ref $tmplid; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 146 | ▶ | delete $gen->{target_cache}{$tmplid} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 3 | my %calling_conv; | |||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 141 | ▶ | sub generate_template { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_template: called CC=6 SCAR=18.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 141 | (my MY $gen, my Template $tmpl) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 219 | print STDERR "Generate: $tmpl->{cf_loadkey}\n" | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 141 | ▶ | if $gen->{cf_debug_translator}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 141 | my $metainfo = $tmpl->metainfo; | |||||||||||||||||||||||||||||||||||||||||||||
| 222 | my @use = map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 141 | ▶ | unless (defined $_) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | () | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 141 | } else { | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | map {"use $_;"} ref $_ ? @$_ : $_ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 141 | } $gen->{cf_use}; | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | 141 | my @file_scope = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 230 | 141 | ▶ | if ($gen->{cf_pagevars}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | $gen->checked_eval(qq{require $gen->{cf_pagevars}}); | |||||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | push @use, "use $gen->{cf_pagevars} (qw($tmpl->{cf_name}), 1);"; | |||||||||||||||||||||||||||||||||||||||||||||
| 233 | ($gen->{cf_pagevars}->build_scope_for($gen, $tmpl->{cf_name}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 1 | , [\%calling_conv]); | |||||||||||||||||||||||||||||||||||||||||||||
| 235 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 140 | \%calling_conv; | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 238 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 141 | my @script; | |||||||||||||||||||||||||||||||||||||||||||||
| 240 | 141 | foreach my $widget (@{$tmpl->widget_list}) { | |||||||||||||||||||||||||||||||||||||||||||||
| 241 | 220 | push @script, $gen->generate_widget($widget, $metainfo, \@file_scope); | |||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 127 | join("", q{package } . $gen->get_package($tmpl) . ';' | |||||||||||||||||||||||||||||||||||||||||||||
| 244 | , join("",@use) | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | , @script); | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 406 | ▶ | sub generate_lineinfo { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_lineinfo: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 406 | (my MY $gen, my Widget $widget, my ($start, $prefix)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 250 | 406 | ▶ | return if $gen->{cf_no_lineinfo}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 251 | sprintf qq{%s#line %d "%s"\n}, $prefix || '' | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 50 | ▶ | , $start, $widget->{cf_filename}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$prefix || ''
MC/DC100%1/1
$prefix || ''
$prefix
Truth table100%2/2
A
A= $prefix
| |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | sub generating_widget { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generating_widget: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my MY $gen = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $gen->{generating_widget}[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 220 | ▶ | sub generate_widget { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_widget: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 220 | (my MY $gen, my Widget $widget, my ($metainfo, $file_scope)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 262 | 220 | local $gen->{generating_widget}[0] = $widget; | |||||||||||||||||||||||||||||||||||||||||||||
| 263 | my @body = $gen->generate_body | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | ([{}, $widget->widget_scope($file_scope)] | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | , $widget->cursor(metainfo => $metainfo->clone | ||||||||||||||||||||||||||||||||||||||||||||||
| 266 | (startline => $widget->{cf_body_start} | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 220 | , caller_widget => $widget))); | |||||||||||||||||||||||||||||||||||||||||||||
| 268 | # body が空の場合もありうる。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 206 | ▶ | return unless @body; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 203 | my ($pkg, $funcname) = $gen->get_funcname_to($gen->{cf_mode}, $widget); | |||||||||||||||||||||||||||||||||||||||||||||
| 271 | join("" | ||||||||||||||||||||||||||||||||||||||||||||||
| 272 | , $gen->generate_lineinfo($widget, $widget->{cf_decl_start}, "\n") | ||||||||||||||||||||||||||||||||||||||||||||||
| 273 | , $gen->generate_getargs($widget, $metainfo) | ||||||||||||||||||||||||||||||||||||||||||||||
| 274 | , $gen->generate_lineinfo($widget, $widget->{cf_body_start}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 203 | , $gen->as_sub | |||||||||||||||||||||||||||||||||||||||||||||
| 276 | ($funcname | ||||||||||||||||||||||||||||||||||||||||||||||
| 277 | , $gen->genprolog($widget) | ||||||||||||||||||||||||||||||||||||||||||||||
| 278 | , $gen->as_statement_list(@body)) | ||||||||||||||||||||||||||||||||||||||||||||||
| 279 | , "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 203 | ▶ | sub generate_getargs { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_getargs: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 203 | (my MY $gen, my Widget $widget, my ($metainfo)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 284 | 203 | $gen->as_sub("getargs_$$widget{cf_name}", sprintf q{ | |||||||||||||||||||||||||||||||||||||||||||||
| 285 | my ($call) = shift; | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | $_[0] = shift @$call; shift; | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | my $args = $_[0] = shift @$call; shift; | ||||||||||||||||||||||||||||||||||||||||||||||
| 288 | if (ref $args eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | %s} else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | %s | ||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | , $gen->gen_getargs_static($widget, $metainfo) | ||||||||||||||||||||||||||||||||||||||||||||||
| 294 | , $gen->gen_getargs_dynamic($widget, $metainfo)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 203 | ▶ | sub genprolog { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
genprolog: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 203 | (my MY $gen, my Widget $widget) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 299 | 203 | my @args = qw($this $args); | |||||||||||||||||||||||||||||||||||||||||||||
| 300 | 203 | ▶ | if ($widget->{arg_order} && @{$widget->{arg_order}}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$widget->{"arg_order"} and @{$widget->{"arg_order"};}
MC/DC50%1/2
$widget->{"arg_order"} and @{$widget->{"arg_order"};}
$widget->{"arg_order"}
@{$widget->{"arg_order"};}
Truth table66%2/3
A and B
A= $widget->{"arg_order"}B= @{$widget->{"arg_order"};}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 161 | foreach my $name (@{$widget->{arg_order}}) { | |||||||||||||||||||||||||||||||||||||||||||||
| 302 | 391 | push @args, $widget->{arg_dict}{$name}->as_lvalue | |||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 305 | sprintf q{getargs_%s(\@_, my (%s))} | ||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 203 | , $$widget{cf_name}, join(", ", @args); | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 285 | ▶ | sub generate_body { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_body: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 285 | (my MY $gen, my ($scope, $cursor)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 311 | 285 | my @code; | |||||||||||||||||||||||||||||||||||||||||||||
| 312 | 285 | ▶ | for (; $cursor->readable; $cursor->next) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 850 | ▶ | if (my $sub = $gen->can("trans_" . (my $t = $cursor->node_type_name))) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 850 | push @code, $sub->($gen, $scope, $cursor); | |||||||||||||||||||||||||||||||||||||||||||||
| 315 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | die $gen->node_error($cursor, "Can't handle node type: %s", $t); | |||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 269 | @code; | |||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 444 | ▶ | sub as_sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_sub: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 444 | my ($gen, $func_name) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 324 | 444 | "sub $func_name ". $gen->as_block(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 460 | ▶ | sub as_block { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_block: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 460 | my ($gen) = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 329 | 460 | ▶ | return '{}' unless @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 460 | my $last = pop; | |||||||||||||||||||||||||||||||||||||||||||||
| 331 | 460 | $last .= do { | |||||||||||||||||||||||||||||||||||||||||||||
| 332 | 460 | ▶ | if ($last =~ s/(\n+)$//) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 326 | "}$1"; | |||||||||||||||||||||||||||||||||||||||||||||
| 334 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 134 | '}'; | |||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 460 | '{ '.join("; ", @_, $last); | |||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 14 | ▶ | sub as_join { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_join: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 14 | my MY $gen = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 343 | 14 | my (@result); | |||||||||||||||||||||||||||||||||||||||||||||
| 344 | 14 | foreach my $trans (@_) { | |||||||||||||||||||||||||||||||||||||||||||||
| 345 | 35 | ▶ | if (ref $trans) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | push @result, qq(YATT::capture {$$trans}); | |||||||||||||||||||||||||||||||||||||||||||||
| 347 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 35 | push @result, $trans; | |||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 14 | sprintf q{join('', %s)}, join ", ", @result; | |||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||
| 354 | use YATT::Types | ||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 3 | ▶ | [queued_joiner => [qw(queue printable last_ws)]]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 279 | ▶ | sub YATT::Translator::Perl::queued_joiner::joiner { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
joiner: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 358 | # 行が変わらない限り、一つの print に入れる。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 359 | # 行が変われば、別の print にする。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 360 | # 印字可能要素が無いなら、空白をそのまま入れる。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 279 | (my queued_joiner $me, my ($head)) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 362 | 279 | my ($line, $prenl, @result, $argc, $nlines) = ('', ''); | |||||||||||||||||||||||||||||||||||||||||||||
| 363 | 279 | foreach my $i (@_) { | |||||||||||||||||||||||||||||||||||||||||||||
| 364 | 590 | ▶ | unless ($i =~ /\S/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 44 | ▶ | push @result, $i | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 366 | and next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 546 | ▶ | if ($line eq '') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # 先頭 | ||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 306 | ▶ | if ($i =~ s/^(\s+)//) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 86 | $prenl .= $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 306 | ▶ | if ($i ne '') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 306 | $line .= $prenl . $head . $i; | |||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 377 | # 残り | ||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 240 | $line .= ', ' . $i; | |||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 546 | ▶ | if ($i =~ /\n/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 246 | push @result, $line; | |||||||||||||||||||||||||||||||||||||||||||||
| 382 | 246 | $line = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 383 | 246 | $prenl = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 279 | ▶ | push @result, $line if $line ne ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 279 | @result; | |||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 689 | ▶ | sub YATT::Translator::Perl::queued_joiner::add { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 689 | (my queued_joiner $me, my $str) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 392 | 689 | push @{$me->{queue}}, $str; | |||||||||||||||||||||||||||||||||||||||||||||
| 393 | 689 | ▶ | if ($str =~ /\S/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 546 | $me->{printable}++; | |||||||||||||||||||||||||||||||||||||||||||||
| 395 | 546 | undef $me->{last_ws}; | |||||||||||||||||||||||||||||||||||||||||||||
| 396 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 143 | $me->{last_ws} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 406 | ▶ | sub YATT::Translator::Perl::queued_joiner::emit_to { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emit_to: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 406 | (my queued_joiner $me, my ($result)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 403 | 406 | ▶ | if ($me->{printable}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 279 | ▶ | my $ws; $ws = pop @{$me->{queue}} if $me->{last_ws}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 279 | ▶ | push @$result, $me->joiner('print ', @{$me->{queue}}) if @{$me->{queue}}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 279 | ▶ | $result->[-1] .= $ws if $me->{last_ws}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 127 | ▶ | push @$result, @{$me->{queue}} if $me->{queue}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 406 | undef @{$me->{queue}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 411 | 406 | undef $me->{printable}; | |||||||||||||||||||||||||||||||||||||||||||||
| 412 | 406 | undef $me->{last_ws}; | |||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 256 | ▶ | sub as_statement_list { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_statement_list: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 256 | my MY $gen = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 417 | 256 | my queued_joiner $queue = queued_joiner->new; | |||||||||||||||||||||||||||||||||||||||||||||
| 418 | 256 | my (@result); | |||||||||||||||||||||||||||||||||||||||||||||
| 419 | 256 | foreach my $trans (@_) { | |||||||||||||||||||||||||||||||||||||||||||||
| 420 | 839 | ▶ | if (ref $trans) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 150 | $queue->emit_to(\@result); | |||||||||||||||||||||||||||||||||||||||||||||
| 422 | 150 | push @result, $$trans; | |||||||||||||||||||||||||||||||||||||||||||||
| 423 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 689 | $queue->add($trans); | |||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 256 | $queue->emit_to(\@result); | |||||||||||||||||||||||||||||||||||||||||||||
| 428 | 256 | ▶ | wantarray ? @result : join('', @result); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||
| 431 | #---------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 432 | # trans_zzz | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | sub trans_comment { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trans_comment: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | (my MY $trans, my ($scope, $node)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | \ ("\n" x $node->node_nlines); | |||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 527 | ▶ | sub trans_text { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trans_text: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 527 | (my MY $trans, my ($scope, $node)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 441 | 527 | my $body = $node->current; | |||||||||||||||||||||||||||||||||||||||||||||
| 442 | 527 | my ($pre, $post) = ('', ''); | |||||||||||||||||||||||||||||||||||||||||||||
| 443 | 527 | my $CRLF = qr{\r?\n}; | |||||||||||||||||||||||||||||||||||||||||||||
| 444 | 527 | ▶ | if ($node->node_is_beginning) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 233 | ▶ | $pre = $1 if $body =~ s/^($CRLF+)//; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } elsif ($node->node_is_end) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 211 | ▶ | if (not $node->has_parent | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $node->has_parent and $node->metainfo->caller_widget->no_last_newline
MC/DC100%2/2
not $node->has_parent and $node->metainfo->caller_widget->no_last_newline
not $node->has_parent
$node->metainfo->caller_widget->no_last_newline
Truth table100%3/3
not(A) and B
A= not $node->has_parentB= $node->metainfo->caller_widget->no_last_newline
| |||||||||||||||||||||||||||||||||||||||||||||||
| 448 | and $node->metainfo->caller_widget->no_last_newline) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 35 | $body =~ s/($CRLF+)$//s; | |||||||||||||||||||||||||||||||||||||||||||||
| 450 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 176 | ▶ | $post = $2 if $body =~ s/($CRLF)($CRLF+)$/$1/s; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 527 | $pre.do { | |||||||||||||||||||||||||||||||||||||||||||||
| 455 | 527 | ▶ | if ($body eq '') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 146 | '' | |||||||||||||||||||||||||||||||||||||||||||||
| 457 | } elsif ($body =~ /^$CRLF$/) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 129 | sprintf qq{"%s"\n}, qcrlf($body); | |||||||||||||||||||||||||||||||||||||||||||||
| 459 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 252 | qparen($body); | |||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 462 | }.$post; | ||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 17 | ▶ | sub trans_pi { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trans_pi: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 17 | (my MY $trans, my ($scope, $node)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # XXX: 処理を許すかどうか、選べるようにすべき。あるいは、mapping が欲しい。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 17 | ▶ | if ($node->node_nsname ne 'perl') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 17 | my $body = $trans->genexpr_node($scope, 0, $node->open); | |||||||||||||||||||||||||||||||||||||||||||||
| 474 | 17 | ▶ | unless ($body =~ s/^(=+)//) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 3 | \ $body; | |||||||||||||||||||||||||||||||||||||||||||||
| 476 | } elsif (length($1) >= 3) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 477 | # print without escaping. | ||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 6 | \ qq{print $body}; | |||||||||||||||||||||||||||||||||||||||||||||
| 479 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 8 | qq{YATT::escape(do {$body})} | |||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 34 | ▶ | sub genexpr_node { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
genexpr_node: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 34 | (my MY $trans, my ($scope, $early_escaped, $node)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 486 | 34 | ▶ | join("", map { ref $_ ? $$_ : $trans->dots_for_arrows(my $cp = $_) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 487 | $trans->mark_vars($scope, $early_escaped, $node)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||
| 490 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 3 | ▶ | use YATT::Util::Enum -prefix => 'ENT_', qw(RAW ESCAPED PRINTED); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 158 | ▶ | sub trans_entity { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trans_entity: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 158 | (my MY $trans, my ($scope, $node)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 496 | 158 | $trans->generate_entref($scope, ENT_PRINTED, $node); | |||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 11 | ▶ | sub trans_html { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trans_html: called CC=13 SCAR=26.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 11 | (my MY $trans, my ($scope, $node)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 501 | 11 | my $tag = $node->node_name; | |||||||||||||||||||||||||||||||||||||||||||||
| 502 | 11 | my ($string, $tagc, $end) = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 503 | 11 | ▶ | if ($node->is_empty_element) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 9 | ("<$tag", " />", ''); | |||||||||||||||||||||||||||||||||||||||||||||
| 505 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 2 | ("<$tag", ">", "</$tag>"); | |||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 508 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 11 | my $item = $node->open; | |||||||||||||||||||||||||||||||||||||||||||||
| 511 | 11 | my @script; | |||||||||||||||||||||||||||||||||||||||||||||
| 512 | 11 | ▶ | for (; $item->readable; $item->next) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 24 | ▶ | last unless $item->is_primary_attribute; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 22 | my $name = $item->node_name; | |||||||||||||||||||||||||||||||||||||||||||||
| 515 | 22 | ▶ | if (my $var = $trans->has_pass_through_var($scope, $item, $name)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | push @script, qparen($string), $var->as_escaped; | |||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | $string = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 22 | $string .= ' '; | |||||||||||||||||||||||||||||||||||||||||||||
| 521 | 22 | my ($open, $close) = $item->node_attribute_format; | |||||||||||||||||||||||||||||||||||||||||||||
| 522 | 22 | $string .= $open; | |||||||||||||||||||||||||||||||||||||||||||||
| 523 | # XXX: quote されてないとき、変数推測をしても良いかも。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 22 | ▶ | for (my $frag = $item->open; $frag->readable; $frag->next) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 27 | my $type = $frag->node_type; | |||||||||||||||||||||||||||||||||||||||||||||
| 526 | 27 | ▶ | if ($type == TEXT_TYPE) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 12 | $string .= $frag->current; | |||||||||||||||||||||||||||||||||||||||||||||
| 528 | } elsif ($type == ENTITY_TYPE) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 529 | # should be entity | ||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 15 | push @script, qparen($string) | |||||||||||||||||||||||||||||||||||||||||||||
| 531 | , $trans->generate_entref($scope, ENT_ESCAPED, $frag); | ||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 15 | $string = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 533 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | die $trans->node_error($frag, "Invalid node in html attribute"); | |||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 22 | $string .= $close; | |||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 11 | ▶ | $string .= $tagc if $tagc ne ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 11 | ▶ | for (; $item->readable; $item->next) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 4 | ▶ | if ($item->node_type == TEXT_TYPE) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 2 | $string .= $item->current; | |||||||||||||||||||||||||||||||||||||||||||||
| 544 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 2 | push @script, qparen($string), $trans->generate_body($scope, $item); | |||||||||||||||||||||||||||||||||||||||||||||
| 546 | 2 | $string = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 11 | ▶ | $string .= $end if $end; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 11 | ▶ | push @script, qparen($string) if $string ne ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 11 | @script; | |||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||
| 554 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 3 | my %control = (if => undef, unless => undef); | |||||||||||||||||||||||||||||||||||||||||||||
| 557 | 137 | ▶ | sub trans_element { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trans_element: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 137 | (my MY $trans, my ($scope, $node)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 559 | 137 | my $tmpl = $trans->get_template_from_node($node); | |||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||
| 561 | # ■ 最初に要素マクロ ← RC から検索。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 137 | ▶ | if (my $macro = $trans->has_element_macro($tmpl, $node, $node->node_path)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 563 | # XXX: ssri:foreach → yatt:foreach も。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 23 | return $macro->($trans, $scope, $node->open); | |||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||
| 567 | # ■ 次に if/unless/else, | ||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 114 | ▶ | if (my @arm = $trans->collect_arms($node, else => \%control)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 5 | return $trans->gencall_conditional($scope, @arm); | |||||||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||
| 572 | # ■ 無条件呼び出し | ||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 109 | $trans->gencall_always($scope, $node); | |||||||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 5 | ▶ | sub gencall_conditional { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gencall_conditional: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 5 | (my MY $trans, my ($scope, $ifunless, @elses)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 578 | 5 | my $pkg; | |||||||||||||||||||||||||||||||||||||||||||||
| 579 | 5 | my $script = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 580 | 5 | my ($cond, $action) = @$ifunless; # (node, cursor) | |||||||||||||||||||||||||||||||||||||||||||||
| 581 | sprintf(q{%s (%s) {%s}} | ||||||||||||||||||||||||||||||||||||||||||||||
| 582 | , $cond->node_name | ||||||||||||||||||||||||||||||||||||||||||||||
| 583 | , $trans->genexpr_node($scope, 0, $cond->open) | ||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 5 | , ${ $trans->gencall_always($scope, $action->make_wrapped) }); | |||||||||||||||||||||||||||||||||||||||||||||
| 585 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 5 | foreach my $arm (@elses) { | |||||||||||||||||||||||||||||||||||||||||||||
| 588 | 5 | my ($cond, $action) = @$arm; | |||||||||||||||||||||||||||||||||||||||||||||
| 589 | 5 | $script .= do { | |||||||||||||||||||||||||||||||||||||||||||||
| 590 | 5 | ▶ | if ($cond) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 2 | sprintf q{ elsif (%s) } | |||||||||||||||||||||||||||||||||||||||||||||
| 592 | , $trans->genexpr_node($scope, 0, $cond->open); | ||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 3 | q{ else } | |||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 596 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 597 | $script .= sprintf q{{%s}} | ||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 5 | , ${ $trans->gencall_always($scope, $action->make_wrapped) }; | |||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 5 | \ $script; | |||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 119 | ▶ | sub gencall_always { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gencall_always: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 119 | (my MY $trans, my ($scope, $node)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 119 | my $tmpl = $trans->get_template_from_node($node); | |||||||||||||||||||||||||||||||||||||||||||||
| 607 | 119 | ▶ | my @elempath = $node->node_path or do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | die $trans->node_error($node, "Empty element path"); | |||||||||||||||||||||||||||||||||||||||||||||
| 609 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||
| 611 | # ■ 局所引数… これも、型の固有処理に任せる. delegate もここで。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 119 | ▶ | if (my $codevar = $trans->find_codearg($scope, @elempath)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 613 | # ← 特に、親の call の body の中で、<yatt:body foo=bar/> で | ||||||||||||||||||||||||||||||||||||||||||||||
| 614 | # 呼ばれるとき, だよね? | ||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 30 | return $codevar->gen_call($trans, $scope, $node); | |||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||
| 618 | # ■ さもなければ、通常の Widget の呼び出し | ||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 89 | my Widget $widget = $trans->get_widget_from_template($tmpl, @elempath); | |||||||||||||||||||||||||||||||||||||||||||||
| 620 | 89 | ▶ | unless ($widget) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 2 | die $trans->node_error($node, "No such widget"); | |||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 87 | $trans->gencall($widget, $scope, $node->open); | |||||||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 87 | ▶ | sub has_unique_argmacro { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_unique_argmacro: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 87 | (my MY $trans, my Widget $callee, my Widget $caller) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 628 | 87 | ▶ | return unless $callee->{argmacro_dict}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 629 | # 現状では、name の重複は無いはず。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 19 | my %suppress; $suppress{$_->call_spec} = 1 for @{$caller->{argmacro_order}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 631 | 19 | ▶ | my @order = grep {not $suppress{$_->call_spec}} @{$callee->{argmacro_order}} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 632 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 11 | my %dict; | |||||||||||||||||||||||||||||||||||||||||||||
| 634 | 11 | foreach my $arg (keys %{$callee->{argmacro_dict}}) { | |||||||||||||||||||||||||||||||||||||||||||||
| 635 | 45 | $dict{$arg} = $callee->{argmacro_dict}{$arg}; | |||||||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 11 | (\%dict, \@order); | |||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 87 | ▶ | sub gencall { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gencall: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 87 | (my MY $trans, my Widget $widget, my ($scope, $node)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 642 | 87 | $trans->ensure_widget_is_generated($widget); | |||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||
| 644 | # 引数マクロの抜き出し | ||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 87 | ▶ | if (my ($dict, $order) = $trans->has_unique_argmacro | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 646 | ($widget, $node->metainfo->caller_widget)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 11 | $node = YATT::ArgMacro->expand_all_macros | |||||||||||||||||||||||||||||||||||||||||||||
| 648 | ($trans, $scope, $node, $widget, $dict, $order); | ||||||||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 87 | my $func = $trans->get_funcname_to($trans->{cf_mode}, $widget); | |||||||||||||||||||||||||||||||||||||||||||||
| 652 | # actual 一覧の作成 | ||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 87 | my ($post, @args) = $trans->genargs_static | |||||||||||||||||||||||||||||||||||||||||||||
| 654 | ($scope, $node, $widget->arg_specs); | ||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||
| 656 | # XXX: calling convention 周り | ||||||||||||||||||||||||||||||||||||||||||||||
| 657 | return \ sprintf(' %s($this, [%s])%s', $func | ||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 83 | ▶ | , join(", ", map {defined $_ ? $_ : 'undef'} @args) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 659 | , $post); | ||||||||||||||||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 6 | ▶ | sub has_single_bare_varexpr { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_single_bare_varexpr: called CC=5 SCAR=16.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 6 | (my MY $trans, my ($scope, $node)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 664 | 6 | my $clone = $node->clone($node->clone_path); | |||||||||||||||||||||||||||||||||||||||||||||
| 665 | 6 | my $parent = $clone->parent; | |||||||||||||||||||||||||||||||||||||||||||||
| 666 | 6 | ▶ | return unless $parent->is_bare_attribute and $parent->node_size == 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$parent->is_bare_attribute and $parent->node_size == 1
MC/DC50%1/2
$parent->is_bare_attribute and $parent->node_size == 1
$parent->is_bare_attribute
$parent->node_size == 1
Truth table66%2/3
A and B
A= $parent->is_bare_attributeB= $parent->node_size == 1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 1 | my (@expr) = ($trans->mark_vars($scope, ENT_RAW, $clone)); | |||||||||||||||||||||||||||||||||||||||||||||
| 668 | 1 | ▶ | return unless @expr and ref $expr[0] eq 'SCALAR'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@expr and ref $expr[0] eq "SCALAR"
MC/DC0%0/2
@expr and ref $expr[0] eq "SCALAR"
@expr
ref $expr[0] eq "SCALAR"
Truth table33%1/3
A and B
A= @exprB= ref $expr[0] eq "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 1 | $expr[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 133 | ▶ | sub has_pass_through_var { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_pass_through_var: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 133 | (my MY $trans, my ($scope, $args, $name)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 674 | 133 | ▶ | return if $args->node_size >= 2; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 118 | ▶ | if ($args->node_size == 1 and ($args->node_flag || 0) == 0) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%5/5
$args->node_size == 1 and ($args->node_flag || 0) == 0
$args->node_flag || 0
MC/DC100%2/2
$args->node_size == 1 and ($args->node_flag || 0) == 0
$args->node_size == 1
$args->node_flag
Truth table100%3/3
A and B
A= $args->node_size == 1B= $args->node_flag
| |||||||||||||||||||||||||||||||||||||||||||||||
| 676 | # bareword 渡し。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 20 | $trans->find_var($scope, $args->node_body); | |||||||||||||||||||||||||||||||||||||||||||||
| 678 | } elsif ($args->node_size == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 679 | # value less 渡し | ||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 43 | $trans->find_var($scope, $name); | |||||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 117 | ▶ | sub genargs_static { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
genargs_static: called CC=18 SCAR=28.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 117 | (my MY $trans, my ($scope, $args, $arg_dict, $arg_order, $delegate_vars)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 686 | 117 | my ($body, @actual) = $args->variant_builder; | |||||||||||||||||||||||||||||||||||||||||||||
| 687 | 117 | my ($postnl, $startline) = ('', $args->linenum); | |||||||||||||||||||||||||||||||||||||||||||||
| 688 | 117 | ▶ | for (my $nth = 0; $args->readable; $args->next) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 177 | ▶ | unless ($args->is_attribute) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 75 | $body->add_node($args->current); | |||||||||||||||||||||||||||||||||||||||||||||
| 691 | 75 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 102 | my ($name, $typename) = $trans->arg_name_types($args); | |||||||||||||||||||||||||||||||||||||||||||||
| 695 | 102 | ▶ | unless (defined $name) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 2 | ▶ | $name = $arg_order->[$nth++] | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 697 | or die $trans->node_error($args, "Too many args"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 102 | my $argdecl = $arg_dict->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 700 | 102 | ▶ | unless ($argdecl) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | die $trans->node_error($args, "Unknown arg '%s'", $name); | |||||||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 703 | # XXX: $typename (attname:type の type) を活用していない。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 704 | # XXX: code 型引数を primary で渡したときにまで、 print が作られてる。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 705 | # $args->is_quoted_by_element で判別せよ。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 102 | $actual[$argdecl->argno] = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 707 | 102 | ▶ | if (my $var = $trans->has_pass_through_var($scope, $args, $name)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 708 | # XXX: early_escaped が一致するか、検査せよ。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 38 | ▶ | $argdecl->early_escaped ? $var->as_escaped : $var->as_lvalue; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 710 | } elsif (defined $args->node_body) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 60 | $argdecl->gen_assignable_node($trans, $scope, $args); | |||||||||||||||||||||||||||||||||||||||||||||
| 712 | } elsif ($argdecl->isa($trans->t_scalar)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 3 | $argdecl->quote_assignable(my $copy = 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 714 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 1 | die $trans->node_error($args, "valueless arg '%s'", $name); | |||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 717 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 116 | ▶ | if ($body->array_size | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$body->array_size and my $bodydecl = $arg_dict->{"body"}
MC/DC50%1/2
$body->array_size and my $bodydecl = $arg_dict->{"body"}
$body->array_size
my $bodydecl = $arg_dict->{"body"}
Truth table66%2/3
A and B
A= $body->array_sizeB= my $bodydecl = $arg_dict->{"body"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 720 | and my $bodydecl = $arg_dict->{body}) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 721 | # if $actual[$bodydecl->argno]; なら、エラーを報告すべきでは? | ||||||||||||||||||||||||||||||||||||||||||||||
| 722 | # code か、html か。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 35 | $actual[$bodydecl->argno] | |||||||||||||||||||||||||||||||||||||||||||||
| 724 | = $bodydecl->gen_assignable_node($trans, $scope, $body, 1); | ||||||||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 114 | ▶ | for (my $i = 0; $i < @$arg_order; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 212 | ▶ | next if defined $actual[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 79 | my $name = $arg_order->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||
| 730 | 79 | ▶ | if ($delegate_vars->{$name}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 731 | # delegate 宣言では、型は同じになるはず。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 732 | # XXX: 引数rename | ||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 17 | $actual[$i] = $arg_dict->{$name}->as_lvalue; | |||||||||||||||||||||||||||||||||||||||||||||
| 734 | } elsif ($arg_dict->{$name}->is_required) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 1 | die $trans->node_error($args->parent | |||||||||||||||||||||||||||||||||||||||||||||
| 736 | , "Argument '%s' is missing", $name); | ||||||||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 113 | ▶ | if ($args->parent->is_empty_element) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 80 | my $diff = $args->parent->linenum(+1) | |||||||||||||||||||||||||||||||||||||||||||||
| 742 | - $startline - $args->count_lines_of(@actual); | ||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 80 | ▶ | $postnl = "\n" x $diff if $diff; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 745 | # XXX: どうする? | ||||||||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 113 | ($postnl, @actual); | |||||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 114 | ▶ | sub collect_arms { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
collect_arms: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 114 | my ($pack, $call, $key, $dict) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 752 | 114 | my ($type, $name) = $call->node_headings; | |||||||||||||||||||||||||||||||||||||||||||||
| 753 | 114 | my $args = $call->open; | |||||||||||||||||||||||||||||||||||||||||||||
| 754 | 114 | my ($cond, $body) = $pack->consume_arm($args, $dict, $type, $name | |||||||||||||||||||||||||||||||||||||||||||||
| 755 | , primary_only => 1); | ||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 114 | ▶ | return unless $cond; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 5 | my @case = [$cond, $body]; | |||||||||||||||||||||||||||||||||||||||||||||
| 758 | 5 | ▶ | for (; $args->readable; $args->next) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 9 | ▶ | if ($args->is_attribute && $args->node_name eq $key) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args->is_attribute and $args->node_name eq $key
MC/DC50%1/2
$args->is_attribute and $args->node_name eq $key
$args->is_attribute
$args->node_name eq $key
Truth table66%2/3
A and B
A= $args->is_attributeB= $args->node_name eq $key
| |||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 5 | push @case, [$pack->consume_arm($args->open, $dict, $type, $name)]; | |||||||||||||||||||||||||||||||||||||||||||||
| 761 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 762 | # XXX: 多分、$case[0] (== $body) | ||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 4 | $case[-1][-1]->add_node($args->current); | |||||||||||||||||||||||||||||||||||||||||||||
| 764 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 5 | @case; | |||||||||||||||||||||||||||||||||||||||||||||
| 767 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 119 | ▶ | sub consume_arm { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
consume_arm: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 119 | my ($trans, $node, $dict, $type, $name, @opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 771 | 119 | my $arm = $node->variant_builder($type, $name); | |||||||||||||||||||||||||||||||||||||||||||||
| 772 | 119 | my @cond = $arm->filter_or_add_from($node, $dict, @opts); | |||||||||||||||||||||||||||||||||||||||||||||
| 773 | 119 | ▶ | if (@cond >= 2) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 774 | die $trans->node_error | ||||||||||||||||||||||||||||||||||||||||||||||
| 775 | ($node, "Too many condtitions: %s" | ||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | , join("", map {stringify_node($_)} @cond)); | |||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 778 | # $cond[0] は undef かもしれない。 ex. <:else/> | ||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 119 | ▶ | my $cond; $cond = $trans->fake_cursor_from($arm, $cond[0]) if defined $cond[0]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 119 | ($cond, $arm); | |||||||||||||||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||
| 784 | #---------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 137 | ▶ | sub has_element_macro { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_element_macro: called CC=6 SCAR=18.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 137 | (my MY $trans, my Template $tmpl, my ($node, @elempath)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 788 | # XXX: macro の一覧は、ちゃんと取り出せるか? | ||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 137 | ▶ | if (@elempath > 2) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 791 | # Not implemented. | ||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 137 | my $pkg = $trans->get_rc_package_from_template($tmpl); | |||||||||||||||||||||||||||||||||||||||||||||
| 796 | 137 | my $ns; | |||||||||||||||||||||||||||||||||||||||||||||
| 797 | 137 | foreach my $shift (0, 1) { | |||||||||||||||||||||||||||||||||||||||||||||
| 798 | 251 | ▶ | $ns = $trans->strip_ns(\@elempath) if $shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 251 | my $macro_name = join("_", macro => @elempath); | |||||||||||||||||||||||||||||||||||||||||||||
| 800 | 251 | ▶ | if (my $sub = $pkg->can($macro_name) || $trans->can($macro_name)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$pkg->can($macro_name) || $trans->can($macro_name)
MC/DC50%1/2
$pkg->can($macro_name) || $trans->can($macro_name)
$pkg->can($macro_name)
$trans->can($macro_name)
Truth table66%2/3
A || B
A= $pkg->can($macro_name)B= $trans->can($macro_name)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 23 | return $sub; | |||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 803 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||
| 806 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 807 | # 宣言関連 | ||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||
| 809 | # XXX: use は perl 固有だから、ここに持たせるのは理にかなう。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | ▶ | sub declare_use { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
declare_use: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 7 | ▶ | sub attr_declare_delegate { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attr_declare_delegate: called CC=7 SCAR=20.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 7 | (my MY $trans, my ($widget, $args, $argname, $subtype, @param)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 815 | 7 | ▶ | my @elempath = $subtype ? @$subtype : $argname; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 7 | my Template $tmpl = $trans->get_template_from_node($args); | |||||||||||||||||||||||||||||||||||||||||||||
| 817 | 7 | my Widget $base = $trans->get_widget_from_template($tmpl, @elempath); | |||||||||||||||||||||||||||||||||||||||||||||
| 818 | 7 | ▶ | unless ($base) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | die $trans->node_error($args, "No such widget %s" | |||||||||||||||||||||||||||||||||||||||||||||
| 820 | , join(":", @elempath)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 7 | ▶ | if ($tmpl->{cf_nsid} != $base->template_nsid) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | $trans->mark_delayed_target($base); | |||||||||||||||||||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 7 | ▶ | if ($base->{arg_dict}{$argname}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 1 | die $trans->node_error($args, q{delegate '%1$s' hides argument '%1$s' of widget %2$s} | |||||||||||||||||||||||||||||||||||||||||||||
| 828 | , $argname, join(":", @elempath)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||||||
| 831 | # pass thru する変数名の一覧。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 832 | # でも、未指定なものだけね。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 833 | # XXX: 引数rename | ||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 6 | my %vars; $vars{$_} = 1 for $widget->copy_specs_from($base); | |||||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||||||
| 836 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 837 | # arg とは別の、コンパイル時のみの仮想的な変数として登録。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 838 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 6 | ▶ | if ($widget->has_virtual_var($argname)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | die $trans->node_error($args, "Duplicate delegate? %s", $argname); | |||||||||||||||||||||||||||||||||||||||||||||
| 841 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 842 | $widget->add_virtual_var | ||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 6 | ($argname, $trans->create_var(delegate => $args | |||||||||||||||||||||||||||||||||||||||||||||
| 844 | , base_path => \@elempath | ||||||||||||||||||||||||||||||||||||||||||||||
| 845 | , base_widget => $base | ||||||||||||||||||||||||||||||||||||||||||||||
| 846 | , delegate_vars => \%vars, @param)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 173 | ▶ | sub after_define_args { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_define_args: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 173 | (my MY $trans, my ($target)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 851 | 173 | ▶ | unless ($target->has_arg('body')) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 154 | $target->add_arg(body => $trans->create_var('code')); | |||||||||||||||||||||||||||||||||||||||||||||
| 853 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 173 | $trans; | |||||||||||||||||||||||||||||||||||||||||||||
| 855 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 16 | ▶ | sub decode_decl_entpath { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode_decl_entpath: called CC=9 SCAR=25.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 16 | (my MY $trans, my $node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 859 | 16 | my ($has_body, @entpath) | |||||||||||||||||||||||||||||||||||||||||||||
| 860 | = $trans->decode_entpath($node, my $entns = [$node->node_path]); | ||||||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 16 | ▶ | unless ($has_body) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 10 | return $node->node_nsname('', '_'); | |||||||||||||||||||||||||||||||||||||||||||||
| 864 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 6 | my (@macro_name, $rename_spec); | |||||||||||||||||||||||||||||||||||||||||||||
| 867 | 6 | ▶ | while (@entpath) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 6 | my ($type, $name, @args) = @{shift @entpath}; | |||||||||||||||||||||||||||||||||||||||||||||
| 869 | 6 | ▶ | if ($type eq 'var') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | ▶ | if (@args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 871 | # foo{name,name,...} case. | ||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | die $trans->node_nimpl($node); | |||||||||||||||||||||||||||||||||||||||||||||
| 873 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | push @macro_name, $name; | |||||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 876 | } elsif ($type eq 'call') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 6 | push @macro_name, $name; | |||||||||||||||||||||||||||||||||||||||||||||
| 878 | 6 | foreach my $arg (@args) { | |||||||||||||||||||||||||||||||||||||||||||||
| 879 | 6 | my ($type, $name, @args) = @$arg; | |||||||||||||||||||||||||||||||||||||||||||||
| 880 | 6 | ▶ | if ($type ne 'text') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | die $trans->node_nimpl($node); | |||||||||||||||||||||||||||||||||||||||||||||
| 882 | } elsif ($rename_spec) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | die $trans->node_nimpl($node); # Error: ()() | |||||||||||||||||||||||||||||||||||||||||||||
| 884 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 6 | $rename_spec = [split /=/, $name, 2]; | |||||||||||||||||||||||||||||||||||||||||||||
| 886 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 887 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 888 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | die $trans->nimpl($node); | |||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 891 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 6 | (join("_", @macro_name), $rename_spec); | |||||||||||||||||||||||||||||||||||||||||||||
| 894 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||||||
| 896 | # For ArgMacro | ||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 51 | ▶ | sub add_decl_entity { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_decl_entity: called CC=7 SCAR=20.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 51 | (my MY $trans, my Widget $widget, my ($node)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||
| 900 | # Widget の configure を呼ぶだけ、のケース ← config(value) でどう? | ||||||||||||||||||||||||||||||||||||||||||||||
| 901 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 51 | my $is_sysns = $trans->shift_ns_by(yatt => | |||||||||||||||||||||||||||||||||||||||||||||
| 903 | my $entns = [$node->node_path]); | ||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 51 | ▶ | if ($is_sysns && @$entns == 1) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$is_sysns and @$entns == 1
MC/DC50%1/2
$is_sysns and @$entns == 1
$is_sysns
@$entns == 1
Truth table66%2/3
A and B
A= $is_sysnsB= @$entns == 1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 35 | ▶ | if ($widget->can_configure($entns->[0])) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 35 | $widget->configure($entns->[0], 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 907 | 35 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 908 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 909 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||||||
| 912 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 51 | my ($macro_name, @args) = $trans->decode_decl_entpath($node); | |||||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 16 | foreach my $pkg ($trans->get_package_from_widget($widget)) { | |||||||||||||||||||||||||||||||||||||||||||||
| 916 | 16 | my $macro_class = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 917 | 16 | ▶ | my $sub = $pkg->can($macro_name) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 918 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 16 | $sub->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 920 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 16 | ▶ | unless ($macro_class->can('handle')) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | die $trans->node_error | |||||||||||||||||||||||||||||||||||||||||||||
| 923 | ($node, "ArgMacro doesn't implement ->handle method: %s" | ||||||||||||||||||||||||||||||||||||||||||||||
| 924 | , $node->node_name); | ||||||||||||||||||||||||||||||||||||||||||||||
| 925 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 16 | return $macro_class->register_in($trans, $node, $widget, @args); | |||||||||||||||||||||||||||||||||||||||||||||
| 927 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 928 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | die $trans->node_error($node, "No such ArgMacro: %s" | |||||||||||||||||||||||||||||||||||||||||||||
| 930 | , $node->node_nsname); | ||||||||||||||||||||||||||||||||||||||||||||||
| 931 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||
| 933 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 934 | # 変数関連 | ||||||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 3 | ▶ | use YATT::Types [VarType => | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 937 | [qw(cf_varname ^cf_argno ^cf_subtype | ||||||||||||||||||||||||||||||||||||||||||||||
| 938 | cf_default cf_default_mode | ||||||||||||||||||||||||||||||||||||||||||||||
| 939 | cf_filename cf_linenum | ||||||||||||||||||||||||||||||||||||||||||||||
| 940 | )]] | ||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 3 | , qw(:export_alias); | |||||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 414 | ▶ | sub find_var { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_var: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 414 | (my MY $trans, my ($scope, $varName)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 945 | 414 | ▶ | for (; $scope; $scope = $scope->[1]) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 987 | ▶ | croak "Undefined varName!" unless defined $varName; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 987 | ▶ | if (defined (my $value = $scope->[0]{$varName})) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 275 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||
| 949 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 950 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 139 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 952 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 145 | ▶ | sub find_codearg { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_codearg: called CC=6 SCAR=18.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 145 | (my MY $trans, my ($scope, @elempath)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 956 | 145 | ▶ | return if @elempath >= 3; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 145 | $trans->strip_ns(\@elempath); | |||||||||||||||||||||||||||||||||||||||||||||
| 958 | 145 | ▶ | return unless @elempath == 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 145 | ▶ | my $var = $trans->find_var($scope, $elempath[0]) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 960 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 40 | ▶ | return unless ref $var and $var->can('arg_specs'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $var and $var->can("arg_specs")
MC/DC50%1/2
ref $var and $var->can("arg_specs")
ref $var
$var->can("arg_specs")
Truth table66%2/3
A and B
A= ref $varB= $var->can("arg_specs")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 38 | $var; | |||||||||||||||||||||||||||||||||||||||||||||
| 963 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 203 | ▶ | sub gen_getargs_static { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_getargs_static: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 203 | (my MY $gen, my Widget $widget, my ($metainfo)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 967 | 203 | my (@args, %scope); | |||||||||||||||||||||||||||||||||||||||||||||
| 968 | 203 | ▶ | foreach my $name ($widget->{arg_order} ? @{$widget->{arg_order}} : ()) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 391 | my VarType $var = $widget->{arg_dict}{$name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 970 | 391 | $scope{$name} = $var; | |||||||||||||||||||||||||||||||||||||||||||||
| 971 | 391 | my $decl = sprintf q{my %s = $_[%d]}, $var->as_lvalue, $$var{cf_argno}; | |||||||||||||||||||||||||||||||||||||||||||||
| 972 | 391 | my $value = $var->gen_getarg | |||||||||||||||||||||||||||||||||||||||||||||
| 973 | ($gen, [\%scope], $widget, $metainfo, qq{\$args->[$$var{cf_argno}]}); | ||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 391 | push @args, "$decl = $value;\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 975 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 203 | join "", @args; | |||||||||||||||||||||||||||||||||||||||||||||
| 977 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 203 | ▶ | sub gen_getargs_dynamic { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_getargs_dynamic: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 203 | ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 981 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | ▶ | sub gen_pass_through_arg_typed { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_pass_through_arg_typed: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | (my MY $gen, my ($type, $scope, $baseNC, $targetNode)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | ▶ | my $node = $targetNode | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 986 | ? $gen->fake_cursor_from($baseNC, $targetNode) | ||||||||||||||||||||||||||||||||||||||||||||||
| 987 | : $baseNC; | ||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | my $name = $node->node_name; | |||||||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | ▶ | if (my $var = $gen->has_pass_through_var($scope, $node, $name)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | $var->as_lvalue; | |||||||||||||||||||||||||||||||||||||||||||||
| 991 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | $gen->faked_gentype($type => $scope, $node) | |||||||||||||||||||||||||||||||||||||||||||||
| 993 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 994 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | ▶ | sub try_pass_through { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
try_pass_through: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | (my MY $trans, my ($scope, $cursor, $rawNode, $defaultFlag)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | ▶ | if (node_size($rawNode) == 1 and node_flag($rawNode) == 0 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
node_size($rawNode) == 1 and node_flag($rawNode) == 0 and (my $nm = node_body($rawNode)) =~ /^\w+$/
node_size($rawNode) == 1 and node_flag($rawNode) == 0
MC/DC0%0/3
node_size($rawNode) == 1 and node_flag($rawNode) == 0 and (my $nm = node_body($rawNode)) =~ /^\w+$/
node_size($rawNode) == 1
node_flag($rawNode) == 0
(my $nm = node_body($rawNode)) =~ /^\w+$/
Truth table0%0/4
A and B and C
A= node_size($rawNode) == 1B= node_flag($rawNode) == 0C= (my $nm = node_body($rawNode)) =~ /^\w+$/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 999 | and (my $nm = node_body($rawNode)) =~ /^\w+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | # [name=bareword_ident] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | # Must be an existing variable. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | ▶ | if (my $var = $trans->find_var($scope, $nm)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | $var->as_lvalue; | |||||||||||||||||||||||||||||||||||||||||||||
| 1005 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | die $trans->node_error($cursor, "No such variable '%s'", $nm); | |||||||||||||||||||||||||||||||||||||||||||||
| 1007 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | } elsif (node_size($rawNode) == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | # [name] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | # variable or flag. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | ▶ | if (my $var = $trans->find_var($scope, my $nm = node_name($rawNode))) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | $var->as_lvalue; | |||||||||||||||||||||||||||||||||||||||||||||
| 1014 | } elsif (defined $defaultFlag) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | $defaultFlag | |||||||||||||||||||||||||||||||||||||||||||||
| 1016 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | die $trans->node_error($cursor, "No such variable '%s'", $nm); | |||||||||||||||||||||||||||||||||||||||||||||
| 1018 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 1021 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 102 | ▶ | sub mark_vars { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mark_vars: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 102 | (my MY $trans, my ($scope, $early_escaped, $node)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 102 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 102 | ▶ | for (; $node->readable; $node->next) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 149 | ▶ | if ($node->node_type == TEXT_TYPE) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | # XXX: dots_for_arrows | ||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 109 | push @result, $node->current; | |||||||||||||||||||||||||||||||||||||||||||||
| 1031 | } elsif ($node->node_type == ELEMENT_TYPE) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | push @result, \ $trans->generate_captured($scope, $node); | |||||||||||||||||||||||||||||||||||||||||||||
| 1033 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 40 | push @result, \ $trans->generate_entref($scope, $early_escaped, $node); | |||||||||||||||||||||||||||||||||||||||||||||
| 1035 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 102 | @result; | |||||||||||||||||||||||||||||||||||||||||||||
| 1038 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 283 | ▶ | sub feed_array_if { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
feed_array_if: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 283 | (my MY $trans, my ($name, $array)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 283 | ▶ | return unless @$array >= 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 283 | ▶ | return unless $array->[0][0] eq $name; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 90 | my $desc = shift @$array; | |||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 90 | ▶ | wantarray ? @{$desc}[1..$#$desc] : $desc; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | # $node の情報を借りながら、@_ を generate. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 32 | ▶ | sub gen_entref_list { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_entref_list: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 32 | (my MY $trans, my ($scope, $node)) = splice @_, 0, 3; | |||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 32 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 32 | foreach my $item (@_) { | |||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 50 | ▶ | push @result, $trans->gen_entref_path | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | ($scope, $node | ||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | , is_nested_entpath($item) ? @$item : $item); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 32 | @result; | |||||||||||||||||||||||||||||||||||||||||||||
| 1058 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 90 | ▶ | sub gen_entref_path { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_entref_path: called CC=25 SCAR=34.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 90 | (my MY $trans, my ($scope, $node)) = splice @_, 0, 3; | |||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 90 | my $var; | |||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 90 | my @expr = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 90 | ▶ | if (my ($name, @args) = $trans->feed_array_if(call => \@_)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 16 | my $pkg = $trans->get_package_from_node($node); | |||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 16 | my $dont_call; | |||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 16 | my $call = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 1068 | # XXX: codevar は、path の先頭だけ。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | # 引数にも現れるから、 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 16 | ▶ | if ($pkg->can(my $en = "entity_$name")) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 8 | sprintf('%s->%s', $pkg, $en); | |||||||||||||||||||||||||||||||||||||||||||||
| 1072 | } elsif ($var = $trans->find_codearg($scope, $name)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 1 | sprintf('%1$s && %1$s->', $var->as_lvalue); | |||||||||||||||||||||||||||||||||||||||||||||
| 1074 | } elsif ($var = $trans->find_var($scope, $name)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 1 | ▶ | if (my $handler = $var->can("entmacro_")) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 1 | $dont_call++; | |||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 1 | $handler->($var, $trans, $scope, $node, \@_, [], @args); | |||||||||||||||||||||||||||||||||||||||||||||
| 1078 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | # XXX: 本当は $pkg よりもファイル名を出すべき。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 0 | die $trans->node_error | |||||||||||||||||||||||||||||||||||||||||||||
| 1081 | ($node, "not implemented call '%s' for %s in %s" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | , $name, $pkg, $node->node_body); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | } elsif (my $handler = $trans->can("entmacro_$name")) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | # XXX: $pkg->can の方が、拡張向きで良いのだが… | ||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | # 予約語も持ちたい。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 6 | $dont_call++; | |||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 6 | $handler->($pkg, $trans, $scope, $node, \@_, [], @args); | |||||||||||||||||||||||||||||||||||||||||||||
| 1089 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 0 | die $trans->node_error($node, "not implemented call '%s' in %s" | |||||||||||||||||||||||||||||||||||||||||||||
| 1091 | , $name, $node->node_body); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 16 | ▶ | ($dont_call || ref $call) ? $call : sprintf q{(%s(%s))}, $call, join ", " | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$dont_call or ref $call
MC/DC50%1/2
$dont_call or ref $call
$dont_call
ref $call
Truth table66%2/3
A or B
A= $dont_callB= ref $call
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | , $trans->gen_entref_list($scope, $node, @args); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | } elsif (($name) = $trans->feed_array_if(var => \@_)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 35 | ▶ | unless ($var = $trans->find_var($scope, $name)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 0 | die $trans->node_error($node, "No such variable '%s'", $name); | |||||||||||||||||||||||||||||||||||||||||||||
| 1100 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 35 | $var->as_lvalue; | |||||||||||||||||||||||||||||||||||||||||||||
| 1102 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | } elsif (($name) = $trans->feed_array_if(expr => \@_)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 11 | $name; | |||||||||||||||||||||||||||||||||||||||||||||
| 1105 | } elsif (my @items = $trans->feed_array_if(array => \@_)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 2 | '['.join(", ", $trans->gen_entref_list($scope, $node, @items)).']'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1107 | } elsif (my @pairs = $trans->feed_array_if(hash => \@_)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | # XXX: '=>' is better. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 0 | '{'.join(", ", $trans->gen_entref_list($scope, $node, @pairs)).'}'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1110 | } elsif (($name) = $trans->feed_array_if(text => \@_)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 26 | qqvalue($name); | |||||||||||||||||||||||||||||||||||||||||||||
| 1112 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 0 | die $trans->node_error($node, "NIMPL(%s)", terse_dump(@_)); | |||||||||||||||||||||||||||||||||||||||||||||
| 1114 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 90 | ▶ | while (@_) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 33 | my $item = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 33 | push @expr, do { | |||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 33 | my ($type, $name, @args) = @$item; | |||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 33 | ▶ | if ($type eq 'call') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | # 先頭の変数が確定している場合の、特殊処理。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | # XXX: 同じ名前のメソッドが呼べなくなる、というデメリットが有る。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 20 | ▶ | if ($var and not ref $name | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$var and not ref $name and my $handler = $var->can("entmacro_$name")
$var and not ref $name
MC/DC33%1/3
$var and not ref $name and my $handler = $var->can("entmacro_$name")
$var
not ref $name
my $handler = $var->can("entmacro_$name")
Truth table50%2/4
A and not(B) and C
A= $varB= not ref $nameC= my $handler = $var->can("entmacro_$name")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | and my $handler = $var->can("entmacro_$name")) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | # ここまでの式を reset する必要が有る時がある。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 19 | $handler->($var, $trans, $scope, $node, \@_, \@expr, @args); | |||||||||||||||||||||||||||||||||||||||||||||
| 1128 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 1 | sprintf q{%s(%s)}, $name, join ", " | |||||||||||||||||||||||||||||||||||||||||||||
| 1130 | , $trans->gen_entref_list($scope, $node, @args); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | } elsif ($type eq 'var') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 2 | ▶ | sprintf '{%s}', join ", ", ref $name | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | ? $trans->gen_entref_list($scope, $node, $name, @args) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | : qqvalue($name); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | } elsif ($type eq 'aref') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | # list は本来冗長だが、nest の処理のため。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 11 | ▶ | sprintf '[%s]', join", ", ref $name | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | ? $trans->gen_entref_list($scope, $node, $name, @args) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | : $name; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 0 | die $trans->node_error($node, "NIMPL(type=$type)"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1143 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 90 | ▶ | @expr > 1 ? join("->", @expr) : $expr[0]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 156 | ▶ | sub find_if_codearg { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_if_codearg: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 156 | (my MY $trans, my ($scope, $node, $entpath)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 156 | my @entns = $node->node_path; | |||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 156 | ▶ | return unless $trans->strip_ns(\@entns); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 155 | ▶ | return if @entns; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 24 | ▶ | return unless @$entpath == 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 18 | ▶ | return unless $entpath->[0][0] eq 'call'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 18 | my ($op, $name, @args) = @{$entpath->[0]}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 18 | ▶ | my $codearg = $trans->find_codearg($scope, $name) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 7 | ($codearg, @args); | |||||||||||||||||||||||||||||||||||||||||||||
| 1161 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 229 | ▶ | sub decode_entpath { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode_entpath: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 229 | (my MY $trans, my ($node, $entns)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 229 | my $has_entns = defined $entns; | |||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 229 | ▶ | unless ($has_entns) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 213 | $trans->strip_ns($entns = [$node->node_path]); | |||||||||||||||||||||||||||||||||||||||||||||
| 1168 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 229 | my $body = $node->node_body; | |||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 229 | ▶ | substr($body, 0, 0) = ':' if defined $body and not defined $node->node_name; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $body and not defined $node->node_name
MC/DC100%2/2
defined $body and not defined $node->node_name
defined $body
not defined $node->node_name
Truth table100%3/3
A and not(B)
A= defined $bodyB= not defined $node->node_name
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 229 | my @entpath = $trans->parse_entpath(join('', map {':'.$_} @$entns) | |||||||||||||||||||||||||||||||||||||||||||||
| 1172 | . coalesce($body, '') | ||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | , $trans, $node); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 227 | ▶ | my $has_body = $body ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 227 | ▶ | $has_entns ? ($has_body, @entpath) : ($entns, $has_body, @entpath); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 213 | ▶ | sub generate_entref { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_entref: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 213 | (my MY $trans, my ($scope, $escaped, $node)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1182 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 213 | my ($entns, $has_body, @entpath) = $trans->decode_entpath($node); | |||||||||||||||||||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | # 特例。&yatt:codevar(); は、副作用で print. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 211 | ▶ | if ($escaped == ENT_PRINTED | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$escaped == 2 and () = $trans->find_if_codearg($scope, $node, \@entpath)
MC/DC100%2/2
$escaped == 2 and () = $trans->find_if_codearg($scope, $node, \@entpath)
$escaped == 2
() = $trans->find_if_codearg($scope, $node, \@entpath)
Truth table100%3/3
A and B
A= $escaped == 2B= () = $trans->find_if_codearg($scope, $node, \@entpath)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | and my ($codearg, @args) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | = $trans->find_if_codearg($scope, $node, \@entpath)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | return \ sprintf('%1$s && %1$s->(%2$s)', $codearg->as_lvalue | ||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | , join(", ", map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 0 | $trans->gen_entref_path($scope, $node, $_) | |||||||||||||||||||||||||||||||||||||||||||||
| 1192 | } @args)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | # 引数。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 204 | ▶ | if ($has_body || @$entns > 1) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$has_body or @$entns > 1
MC/DC50%1/2
$has_body or @$entns > 1
$has_body
@$entns > 1
Truth table66%2/3
A or B
A= $has_bodyB= @$entns > 1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | # path が有る。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 40 | my $expr = $trans->gen_entref_path($scope, $node, @entpath); | |||||||||||||||||||||||||||||||||||||||||||||
| 1198 | # XXX: sub { print } なら \ $expr にすべきだが、 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | # sub { value } などは、むしろ YATT::escape(do {$expr}) すべき。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 40 | ▶ | return $expr if ref $expr; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 38 | ▶ | return $escaped ? qq(YATT::escape($expr)) : $expr; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 164 | my $varName = shift @$entns; | |||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 164 | ▶ | unless (my $vardecl = $trans->find_var($scope, $varName)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 7 | die $trans->node_error($node, "No such variable '%s'", $varName); | |||||||||||||||||||||||||||||||||||||||||||||
| 1207 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 157 | ▶ | $escaped ? $vardecl->as_escaped : $vardecl->as_lvalue; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | # マクロなどで、cursor になっていない targetNode を入手した後で、 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | # それを再び cursor にして、指定の型のソースを生成する仕組み。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | # デフォルト値を最初に指定。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 0 | ▶ | sub default_gentype { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_gentype: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | (my MY $trans, my ($default, $type, $scope, $baseNC, $targetNode)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 0 | ▶ | if (ref $type) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 0 | croak "Type mismatch: \$type should be string for default_gentype: $type"; | |||||||||||||||||||||||||||||||||||||||||||||
| 1221 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | ▶ | unless (defined $targetNode and node_body($targetNode)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $targetNode and node_body($targetNode)
MC/DC0%0/2
defined $targetNode and node_body($targetNode)
defined $targetNode
node_body($targetNode)
Truth table0%0/3
A and B
A= defined $targetNodeB= node_body($targetNode)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 0 | return $default; | |||||||||||||||||||||||||||||||||||||||||||||
| 1224 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | # my $name = node_name($targetNode); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | # if (my $var | ||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | # = $trans->has_pass_through_var($scope, $targetNode, $name)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | # $var->as_lvalue; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | # } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | $trans->faked_gentype($type, $scope, $baseNC, $targetNode); | |||||||||||||||||||||||||||||||||||||||||||||
| 1231 | # } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 2 | ▶ | sub faked_gentype { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
faked_gentype: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 2 | (my MY $trans, my ($type, $scope, $baseNC, $targetNode)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 2 | ▶ | my $node = $targetNode ? $trans->fake_cursor_from($baseNC, $targetNode) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | : $baseNC; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 2 | ▶ | my $sub = $trans->can("t_$type") | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | or die $trans->node_error($node, "No such argtype: %s", $type); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 2 | $sub->()->gen_assignable_node($trans, $scope, $node); | |||||||||||||||||||||||||||||||||||||||||||||
| 1241 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | # expr 専用。デフォルト値も渡せる。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 0 | ▶ | sub faked_genexpr { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
faked_genexpr: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | (my MY $trans, my ($scope, $baseNC, $targetNode, $default, $ent_flag)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1246 | 0 | ▶ | unless (defined $targetNode and node_body($targetNode)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $targetNode and node_body($targetNode)
MC/DC0%0/2
defined $targetNode and node_body($targetNode)
defined $targetNode
node_body($targetNode)
Truth table0%0/3
A and B
A= defined $targetNodeB= node_body($targetNode)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 0 | return $default; | |||||||||||||||||||||||||||||||||||||||||||||
| 1248 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | # open するのが、faked_gentype(scalar) とも違う所、のはず。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | 0 | my $nc = $trans->fake_cursor_from($baseNC, $targetNode)->open; | |||||||||||||||||||||||||||||||||||||||||||||
| 1251 | 0 | ▶ | $trans->genexpr_node($scope, defined $ent_flag ? $ent_flag : ENT_RAW | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | , $nc); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 391 | ▶ | sub YATT::Translator::Perl::VarType::gen_getarg { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_getarg: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 391 | (my VarType $var, my MY $gen | |||||||||||||||||||||||||||||||||||||||||||||
| 1259 | , my ($scope, $widget, $metainfo, $actual)) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | return $actual unless defined $var->{cf_default} | ||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 391 | ▶ | and defined (my $mode = $var->{cf_default_mode}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $var->{"cf_default"} and defined(my $mode = $var->{"cf_default_mode"})
MC/DC100%2/2
defined $var->{"cf_default"} and defined(my $mode = $var->{"cf_default_mode"})
defined $var->{"cf_default"}
defined(my $mode = $var->{"cf_default_mode"})
Truth table100%3/3
A and B
A= defined $var->{"cf_default"}B= defined(my $mode = $var->{"cf_default_mode"})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | 12 | ▶ | if ($mode eq "!") { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 2 | return qq{defined $actual ? $actual : } | |||||||||||||||||||||||||||||||||||||||||||||
| 1265 | . qq{die "Argument '$var->{cf_varname}' is undef!"} | ||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 10 | my ($cond) = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 10 | ▶ | if ($mode eq "|") { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 2 | qq{$actual} | |||||||||||||||||||||||||||||||||||||||||||||
| 1271 | } elsif ($mode eq "?") { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 6 | qq{defined $actual && $actual ne ""} | |||||||||||||||||||||||||||||||||||||||||||||
| 1273 | } elsif ($mode eq "/") { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 2 | qq{defined $actual} | |||||||||||||||||||||||||||||||||||||||||||||
| 1275 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 0 | die "Unknown defaulting mode: $mode" | |||||||||||||||||||||||||||||||||||||||||||||
| 1277 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | my $default = $var->gen_assignable_node | ||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | ($gen, $scope | ||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | , $gen->fake_cursor($widget, $metainfo | ||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 10 | ▶ | , map {ref $_ ? @$_ : $_} $var->{cf_default}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 10 | , 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 1285 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | 10 | qq{($cond ? $actual : $default)}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1287 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | 67 | ▶ | sub YATT::Translator::Perl::VarType::gen_assignable_node { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_assignable_node: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 67 | (my VarType $var, my MY $trans, my ($scope, $node, $is_opened)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1291 | # early escaped な変数への代入値は、代入前に escape される。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 67 | my $escaped = $var->early_escaped; | |||||||||||||||||||||||||||||||||||||||||||||
| 1293 | 67 | ▶ | $var->quote_assignable | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | ($trans->mark_vars($scope, $escaped, $is_opened ? $node : $node->open)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 62 | ▶ | sub YATT::Translator::Perl::VarType::is_required { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_required: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 62 | my VarType $var = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 62 | ▶ | defined $var->{cf_default_mode} && $var->{cf_default_mode} eq '!'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | 0 | ▶ | sub YATT::Translator::Perl::VarType::can_call { 0 } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can_call: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | 103 | ▶ | sub YATT::Translator::Perl::VarType::early_escaped { 0 } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
early_escaped: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 929 | ▶ | sub YATT::Translator::Perl::VarType::lvalue_format {'$%s'} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lvalue_format: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 956 | ▶ | sub YATT::Translator::Perl::VarType::as_lvalue { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_lvalue: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | 956 | my VarType $var = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1307 | 956 | sprintf $var->lvalue_format, $var->{cf_varname}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1308 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | 107 | ▶ | sub YATT::Translator::Perl::VarType::escaped_format {'YATT::escape($%s)'} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
escaped_format: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 123 | ▶ | sub YATT::Translator::Perl::VarType::as_escaped { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_escaped: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 123 | my VarType $var = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1314 | 123 | sprintf $var->escaped_format, $var->{cf_varname}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1315 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | 0 | ▶ | sub YATT::Translator::Perl::VarType::as_typespec { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_typespec: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | 0 | shift->type_name; | |||||||||||||||||||||||||||||||||||||||||||||
| 1319 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 0 | ▶ | sub YATT::Translator::Perl::VarType::as_argspec { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_argspec: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | 0 | (my VarType $var) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 0 | my $spec = $var->as_typespec; | |||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 0 | ▶ | if (my $mode = $var->{cf_default_mode}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | 0 | $spec .= $mode; | |||||||||||||||||||||||||||||||||||||||||||||
| 1326 | 0 | ▶ | if (defined (my $default = $var->{cf_default})) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | $spec .= join "", map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | 0 | ▶ | ref $_ ? map(ref $_ ? stringify_node($_) : $_, @$_) : $_ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | } $default; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | 0 | $spec; | |||||||||||||||||||||||||||||||||||||||||||||
| 1333 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | use YATT::ArgTypes | ||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 3 | ▶ | (-type_map => \%TYPE_MAP | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | , -base => VarType | ||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | , -type_fmt => join("::", MY, 't_%s') | ||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | , [text => -alias => ''] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | , [html => \ lvalue_format => '$html_%s', \ early_escaped => 1] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | , [scalar => -alias => ['value', 'flag']] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | , ['list'] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | , [attr => -base => 'text'] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | , [code => -alias => 'expr', \ can_call => 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | # 引数の型情報 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | , -fields => [qw(arg_dict arg_order)]] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | , [delegate => -fields => [qw(cf_base_path | ||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | cf_base_widget | ||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | cf_delegate_vars)]] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | , qw(:type_name) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1352 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | 3 | $calling_conv{this} = t_scalar->new(varname => 'this'); | |||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 3 | $calling_conv{args} = t_scalar->new(varname => 'args'); | |||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 3 | $calling_conv{_} = t_scalar->new(varname => '_'); | |||||||||||||||||||||||||||||||||||||||||||||
| 1356 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | 45 | ▶ | sub YATT::Translator::Perl::t_text::quote_assignable { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quote_assignable: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 45 | shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 45 | my ($nvars); | |||||||||||||||||||||||||||||||||||||||||||||
| 1360 | my @items = map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | 45 | ▶ | if (ref $_) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | 7 | $nvars++; | |||||||||||||||||||||||||||||||||||||||||||||
| 1363 | 7 | $$_ | |||||||||||||||||||||||||||||||||||||||||||||
| 1364 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | # $var is prohibited. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | 46 | qparen($_); | |||||||||||||||||||||||||||||||||||||||||||||
| 1367 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | } @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | 45 | ▶ | if (@items == 1 && !$nvars) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@items == 1 and not $nvars
MC/DC100%2/2
@items == 1 and not $nvars
@items == 1
not $nvars
Truth table100%3/3
A and not(B)
A= @items == 1B= not $nvars
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | 39 | $items[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 1371 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | 6 | MY->as_join(@items); | |||||||||||||||||||||||||||||||||||||||||||||
| 1373 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | # XXX: 本当に良いのか? | ||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | 0 | ▶ | sub YATT::Translator::Perl::t_html::quote_assignable { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quote_assignable: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | 0 | shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 0 | sprintf q{YATT::escape(%s)}, t_text->quote_assignable(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 1380 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 16 | ▶ | sub YATT::Translator::Perl::t_html::escaped_format {shift->lvalue_format} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
escaped_format: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 6 | ▶ | sub YATT::Translator::Perl::t_html::gen_assignable_node { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_assignable_node: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | 6 | (my VarType $var, my MY $trans, my ($scope, $node, $is_opened)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1386 | # XXX: フラグがダサい。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | 6 | ▶ | my $n = $is_opened ? $node : $node->open; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | 6 | ▶ | if (my $expr = $trans->has_single_bare_varexpr($scope, $n)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | 1 | t_scalar->quote_assignable($expr); | |||||||||||||||||||||||||||||||||||||||||||||
| 1390 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | 5 | $trans->as_join($trans->generate_body($scope, $n)); | |||||||||||||||||||||||||||||||||||||||||||||
| 1392 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | 0 | ▶ | sub YATT::Translator::Perl::t_attr::as_typespec { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_typespec: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 0 | my t_attr $var = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1397 | 0 | ▶ | join(":", $var->type_name, $var->{cf_subtype} || $var->{cf_varname}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$var->{'cf_subtype'} || $var->{'cf_varname'}
MC/DC0%0/2
$var->{'cf_subtype'} || $var->{'cf_varname'}
$var->{'cf_subtype'}
$var->{'cf_varname'}
Truth table0%0/3
A || B
A= $var->{'cf_subtype'}B= $var->{'cf_varname'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | 1 | ▶ | sub YATT::Translator::Perl::t_attr::entmacro_ { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
entmacro_: called CC=4 SCAR=16.6
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | 1 | (my t_attr $var, my MY $trans | |||||||||||||||||||||||||||||||||||||||||||||
| 1403 | , my ($scope, $node, $restExpr, $queue, @args)) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | 1 | ▶ | if (@$restExpr) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | 0 | die $trans->node_error($node, "attr() should be last call."); | |||||||||||||||||||||||||||||||||||||||||||||
| 1406 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 1 | ▶ | if (ref $var->{cf_subtype}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 0 | die $trans->node_error($node, "nested subtype for attr"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1409 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 1 | my @expr = $trans->gen_entref_list($scope, $node, @args); | |||||||||||||||||||||||||||||||||||||||||||||
| 1411 | sprintf(q{YATT::attr('%s', %s)} | ||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | , $var->{cf_subtype} || $var->{cf_varname} | ||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | 1 | ▶ | , join(", ", $var->as_lvalue, @expr)); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$var->{'cf_subtype'} || $var->{'cf_varname'}
MC/DC0%0/2
$var->{'cf_subtype'} || $var->{'cf_varname'}
$var->{'cf_subtype'}
$var->{'cf_varname'}
Truth table33%1/3
A || B
A= $var->{'cf_subtype'}B= $var->{'cf_varname'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | 4 | ▶ | sub YATT::Translator::Perl::t_attr::as_escaped { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_escaped: called CC=3 SCAR=12.7
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | 4 | my t_attr $var = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1418 | 4 | ▶ | if (ref $var->{cf_subtype}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | 0 | die "nested subtype for attr: $var->{cf_varname}"; | |||||||||||||||||||||||||||||||||||||||||||||
| 1420 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | 4 | my $realvar = sprintf $var->lvalue_format, $var->{cf_varname}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1422 | sprintf(q{YATT::named_attr('%s', %s)} | ||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | , $var->{cf_subtype} || $var->{cf_varname} | ||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | 4 | ▶ | , $realvar); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$var->{'cf_subtype'} || $var->{'cf_varname'}
MC/DC0%0/2
$var->{'cf_subtype'} || $var->{'cf_varname'}
$var->{'cf_subtype'}
$var->{'cf_varname'}
Truth table33%1/3
A || B
A= $var->{'cf_subtype'}B= $var->{'cf_varname'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | 13 | ▶ | sub YATT::Translator::Perl::t_scalar::quote_assignable { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quote_assignable: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | 13 | shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1429 | 13 | ▶ | 'scalar(do {'.join("", map { ref $_ ? $$_ : $_ } @_).'})'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | 13 | ▶ | sub YATT::Translator::Perl::t_list::quote_assignable { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quote_assignable: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | 13 | shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1434 | 13 | ▶ | '['.join("", map { ref $_ ? $$_ : $_ } @_).']'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | 17 | ▶ | sub YATT::Translator::Perl::t_list::entmacro_expand { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
entmacro_expand: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | 17 | (my t_list $var, my MY $trans | |||||||||||||||||||||||||||||||||||||||||||||
| 1439 | , my ($scope, $node, $restExpr, $queue, @args)) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | 17 | my $was = join "->", splice @$queue, 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 1441 | 17 | sprintf q{map($_ ? @$_ : (), %s)}, $was; | |||||||||||||||||||||||||||||||||||||||||||||
| 1442 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | 2 | ▶ | sub YATT::Translator::Perl::t_list::entmacro_size { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
entmacro_size: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | 2 | (my t_list $var, my MY $trans | |||||||||||||||||||||||||||||||||||||||||||||
| 1446 | , my ($scope, $node, $restExpr, $queue, @args)) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 2 | my $was = join "->", splice @$queue, 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 2 | sprintf q{scalar(map(defined $_ ? @$_ : (), %s))}, $was; | |||||||||||||||||||||||||||||||||||||||||||||
| 1449 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | # XXX: head($n), tail($n) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | 0 | ▶ | sub YATT::Translator::Perl::t_list::entmacro_head { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
entmacro_head: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | 0 | (my t_list $var, my MY $trans | |||||||||||||||||||||||||||||||||||||||||||||
| 1455 | , my ($scope, $node, $restExpr, $queue, @args)) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | 0 | my $was = join "->", splice @$queue, 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 1457 | 0 | sprintf q{map($_ ? $$_[0] : (), %s)}, $was; | |||||||||||||||||||||||||||||||||||||||||||||
| 1458 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | 0 | ▶ | sub YATT::Translator::Perl::t_list::entmacro_tail { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
entmacro_tail: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | 0 | (my t_list $var, my MY $trans | |||||||||||||||||||||||||||||||||||||||||||||
| 1462 | , my ($scope, $node, $restExpr, $queue, @args)) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | 0 | my $was = join "->", splice @$queue, 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 0 | sprintf q{map($_ ? @{$_}[1..$#$_] : (), %s)}, $was; | |||||||||||||||||||||||||||||||||||||||||||||
| 1465 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | 25 | ▶ | sub YATT::Translator::Perl::t_code::gen_call { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_call: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | 25 | (my t_code $argdecl, my MY $trans, my ($scope, $node)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1469 | 25 | my ($post, @args) = $trans->genargs_static | |||||||||||||||||||||||||||||||||||||||||||||
| 1470 | ($scope, $node->open, $argdecl->arg_specs); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | # XXX: こっちを () しなくて済むのはなぜ? => <yatt:tag/> の call だから? | ||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | 25 | return \ sprintf '%1$s && %1$s->(%2$s)%3$s', $argdecl->as_lvalue | |||||||||||||||||||||||||||||||||||||||||||||
| 1473 | , join(", ", @args), $post; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | 31 | ▶ | sub YATT::Translator::Perl::t_code::arg_specs { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arg_specs: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | 31 | my t_code $argdecl = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1478 | 31 | ▶ | ($argdecl->{arg_dict} ||= {}, $argdecl->{arg_order} ||= []); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$argdecl->{"arg_dict"} ||= {}
$argdecl->{"arg_order"} ||= []
MC/DC100%1/1
$argdecl->{"arg_dict"} ||= {}
$argdecl->{"arg_dict"}
MC/DC100%1/1
$argdecl->{"arg_order"} ||= []
$argdecl->{"arg_order"}
Truth table100%2/2
A
A= $argdecl->{"arg_dict"}
Truth table100%2/2
A
A= $argdecl->{"arg_order"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | 39 | ▶ | sub YATT::Translator::Perl::t_code::gen_args { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_args: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | 39 | (my t_code $argdecl) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1483 | return unless $argdecl->{arg_order} | ||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | 39 | ▶ | && (my @args = @{$argdecl->{arg_order}}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$argdecl->{"arg_order"} and my(@args) = @{$argdecl->{"arg_order"};}
MC/DC100%2/2
$argdecl->{"arg_order"} and my(@args) = @{$argdecl->{"arg_order"};}
$argdecl->{"arg_order"}
my(@args) = @{$argdecl->{"arg_order"};}
Truth table100%3/3
A and B
A= $argdecl->{"arg_order"}B= my(@args) = @{$argdecl->{"arg_order"};}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | \ sprintf('my (%s) = @_', join(", ", map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | 9 | $argdecl->{arg_dict}{$_}->as_lvalue; | |||||||||||||||||||||||||||||||||||||||||||||
| 1487 | } @args)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | 40 | ▶ | sub YATT::Translator::Perl::t_code::gen_body { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_body: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | 40 | (my t_code $argdecl, my MY $trans, my ($scope, $is_expr, $node)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1492 | 40 | ▶ | return unless $node->array_size; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | 40 | ▶ | if ($is_expr) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | 1 | $trans->genexpr_node($scope, ENT_RAW, $node); | |||||||||||||||||||||||||||||||||||||||||||||
| 1495 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | $trans->as_statement_list | ||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | ($argdecl->gen_args | ||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | 39 | , $trans->generate_body([{}, [$argdecl->{arg_dict}, $scope]], $node)); | |||||||||||||||||||||||||||||||||||||||||||||
| 1499 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | 40 | ▶ | sub YATT::Translator::Perl::t_code::gen_assignable_node { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_assignable_node: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | 40 | (my t_code $argdecl, my MY $trans, my ($scope, $node, $is_opened)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1504 | 40 | ▶ | my $is_expr = !$is_opened && !$node->is_quoted_by_element; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$is_opened || $node->is_quoted_by_element
MC/DC100%2/2
$is_opened || $node->is_quoted_by_element
$is_opened
$node->is_quoted_by_element
Truth table100%3/3
A || B
A= $is_openedB= $node->is_quoted_by_element
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | 40 | ▶ | $trans->as_sub('', $argdecl->gen_body($trans, $scope, $is_expr | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | , $is_opened ? $node : $node->open)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | 12 | ▶ | sub YATT::Translator::Perl::t_code::has_arg { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_arg: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | 12 | (my t_code $argdecl, my ($name)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1511 | 12 | defined $argdecl->{arg_dict}{$name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1512 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | 13 | ▶ | sub YATT::Translator::Perl::t_code::add_arg { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_arg: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | 13 | (my t_code $codevar, my ($name, $arg)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1516 | 13 | add_arg_order_in($codevar->{arg_dict}, $codevar->{arg_order}, $name, $arg); | |||||||||||||||||||||||||||||||||||||||||||||
| 1517 | 13 | $codevar; | |||||||||||||||||||||||||||||||||||||||||||||
| 1518 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | 6 | ▶ | sub YATT::Translator::Perl::t_code::clone { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | 6 | (my t_code $orig) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1522 | 6 | my t_code $new = $orig->SUPER::clone; | |||||||||||||||||||||||||||||||||||||||||||||
| 1523 | 6 | my ($dict, $order) = $orig->arg_specs; | |||||||||||||||||||||||||||||||||||||||||||||
| 1524 | 6 | foreach my $name (@$order) { | |||||||||||||||||||||||||||||||||||||||||||||
| 1525 | 1 | $new->add_arg($name, $dict->{$name}->clone); | |||||||||||||||||||||||||||||||||||||||||||||
| 1526 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | $new | ||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | 6 | } | |||||||||||||||||||||||||||||||||||||||||||||
| 1529 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | # code 型の変数宣言の生成 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | 172 | ▶ | sub create_var_code { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_var_code: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | 172 | (my MY $trans, my ($node, @param)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1533 | 172 | my t_code $codevar = $trans->t_code->new(@param); | |||||||||||||||||||||||||||||||||||||||||||||
| 1534 | 172 | ▶ | $trans->define_args($codevar, $node->open) if $node; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | 172 | $codevar; | |||||||||||||||||||||||||||||||||||||||||||||
| 1536 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | 5 | ▶ | sub YATT::Translator::Perl::t_delegate::gen_call { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_call: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | 5 | (my t_delegate $argdecl, my MY $trans, my ($scope, $node)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1540 | my $func = $trans->get_funcname_to($trans->{cf_mode} | ||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | 5 | , $argdecl->{cf_base_widget}); | |||||||||||||||||||||||||||||||||||||||||||||
| 1542 | # XXX: テストを書け。body が code か html か、だ。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | # my $body_dict = $argdecl->{cf_base_widget}->get_arg_spec(body => undef); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | 5 | my $body_spec = $argdecl->{cf_base_widget}->{arg_dict}->{body}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1545 | 5 | my $body_scope = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 1546 | 5 | ▶ | if ($body_spec->type_name eq 'code') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | 5 | [$body_spec->{arg_dict}, $scope] | |||||||||||||||||||||||||||||||||||||||||||||
| 1548 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | 0 | $scope | |||||||||||||||||||||||||||||||||||||||||||||
| 1550 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | 5 | my ($post, @args) = $trans->genargs_static | |||||||||||||||||||||||||||||||||||||||||||||
| 1553 | ([{}, $body_scope] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | , $node->open, $argdecl->arg_specs); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | return \ sprintf(' %s($this, [%s])%s', $func | ||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | 5 | ▶ | , join(", ", map {defined $_ ? $_ : 'undef'} @args) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | , $post); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | 5 | ▶ | sub YATT::Translator::Perl::t_delegate::arg_specs { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arg_specs: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | 5 | my t_delegate $argdecl = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1562 | ($argdecl->{cf_base_widget}->arg_specs | ||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | 5 | , $argdecl->{cf_delegate_vars}); | |||||||||||||||||||||||||||||||||||||||||||||
| 1564 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | 7 | ▶ | sub make_arg_spec { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_arg_spec: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | 7 | my ($dict, $order) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 1570 | 7 | foreach my $name (@_) { | |||||||||||||||||||||||||||||||||||||||||||||
| 1571 | 19 | $dict->{$name} = @$order; | |||||||||||||||||||||||||||||||||||||||||||||
| 1572 | 19 | push @$order, $name; | |||||||||||||||||||||||||||||||||||||||||||||
| 1573 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | 109 | ▶ | sub arg_name_types { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arg_name_types: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 109 | (my MY $trans, my ($args)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1578 | 109 | my (@path) = $args->node_path; | |||||||||||||||||||||||||||||||||||||||||||||
| 1579 | 109 | ▶ | if ($args->is_attribute and $args->is_quoted_by_element) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args->is_attribute and $args->is_quoted_by_element
MC/DC50%1/2
$args->is_attribute and $args->is_quoted_by_element
$args->is_attribute
$args->is_quoted_by_element
Truth table66%2/3
A and B
A= $args->is_attributeB= $args->is_quoted_by_element
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | 8 | shift @path; | |||||||||||||||||||||||||||||||||||||||||||||
| 1581 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | 109 | my ($name) = shift @path; | |||||||||||||||||||||||||||||||||||||||||||||
| 1583 | 109 | ▶ | @path >= 2 ? ($name, \@path) : ($name, $path[0]); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | # macro の、 my:type=var など専用。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 14 | ▶ | sub feed_arg_spec { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
feed_arg_spec: called CC=6 SCAR=18.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | 14 | (my MY $trans, my ($args, $arg_dict, $arg_order)) = splice @_, 0, 4; | |||||||||||||||||||||||||||||||||||||||||||||
| 1589 | 14 | my $found; | |||||||||||||||||||||||||||||||||||||||||||||
| 1590 | 14 | ▶ | for (my $nth = 0; $args->readable; $args->next) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | 31 | ▶ | last unless $args->is_primary_attribute; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | 17 | my ($name, @ext) = $args->node_path; | |||||||||||||||||||||||||||||||||||||||||||||
| 1593 | 17 | ▶ | unless (defined $name) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | 4 | ▶ | $name = $arg_order->[$nth++] | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | or die $trans->node_error($args, "Too many args"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | 17 | ▶ | defined (my $argno = $arg_dict->{$name}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | or die $trans->node_error($args, "Unknown arg '%s'", $name); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | 17 | $_[$argno] = $args->current; | |||||||||||||||||||||||||||||||||||||||||||||
| 1601 | 17 | $found++; | |||||||||||||||||||||||||||||||||||||||||||||
| 1602 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | 14 | $found; | |||||||||||||||||||||||||||||||||||||||||||||
| 1604 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | # list=list/value, my=text, ith=text | ||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | 3 | make_arg_spec(\ my %arg_dict, \ my @arg_order | |||||||||||||||||||||||||||||||||||||||||||||
| 1609 | , qw(list my ith)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | 3 | declare_alias macro_yatt_foreach => \¯o_foreach; | |||||||||||||||||||||||||||||||||||||||||||||
| 1612 | 6 | ▶ | sub macro_foreach { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
macro_foreach: called CC=8 SCAR=21.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | 6 | (my MY $trans, my ($scope, $args, $fragment)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1614 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | 6 | ▶ | $trans->feed_arg_spec($args, \%arg_dict, \@arg_order | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | , my ($list, $my, $ith)) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | or die $trans->node_error($args, "Not enough arguments"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | 6 | ▶ | unless (defined $list) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | 0 | die $trans->node_error($args, "no list= is given"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1621 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | # $ith をまだ使っていない。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | 6 | my %local; | |||||||||||||||||||||||||||||||||||||||||||||
| 1625 | 6 | my $loopvar = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 1626 | 6 | ▶ | if ($my) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | 5 | my ($x, @type) = node_path($my); | |||||||||||||||||||||||||||||||||||||||||||||
| 1628 | 5 | my $varname = node_body($my); | |||||||||||||||||||||||||||||||||||||||||||||
| 1629 | 5 | ▶ | $local{$varname} = $trans->create_var | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$type[0] || ''
MC/DC0%0/1
$type[0] || ''
$type[0]
Truth table50%1/2
A
A= $type[0]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | ($type[0] || '', undef, varname => $varname); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | 5 | 'my $' . $varname; | |||||||||||||||||||||||||||||||||||||||||||||
| 1632 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | # _ は? entity 自体に処理させるか… | ||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | 1 | '' | |||||||||||||||||||||||||||||||||||||||||||||
| 1635 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | 6 | my $fmt = q{foreach %1$s (%2$s) %3$s}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1639 | 6 | my $listexpr = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 1640 | 6 | if (0) { | |||||||||||||||||||||||||||||||||||||||||||||
| 1641 | print STDERR "# foreach list: " | ||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | , YATT::LRXML::Node::stringify_node($list), "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | # XXX: 何故使い分けが必要になってしまうのか? | ||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | # my $fc = $args->adopter_for($list); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | # my $fc = $trans->fake_cursor_from($args, $list); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | 6 | ▶ | if (my $var = $trans->has_pass_through_var | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | ($scope, my $fc = $trans->fake_cursor_from($args, $list), 'list')) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | 3 | ▶ | unless ($var->type_name eq 'list') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | 1 | my $path = $args->parent->node_path; | |||||||||||||||||||||||||||||||||||||||||||||
| 1651 | 1 | die $trans->node_error($fc, "$path - should be list type") | |||||||||||||||||||||||||||||||||||||||||||||
| 1652 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | 2 | '@'.$var->as_lvalue; | |||||||||||||||||||||||||||||||||||||||||||||
| 1654 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | 3 | $trans->genexpr_node($scope, 0, $args->adopter_for($list)); | |||||||||||||||||||||||||||||||||||||||||||||
| 1656 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | 5 | my @statements = $trans->as_statement_list | |||||||||||||||||||||||||||||||||||||||||||||
| 1659 | ($trans->generate_body([\%local, $scope], $args)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | 5 | ▶ | if ($fragment) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | 0 | ($fmt, $loopvar, $listexpr, \@statements); | |||||||||||||||||||||||||||||||||||||||||||||
| 1663 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | 5 | \ sprintf $fmt, $loopvar, $listexpr, $trans->as_block(@statements); | |||||||||||||||||||||||||||||||||||||||||||||
| 1665 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | # if | ||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | 3 | make_arg_spec(\ my %arg_dict, \ my @arg_order | |||||||||||||||||||||||||||||||||||||||||||||
| 1672 | , qw(if unless)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | 8 | ▶ | sub gen_macro_if_arm { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_macro_if_arm: called CC=8 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | 8 | (my MY $trans, my ($scope, $primary, $pkg, $if, $unless, $body)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1675 | 8 | my $header = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 1676 | 8 | ▶ | if ($primary) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | 5 | my ($kw, $cond) = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 1678 | 5 | ▶ | if ($if) { (if => $if) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | 0 | elsif ($unless) { (unless => $unless) } | |||||||||||||||||||||||||||||||||||||||||||||
| 1680 | 0 | else { die "??" } | |||||||||||||||||||||||||||||||||||||||||||||
| 1681 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | 5 | sprintf q{%s (%s) }, $kw | |||||||||||||||||||||||||||||||||||||||||||||
| 1683 | , $trans->genexpr_node($scope, 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | , $trans->fake_cursor_from($body, $cond, 1)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | 3 | my ($cond, $true) = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 1687 | 3 | ▶ | if ($if) { ($if, 1) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | 0 | elsif ($unless) { ($unless, 0) } | |||||||||||||||||||||||||||||||||||||||||||||
| 1689 | else {} | ||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | 3 | ▶ | unless (defined $cond) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | 2 | q{else } | |||||||||||||||||||||||||||||||||||||||||||||
| 1693 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | 1 | my $expr = $trans->genexpr_node | |||||||||||||||||||||||||||||||||||||||||||||
| 1695 | ($scope, 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | , $trans->fake_cursor_from($body, $cond, 1)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | 1 | ▶ | sprintf q{elsif (%s) }, $true ? $expr : qq{not($expr)}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | 8 | $header . $trans->as_block | |||||||||||||||||||||||||||||||||||||||||||||
| 1702 | ($trans->as_statement_list | ||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | ($trans->generate_body($scope, $body))); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | 3 | declare_alias macro_yatt_if => \¯o_if; | |||||||||||||||||||||||||||||||||||||||||||||
| 1707 | 5 | ▶ | sub macro_if { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
macro_if: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | 5 | (my MY $trans, my ($scope, $args)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1709 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | 5 | my @case = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 1711 | 5 | ▶ | $trans->feed_arg_spec($args, \%arg_dict, \@arg_order | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | , my ($if, $unless)) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | or die $trans->node_error($args, "Not enough arguments"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | 5 | ([$if, $unless, $args->variant_builder]); | |||||||||||||||||||||||||||||||||||||||||||||
| 1715 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | 5 | ▶ | for (; $args->readable; $args->next) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | 12 | ▶ | if ($args->is_attribute && $args->node_name eq 'else') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args->is_attribute and $args->node_name eq "else"
MC/DC50%1/2
$args->is_attribute and $args->node_name eq "else"
$args->is_attribute
$args->node_name eq "else"
Truth table66%2/3
A and B
A= $args->is_attributeB= $args->node_name eq "else"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | 3 | my $kid = $args->open; | |||||||||||||||||||||||||||||||||||||||||||||
| 1719 | 3 | $trans->feed_arg_spec($kid, \%arg_dict, \@arg_order | |||||||||||||||||||||||||||||||||||||||||||||
| 1720 | , my ($if, $unless)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | 3 | push @case, [$if, $unless, $kid]; | |||||||||||||||||||||||||||||||||||||||||||||
| 1722 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | # XXX: 多分、$case[0] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | 9 | $case[-1][-1]->add_node($args->current); | |||||||||||||||||||||||||||||||||||||||||||||
| 1725 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | 5 | my $pkg = $trans->get_package_from_node($args); | |||||||||||||||||||||||||||||||||||||||||||||
| 1729 | 5 | my @script = $trans->gen_macro_if_arm($scope, 1, $pkg, @{shift @case}); | |||||||||||||||||||||||||||||||||||||||||||||
| 1730 | 5 | ▶ | while (my $arm = shift @case) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | 3 | push @script, $trans->gen_macro_if_arm($scope, 0, $pkg, @$arm); | |||||||||||||||||||||||||||||||||||||||||||||
| 1732 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | 5 | \ join " ", @script; | |||||||||||||||||||||||||||||||||||||||||||||
| 1734 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | 3 | declare_alias macro_yatt_block => \¯o_block; | |||||||||||||||||||||||||||||||||||||||||||||
| 1739 | 3 | ▶ | sub macro_block { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
macro_block: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | 3 | (my MY $trans, my ($scope, $args)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1741 | 3 | \ $trans->as_block | |||||||||||||||||||||||||||||||||||||||||||||
| 1742 | ($trans->as_statement_list | ||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | ($trans->generate_body([{}, $scope], $args))); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | 3 | declare_alias macro_yatt_my => \¯o_my; | |||||||||||||||||||||||||||||||||||||||||||||
| 1747 | 6 | ▶ | sub macro_my { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
macro_my: called CC=13 SCAR=26.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | 6 | (my MY $trans, my ($scope, $args)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1749 | 6 | my @assign; | |||||||||||||||||||||||||||||||||||||||||||||
| 1750 | 6 | my $filename = $args->metainfo->filename; | |||||||||||||||||||||||||||||||||||||||||||||
| 1751 | 6 | ▶ | for (; $args->readable; $args->next) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | 8 | ▶ | last unless $args->is_primary_attribute; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | 7 | my ($name, $typename) = $trans->arg_name_types($args); | |||||||||||||||||||||||||||||||||||||||||||||
| 1754 | 7 | ▶ | $typename ||= $args->next_is_body ? 'html' : 'text'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$typename ||= $args->next_is_body ? "html" : "text"
MC/DC0%0/2
$typename ||= $args->next_is_body ? "html" : "text"
$typename
$args->next_is_body ? "html" : "text"
Truth table66%2/3
A ||= B
A= $typenameB= $args->next_is_body ? "html" : "text"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | 7 | ▶ | if (my VarType $old = $scope->[0]{$name}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | die $trans->node_error | ||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | ($args, "Variable '%s' redefined (previously at file %s line %s)" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | , $name, $old->{cf_filename} || '(unknown)' | ||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | 0 | ▶ | , $old->{cf_linenum} || '(unknown)'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$old->{'cf_filename'} || '(unknown)'
$old->{'cf_linenum'} || '(unknown)'
MC/DC0%0/1
$old->{'cf_filename'} || '(unknown)'
$old->{'cf_filename'}
MC/DC0%0/1
$old->{'cf_linenum'} || '(unknown)'
$old->{'cf_linenum'}
Truth table0%0/2
A
A= $old->{'cf_filename'}
Truth table0%0/2
A
A= $old->{'cf_linenum'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | 7 | my $var = $scope->[0]{$name} | |||||||||||||||||||||||||||||||||||||||||||||
| 1762 | = $trans->create_var($typename, $args | ||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | , varname => $name | ||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | , filename => $filename | ||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | , linenum => $args->linenum); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | 7 | ▶ | push @assign, [$var, $args->node_size | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | ? $var->gen_assignable_node($trans, $scope, $args) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | : ()]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | 6 | ▶ | if ($args->readable) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | 1 | my $var = $assign[-1][0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 1774 | 1 | ▶ | $assign[-1][1] ||= $var->gen_assignable_node($trans, $scope, $args, 1); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$assign[-1][1] ||= $var->gen_assignable_node($trans, $scope, $args, 1)
MC/DC0%0/2
$assign[-1][1] ||= $var->gen_assignable_node($trans, $scope, $args, 1)
$assign[-1][1]
$var->gen_assignable_node($trans, $scope, $args, 1)
Truth table33%1/3
A ||= B
A= $assign[-1][1]B= $var->gen_assignable_node($trans, $scope, $args, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | 6 | my @script; | |||||||||||||||||||||||||||||||||||||||||||||
| 1778 | 6 | foreach my $desc (@assign) { | |||||||||||||||||||||||||||||||||||||||||||||
| 1779 | 7 | my ($var, $value) = @$desc; | |||||||||||||||||||||||||||||||||||||||||||||
| 1780 | 7 | my $script = sprintf q{my %s}, $var->as_lvalue; | |||||||||||||||||||||||||||||||||||||||||||||
| 1781 | 7 | ▶ | $script .= q{ = } . $value if defined $value; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | 7 | push @script, \ $script; | |||||||||||||||||||||||||||||||||||||||||||||
| 1783 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | 6 | @script; | |||||||||||||||||||||||||||||||||||||||||||||
| 1785 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | 3 | declare_alias macro_yatt_format => \¯o_format; | |||||||||||||||||||||||||||||||||||||||||||||
| 1790 | 3 | ▶ | sub macro_format { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
macro_format: called CC=4 SCAR=14.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | 3 | (my MY $trans, my ($scope, $args)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1792 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | 3 | ▶ | unless ($args->readable && $args->is_primary_attribute) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args->readable and $args->is_primary_attribute
MC/DC0%0/2
$args->readable and $args->is_primary_attribute
$args->readable
$args->is_primary_attribute
Truth table33%1/3
A and B
A= $args->readableB= $args->is_primary_attribute
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | 0 | die $trans->node_error($args, "format parameter is missing"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1795 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | 3 | my $name = $args->node_name; | |||||||||||||||||||||||||||||||||||||||||||||
| 1798 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | 3 | my $format = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 1800 | 3 | ▶ | if (my $var = $trans->has_pass_through_var($scope, $args, $name)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | 1 | $var->as_lvalue; | |||||||||||||||||||||||||||||||||||||||||||||
| 1802 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | 2 | $trans->faked_gentype(text => $scope, $args); | |||||||||||||||||||||||||||||||||||||||||||||
| 1804 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | 3 | $args->next; | |||||||||||||||||||||||||||||||||||||||||||||
| 1808 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | 3 | sprintf(q|sprintf(%s, %s)| | |||||||||||||||||||||||||||||||||||||||||||||
| 1810 | , $format | ||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | , $trans->as_join($trans->generate_body([{}, $scope], $args))); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | 3 | ▶ | sub macro_dbfetch { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
macro_dbfetch: not called CC=1 SCAR=2.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | 0 | require YATT::Translator::Perl::macro_dbfetch; | |||||||||||||||||||||||||||||||||||||||||||||
| 1817 | 0 | shift->YATT::Translator::Perl::macro_dbfetch::macro(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 1818 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | 0 | ▶ | sub feed_arg_or_make_hash_of { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
feed_arg_or_make_hash_of: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | 0 | (my $trans | |||||||||||||||||||||||||||||||||||||||||||||
| 1822 | , my ($type, $scope, $args, $arg_dict, $arg_order)) = splice @_, 0, 6; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | 0 | my (@primary, @secondary); | |||||||||||||||||||||||||||||||||||||||||||||
| 1824 | 0 | ▶ | for (my $nth = 0; $args->readable; $args->next) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | 0 | ▶ | last unless $args->is_primary_attribute; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | 0 | my ($name, @ext) = $args->node_path; | |||||||||||||||||||||||||||||||||||||||||||||
| 1827 | 0 | ▶ | unless (defined $name) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | 0 | ▶ | $name = $arg_order->[$nth++] | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | or die $trans->node_error($args, "Too many args"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | 0 | ▶ | if ($name =~ /^-(.*)/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | # XXX: そもそも -name=[...] で構造化したかった | ||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | 0 | push @secondary, [$name, $trans->faked_gentype | |||||||||||||||||||||||||||||||||||||||||||||
| 1834 | ($type => $scope, $args, $args->current)]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 1836 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | 0 | ▶ | defined (my $argno = $arg_dict->{$name}) or do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | 0 | push @primary, [$name, $trans->faked_gentype | |||||||||||||||||||||||||||||||||||||||||||||
| 1839 | ($type => $scope, $args, $args->current)]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 1841 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | 0 | $_[$argno] = $args->current; | |||||||||||||||||||||||||||||||||||||||||||||
| 1844 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | 0 | ▶ | grep {@$_ ? $_ : ()} (\@primary, \@secondary); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | 4 | ▶ | sub entmacro_if { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
entmacro_if: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | 4 | my ($this, $trans | |||||||||||||||||||||||||||||||||||||||||||||
| 1851 | , $scope, $node, $restExpr, $queue, @args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | # XXX: $cond を文字列にするのは不便。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | 4 | my ($cond, $then, $else) | |||||||||||||||||||||||||||||||||||||||||||||
| 1854 | = $trans->gen_entref_list($scope, $node, @args); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | # XXX: 三項演算だと、狂いが出そうな。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | sprintf q{((%s) ? %s : %s)} | ||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | 4 | ▶ | , map {ref $_ ? $$_ : $_} $cond, $then, $else || q{''}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$else || q['']
MC/DC0%0/1
$else || q['']
$else
Truth table50%1/2
A
A= $else
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | 2 | ▶ | sub entmacro_render { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
entmacro_render: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | 2 | my ($this, $trans | |||||||||||||||||||||||||||||||||||||||||||||
| 1862 | , $scope, $node, $restExpr, $queue, @args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | 2 | my ($type, @expr) | |||||||||||||||||||||||||||||||||||||||||||||
| 1864 | = $trans->gen_entref_list($scope, $node, @args); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | 2 | \ sprintf q{__PACKAGE__->can('render_'.%s)->($this, [%s])} | |||||||||||||||||||||||||||||||||||||||||||||
| 1866 | , $type, join(", ", @expr); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | 352 | ▶ | sub paren_escape ($) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
paren_escape: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | 352 | ▶ | unless (defined $_[0]) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | 0 | confess "Undefined text"; | |||||||||||||||||||||||||||||||||||||||||||||
| 1873 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | 352 | $_[0] =~ s{([\(\)\\])}{\\$1}g; | |||||||||||||||||||||||||||||||||||||||||||||
| 1875 | 352 | $_[0] | |||||||||||||||||||||||||||||||||||||||||||||
| 1876 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | 352 | ▶ | sub qparen ($) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
qparen: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | 352 | 'q('.paren_escape($_[0]).')' | |||||||||||||||||||||||||||||||||||||||||||||
| 1880 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | 26 | ▶ | sub qqvalue ($) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
qqvalue: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | 26 | 'q'.qparen($_[0]); | |||||||||||||||||||||||||||||||||||||||||||||
| 1884 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | 3 | my %map = ("\r", "r", "\n", "n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1888 | 129 | ▶ | sub qcrlf ($) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
qcrlf: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | 129 | my ($crlf) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1890 | 129 | $crlf =~ s{([\r\n])}{\\$map{$1}}g; | |||||||||||||||||||||||||||||||||||||||||||||
| 1891 | 129 | $crlf; | |||||||||||||||||||||||||||||||||||||||||||||
| 1892 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | 3 | ▶ | sub dots_for_arrows { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dots_for_arrows: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | 31 | shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1897 | 31 | ▶ | return unless defined $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | 31 | $_[0] =~ s{\b\.(?=\w+\()}{->}g; | |||||||||||||||||||||||||||||||||||||||||||||
| 1899 | 31 | $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 1900 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||