| 1 | ## no critic (ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||
| 2 | package Text::Template::Simple::Base::Compiler; | ||||||||||||||||||||||||||||
| 3 | 32 | $Text::Template::Simple::Base::Compiler::VERSION = '0.91'; | |||||||||||||||||||||||||||
| 4 | 32 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 32 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 32 | ▶ | use Text::Template::Simple::Util qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 32 | ▶ | use Text::Template::Simple::Constants qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 253 | ▶ | sub _init_compile_opts { | ||||||||||||||||||||||||||
|
Subroutine
_init_compile_opts: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||
| 11 | 253 | my $self = shift; | |||||||||||||||||||||||||||
| 12 | 253 | ▶ | my $opt = shift || {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || {}
MC/DC100%1/1
shift() || {}
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 253 | ▶ | fatal('tts.base.compiler._compile.opt') if ref $opt ne 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | # set defaults | ||||||||||||||||||||||||||||
| 17 | 253 | ▶ | $opt->{id} ||= EMPTY_STRING; # id is AUTO | ||||||||||||||||||||||||||
|
Condition100%2/2
$opt->{"id"} ||= ""
MC/DC100%1/1
$opt->{"id"} ||= ""
$opt->{"id"}
Truth table100%2/2
A
A= $opt->{"id"}
| |||||||||||||||||||||||||||||
| 18 | 253 | ▶ | $opt->{map_keys} ||= 0; # use normal behavior | ||||||||||||||||||||||||||
|
Condition100%2/2
$opt->{"map_keys"} ||= 0
MC/DC100%1/1
$opt->{"map_keys"} ||= 0
$opt->{"map_keys"}
Truth table100%2/2
A
A= $opt->{"map_keys"}
| |||||||||||||||||||||||||||||
| 19 | 253 | ▶ | $opt->{chkmt} ||= 0; # check mtime of file template? | ||||||||||||||||||||||||||
|
Condition100%2/2
$opt->{"chkmt"} ||= 0
MC/DC100%1/1
$opt->{"chkmt"} ||= 0
$opt->{"chkmt"}
Truth table100%2/2
A
A= $opt->{"chkmt"}
| |||||||||||||||||||||||||||||
| 20 | 253 | ▶ | $opt->{_sub_inc} ||= 0; # are we called from a dynamic include op? | ||||||||||||||||||||||||||
|
Condition100%2/2
$opt->{"_sub_inc"} ||= 0
MC/DC100%1/1
$opt->{"_sub_inc"} ||= 0
$opt->{"_sub_inc"}
Truth table100%2/2
A
A= $opt->{"_sub_inc"}
| |||||||||||||||||||||||||||||
| 21 | 253 | ▶ | $opt->{_filter} ||= EMPTY_STRING; # any filters? | ||||||||||||||||||||||||||
|
Condition100%2/2
$opt->{"_filter"} ||= ""
MC/DC100%1/1
$opt->{"_filter"} ||= ""
$opt->{"_filter"}
Truth table100%2/2
A
A= $opt->{"_filter"}
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # first element is the shared names. if it's not defined, then there | ||||||||||||||||||||||||||||
| 24 | # are no shared variables from top level | ||||||||||||||||||||||||||||
| 25 | 253 | ▶ | if ( ref $opt->{_share} eq 'ARRAY' && ! defined $opt->{_share}[0] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $opt->{"_share"} eq "ARRAY" and not defined $opt->{"_share"}[0]
MC/DC100%2/2
ref $opt->{"_share"} eq "ARRAY" and not defined $opt->{"_share"}[0]
ref $opt->{"_share"} eq "ARRAY"
not defined $opt->{"_share"}[0]
Truth table100%3/3
A and not(B)
A= ref $opt->{"_share"} eq "ARRAY"B= not defined $opt->{"_share"}[0]
| |||||||||||||||||||||||||||||
| 26 | 6 | delete $opt->{_share}; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 253 | ▶ | $opt->{as_is} = $opt->{_sub_inc} && $opt->{_sub_inc} == T_STATIC; | ||||||||||||||||||||||||||
|
Condition100%3/3
$opt->{'_sub_inc'} && $opt->{'_sub_inc'} == 10
MC/DC100%2/2
$opt->{'_sub_inc'} && $opt->{'_sub_inc'} == 10
$opt->{'_sub_inc'}
$opt->{'_sub_inc'} == 10
Truth table100%3/3
A && B
A= $opt->{'_sub_inc'}B= $opt->{'_sub_inc'} == 10
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 253 | return $opt; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 125 | ▶ | sub _validate_chkmt { | ||||||||||||||||||||||||||
|
Subroutine
_validate_chkmt: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 35 | 125 | my($self, $chkmt_ref, $tmpx) = @_; | |||||||||||||||||||||||||||
| 36 | 125 | ${$chkmt_ref} = $self->[TYPE] eq 'FILE' | |||||||||||||||||||||||||||
| 37 | ? (stat $tmpx)[STAT_MTIME] | ||||||||||||||||||||||||||||
| 38 | 125 | ▶ | : do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 1 | ▶ | DEBUG && LOG( DISABLE_MT => | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 'Disabling chkmt. Template is not a file'); | ||||||||||||||||||||||||||||
| 41 | 1 | 0; | |||||||||||||||||||||||||||
| 42 | }; | ||||||||||||||||||||||||||||
| 43 | 125 | return; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 9 | ▶ | sub _compile_cache { | ||||||||||||||||||||||||||
|
Subroutine
_compile_cache: called CC=6 SCAR=19.5
| |||||||||||||||||||||||||||||
| 47 | 9 | my($self, $tmp, $opt, $id_ref, $code_ref) = @_; | |||||||||||||||||||||||||||
| 48 | 9 | my $method = $opt->{id}; | |||||||||||||||||||||||||||
| 49 | 9 | ▶ | my $auto_id = ! $method || $method eq 'AUTO'; | ||||||||||||||||||||||||||
|
Condition66%2/3
!$method || $method eq 'AUTO'
MC/DC50%1/2
!$method || $method eq 'AUTO'
!$method
$method eq 'AUTO'
Truth table66%2/3
not(A) || B
A= !$methodB= $method eq 'AUTO'
| |||||||||||||||||||||||||||||
| 50 | 9 | ▶ | ${ $id_ref } = $self->connector('Cache::ID')->new->generate( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | $auto_id ? ( $tmp ) : ( $method, 'custom' ) | ||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | # prevent overwriting the compiled version in cache | ||||||||||||||||||||||||||||
| 55 | # since we need the non-compiled version | ||||||||||||||||||||||||||||
| 56 | 0 | ▶ | ${ $id_ref } .= '_1' if $opt->{as_is}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 9 | ${ $code_ref } = $self->cache->hit( ${$id_ref}, $opt->{chkmt} ); | |||||||||||||||||||||||||||
| 59 | 0 | ▶ | LOG( CACHE_HIT => ${$id_ref} ) if DEBUG && ${$code_ref}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
DEBUG() and ${$code_ref;}
MC/DC0%0/2
DEBUG() and ${$code_ref;}
DEBUG()
${$code_ref;}
Truth table33%1/3
A and B
A= DEBUG()B= ${$code_ref;}
| |||||||||||||||||||||||||||||
| 60 | 9 | return; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 253 | ▶ | sub _compile { | ||||||||||||||||||||||||||
|
Subroutine
_compile: called CC=20 SCAR=30.6
| |||||||||||||||||||||||||||||
| 64 | 253 | my $self = shift; | |||||||||||||||||||||||||||
| 65 | 253 | ▶ | my $tmpx = shift || fatal('tts.base.compiler._compile.notmp'); | ||||||||||||||||||||||||||
|
Condition33%1/3
shift() || fatal('tts.base.compiler._compile.notmp')
MC/DC0%0/2
shift() || fatal('tts.base.compiler._compile.notmp')
shift()
fatal('tts.base.compiler._compile.notmp')
Truth table33%1/3
A || B
A= shift()B= fatal('tts.base.compiler._compile.notmp')
| |||||||||||||||||||||||||||||
| 66 | 253 | ▶ | my $param = shift || []; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || []
MC/DC100%1/1
shift() || []
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 67 | 253 | my $opt = $self->_init_compile_opts( shift ); | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 253 | ▶ | fatal('tts.base.compiler._compile.param') if ref $param ne 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 253 | my $tmp = $self->_examine( $tmpx ); | |||||||||||||||||||||||||||
| 72 | 251 | ▶ | return $tmp if $self->[TYPE] eq 'ERROR'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 251 | ▶ | if ( $opt->{_sub_inc} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | # TODO:generate a single error handler for includes, merge with _include() | ||||||||||||||||||||||||||||
| 76 | # tmpx is a "file" included from an upper level compile() | ||||||||||||||||||||||||||||
| 77 | 133 | my $etitle = $self->_include_error( T_DYNAMIC ); | |||||||||||||||||||||||||||
| 78 | 133 | my $exists = $self->io->file_exists( $tmpx ); | |||||||||||||||||||||||||||
| 79 | 133 | ▶ | return $etitle . " '$tmpx' is not a file" if not $exists; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | # TODO: remove this second call somehow, reduce to a single call | ||||||||||||||||||||||||||||
| 81 | 133 | $tmp = $self->_examine( $exists ); # re-examine | |||||||||||||||||||||||||||
| 82 | 133 | $self->[NEEDS_OBJECT]++; # interpolated includes will need that | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 251 | ▶ | $self->_validate_chkmt( \$opt->{chkmt}, $tmpx ) if $opt->{chkmt}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 251 | ▶ | LOG( COMPILE => $opt->{id} ) if DEBUG && defined $opt->{id}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
DEBUG() and defined $opt->{"id"}
MC/DC0%0/2
DEBUG() and defined $opt->{"id"}
DEBUG()
defined $opt->{"id"}
Truth table33%1/3
A and B
A= DEBUG()B= defined $opt->{"id"}
| |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 251 | my $cache_id = EMPTY_STRING; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 251 | my($CODE); | |||||||||||||||||||||||||||
| 92 | 251 | ▶ | $self->_compile_cache( $tmp, $opt, \$cache_id, \$CODE ) if $self->[CACHE]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 251 | $self->cache->id( $cache_id ); # if $cache_id; | |||||||||||||||||||||||||||
| 95 | 251 | ▶ | $self->[FILENAME] = $self->[TYPE] eq 'FILE' ? $tmpx : $self->cache->id; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 251 | ▶ | my($shead, @sparam) = $opt->{_share} ? @{$opt->{_share}} : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 251 | ▶ | LOG( | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
DEBUG() and $shead
MC/DC0%0/2
DEBUG() and $shead
DEBUG()
$shead
Truth table33%1/3
A and B
A= DEBUG()B= $shead
| |||||||||||||||||||||||||||||
| 100 | SHARED_VARS => "Adding shared variables ($shead) from a dynamic include" | ||||||||||||||||||||||||||||
| 101 | ) if DEBUG && $shead; | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 251 | ▶ | $CODE = $self->_cache_miss( $cache_id, $shead, \@sparam, $opt, $tmp ) if ! $CODE; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 250 | my @args; | |||||||||||||||||||||||||||
| 106 | 250 | ▶ | push @args, $self if $self->[NEEDS_OBJECT]; # must be the first | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 250 | ▶ | push @args, @sparam if @sparam; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | 250 | ▶ | push @args, @{ $self->[ADD_ARGS] } if $self->[ADD_ARGS]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 250 | push @args, @{ $param }; | |||||||||||||||||||||||||||
| 110 | 250 | my $out = $CODE->( @args ); | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | $self->_call_filters( \$out, split RE_FILTER_SPLIT, $opt->{_filter} ) | ||||||||||||||||||||||||||||
| 113 | 250 | ▶ | if $opt->{_filter}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 250 | return $out; | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 249 | ▶ | sub _cache_miss { | ||||||||||||||||||||||||||
|
Subroutine
_cache_miss: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 119 | 249 | my($self, $cache_id, $shead, $sparam, $opt, $tmp) = @_; | |||||||||||||||||||||||||||
| 120 | # we have a cache miss; parse and compile | ||||||||||||||||||||||||||||
| 121 | 249 | ▶ | LOG( CACHE_MISS => $cache_id ) if DEBUG; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 249 | my $restore_header; | |||||||||||||||||||||||||||
| 124 | 249 | ▶ | if ( $shead ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | 3 | my $param_x = join q{,}, ('shift') x @{ $sparam }; | |||||||||||||||||||||||||||
| 126 | 3 | my $shared = sprintf q~my(%s) = (%s);~, $shead, $param_x; | |||||||||||||||||||||||||||
| 127 | 3 | $restore_header = $self->[HEADER]; | |||||||||||||||||||||||||||
| 128 | 3 | ▶ | $self->[HEADER] = $shared . q{;} . ( $self->[HEADER] || EMPTY_STRING ); | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->[14] || ''
MC/DC0%0/1
$self->[14] || ''
$self->[14]
Truth table50%1/2
A
A= $self->[14]
| |||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 249 | my %popt = ( %{ $opt }, cache_id => $cache_id, as_is => $opt->{as_is} ); | |||||||||||||||||||||||||||
| 132 | 249 | my $parsed = $self->_parse( $tmp, \%popt ); | |||||||||||||||||||||||||||
| 133 | 249 | my $CODE = $self->cache->populate( $cache_id, $parsed, $opt->{chkmt} ); | |||||||||||||||||||||||||||
| 134 | 248 | ▶ | $self->[HEADER] = $restore_header if $shead; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | 248 | return $CODE; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 2 | ▶ | sub _call_filters { | ||||||||||||||||||||||||||
|
Subroutine
_call_filters: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||
| 139 | 2 | my($self, $oref, @filters) = @_; | |||||||||||||||||||||||||||
| 140 | 2 | my $fname = $self->[FILENAME]; | |||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 2 | APPLY_FILTERS: foreach my $filter ( @filters ) { | |||||||||||||||||||||||||||
| 143 | 3 | my $fref = DUMMY_CLASS->can( 'filter_' . $filter ); | |||||||||||||||||||||||||||
| 144 | 3 | ▶ | if ( ! $fref ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | 0 | ${$oref} .= "\n[ filter warning ] Can not apply undefined filter" | |||||||||||||||||||||||||||
| 146 | . " $filter to $fname\n"; | ||||||||||||||||||||||||||||
| 147 | 0 | next; | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | 3 | $fref->( $self, $oref ); | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 2 | return; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 250 | ▶ | sub _wrap_compile { | ||||||||||||||||||||||||||
|
Subroutine
_wrap_compile: called CC=9 SCAR=23.9
| |||||||||||||||||||||||||||||
| 156 | 250 | my $self = shift; | |||||||||||||||||||||||||||
| 157 | 250 | ▶ | my $parsed = shift or fatal('tts.base.compiler._wrap_compile.parsed'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 158 | 250 | ▶ | LOG( CACHE_ID => $self->cache->id ) if $self->[WARN_IDS] && $self->cache->id; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->[17] and $self->cache->id
MC/DC0%0/2
$self->[17] and $self->cache->id
$self->[17]
$self->cache->id
Truth table33%1/3
A and B
A= $self->[17]B= $self->cache->id
| |||||||||||||||||||||||||||||
| 159 | 250 | ▶ | LOG( COMPILER => $self->[SAFE] ? 'Safe' : 'Normal' ) if DEBUG; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 160 | 250 | my($CODE, $error); | |||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 250 | ▶ | my $compiler = $self->[SAFE] ? COMPILER_SAFE : COMPILER; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 250 | $CODE = $compiler->compile( $parsed ); | |||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 250 | ▶ | if( $error = $@ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | 1 | my $error2; | |||||||||||||||||||||||||||
| 168 | 1 | ▶ | $error .= $error2 if $error2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 250 | return $CODE, $error; | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 140 | ▶ | sub _mini_compiler { | ||||||||||||||||||||||||||
|
Subroutine
_mini_compiler: called CC=8 SCAR=21.7
| |||||||||||||||||||||||||||||
| 175 | # little dumb compiler for internal templates | ||||||||||||||||||||||||||||
| 176 | 140 | my $self = shift; | |||||||||||||||||||||||||||
| 177 | 140 | ▶ | my $template = shift || fatal('tts.base.compiler._mini_compiler.notmp'); | ||||||||||||||||||||||||||
|
Condition33%1/3
shift() || fatal('tts.base.compiler._mini_compiler.notmp')
MC/DC0%0/2
shift() || fatal('tts.base.compiler._mini_compiler.notmp')
shift()
fatal('tts.base.compiler._mini_compiler.notmp')
Truth table33%1/3
A || B
A= shift()B= fatal('tts.base.compiler._mini_compiler.notmp')
| |||||||||||||||||||||||||||||
| 178 | 140 | ▶ | my $param = shift || fatal('tts.base.compiler._mini_compiler.noparam'); | ||||||||||||||||||||||||||
|
Condition33%1/3
shift() || fatal('tts.base.compiler._mini_compiler.noparam')
MC/DC0%0/2
shift() || fatal('tts.base.compiler._mini_compiler.noparam')
shift()
fatal('tts.base.compiler._mini_compiler.noparam')
Truth table33%1/3
A || B
A= shift()B= fatal('tts.base.compiler._mini_compiler.noparam')
| |||||||||||||||||||||||||||||
| 179 | 140 | ▶ | my $opt = shift || {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || {}
MC/DC100%1/1
shift() || {}
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 140 | ▶ | fatal('tts.base.compiler._mini_compiler.opt') if ref $opt ne 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | 140 | ▶ | fatal('tts.base.compiler._mini_compiler.param') if ref $param ne 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 140 | foreach my $var ( keys %{ $param } ) { | |||||||||||||||||||||||||||
| 185 | 449 | my $str = $param->{$var}; | |||||||||||||||||||||||||||
| 186 | 449 | $template =~ s{<%\Q$var\E%>}{$str}xmsg; | |||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 140 | ▶ | $template =~ s{\s+}{ }xmsg if $opt->{flatten}; # remove extra spaces | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 140 | return $template; | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 32 | 1; | |||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | __END__ | ||||||||||||||||||||||||||||