| 1 | # Copyright (c) 1998-2005 by Jonathan Swartz. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | package Mason::Compilation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 21 | $Mason::Compilation::VERSION = '2.24'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 21 | ▶ | use File::Basename qw(dirname); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 21 | ▶ | use Guard; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 21 | ▶ | use Mason::Component::ClassMeta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 21 | ▶ | use Mason::Util qw(dump_one_line json_encode read_file taint_is_on trim); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 21 | ▶ | use Mason::Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # Passed attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 21 | has 'interp' => ( required => 1, weak_ref => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 21 | has 'path' => ( required => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 21 | has 'source_file' => ( required => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # Derived attributes - most of these should be class attributes :( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 21 | has 'bad_attribute_hash' => ( lazy_build => 1, init_arg => undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 21 | has 'bad_method_hash' => ( lazy_build => 1, init_arg => undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 21 | has 'dir_path' => ( lazy_build => 1, init_arg => undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 21 | has 'named_block_regex' => ( lazy_build => 1, init_arg => undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 21 | has 'unnamed_block_regex' => ( lazy_build => 1, init_arg => undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 21 | has 'valid_flags_hash' => ( lazy_build => 1, init_arg => undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # Valid Perl identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 21 | my $identifier = qr/[[:alpha:]_]\w*/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # BUILD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 21 | ▶ | method BUILD () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BUILD: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # Initialize state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 36 | $self->{blocks} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 36 | $self->{blocks}->{class} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 36 | $self->{source} = read_file( $self->source_file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 36 | $self->{source} =~ s/\r\n?/\n/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 36 | $self->{line_number} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 36 | $self->{methods} = { main => $self->_new_method_hash( name => 'main' ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 36 | $self->{current_method} = $self->{methods}->{main}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 36 | $self->{is_pure_perl} = $self->interp->is_pure_perl_comp_path( $self->path ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 21 | ▶ | method _build_bad_attribute_hash () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_build_bad_attribute_hash: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | return { map { ( $_, 1 ) } @{ $self->bad_attribute_names } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 21 | ▶ | method _build_bad_method_hash () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_build_bad_method_hash: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 13 | return { map { ( $_, 1 ) } @{ $self->bad_method_names } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 21 | ▶ | method _build_dir_path () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_build_dir_path: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 215 | return dirname( $self->path ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 21 | ▶ | method _build_named_block_regex () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 188 | my $re = join '|', @{ $self->named_block_types }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 188 | return qr/$re/i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 21 | ▶ | method _build_unnamed_block_regex () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 241 | my $re = join '|', @{ $self->unnamed_block_types }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 241 | return qr/$re/i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 21 | ▶ | method _build_valid_flags_hash () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_build_valid_flags_hash: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 8 | return { map { ( $_, 1 ) } @{ $self->valid_flags } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # MODIFIABLE METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 21 | ▶ | method bad_attribute_names () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | return [qw(args m cmeta handle render wrap main)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 21 | ▶ | method bad_method_names () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 13 | return [qw(args m cmeta)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 21 | ▶ | method compile () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 241 | $self->parse(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 215 | return $self->_output_compiled_component(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 21 | ▶ | method named_block_types () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
named_block_types: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 188 | return [qw(after augment around before filter method override)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 21 | ▶ | method output_class_footer () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
output_class_footer: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 215 | return ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 21 | ▶ | method output_class_header () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
output_class_header: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 215 | return $self->interp->class_header; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 21 | ▶ | method parse () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=24 SCAR=32.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # We need to untaint the component source or else the regexes may fail. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 289 | ▶ | ( $self->{source} ) = ( ( delete $self->{source} ) =~ /(.*)/s ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | if taint_is_on(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 289 | ▶ | if ( $self->{is_pure_perl} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 15 | $self->{source} = "<%class> " . $self->{source} . " </%class>"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 15 | delete( $self->{methods}->{main} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 289 | my $lm = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 289 | my $iter = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 289 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1008 | ▶ | $self->_throw_syntax_error("parse loop iterated >1000 times - infinite loop?") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | if ++$iter > 1000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1008 | $self->{last_match} = $lm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1008 | ▶ | $self->_match_end && last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 768 | ▶ | $self->_match_apply_filter_end && last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 745 | ▶ | $self->_match_unnamed_block && ( $lm = 'unnamed_block' ) && next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->_match_unnamed_block and $lm = "unnamed_block"
MC/DC100%1/1
$self->_match_unnamed_block and $lm = "unnamed_block"
$self->_match_unnamed_block
Truth table100%2/2
A
A= $self->_match_unnamed_block
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 631 | ▶ | $self->_match_named_block && ( $lm = 'named_block' ) && next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->_match_named_block and $lm = "named_block"
MC/DC100%1/1
$self->_match_named_block and $lm = "named_block"
$self->_match_named_block
Truth table100%2/2
A
A= $self->_match_named_block
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 598 | ▶ | $self->_match_unknown_block && ( $lm = 'unknown_block' ) && next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->_match_unknown_block and $lm = "unknown_block"
MC/DC0%0/1
$self->_match_unknown_block and $lm = "unknown_block"
$self->_match_unknown_block
Truth table50%1/2
A
A= $self->_match_unknown_block
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 596 | ▶ | $self->_match_apply_filter && ( $lm = 'apply_filter' ) && next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->_match_apply_filter and $lm = "apply_filter"
MC/DC100%1/1
$self->_match_apply_filter and $lm = "apply_filter"
$self->_match_apply_filter
Truth table100%2/2
A
A= $self->_match_apply_filter
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 573 | ▶ | $self->_match_substitution && ( $lm = 'substitution' ) && next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->_match_substitution and $lm = "substitution"
MC/DC100%1/1
$self->_match_substitution and $lm = "substitution"
$self->_match_substitution
Truth table100%2/2
A
A= $self->_match_substitution
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 387 | ▶ | $self->_match_component_call && ( $lm = 'component_call' ) && next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->_match_component_call and $lm = "component_call"
MC/DC100%1/1
$self->_match_component_call and $lm = "component_call"
$self->_match_component_call
Truth table100%2/2
A
A= $self->_match_component_call
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 354 | ▶ | $self->_match_perl_line && ( $lm = 'perl_line' ) && next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->_match_perl_line and $lm = "perl_line"
MC/DC100%1/1
$self->_match_perl_line and $lm = "perl_line"
$self->_match_perl_line
Truth table100%2/2
A
A= $self->_match_perl_line
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 307 | ▶ | $self->_match_bad_close_tag && ( $lm = 'bad_close_tag' ) && next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->_match_bad_close_tag and $lm = "bad_close_tag"
MC/DC0%0/1
$self->_match_bad_close_tag and $lm = "bad_close_tag"
$self->_match_bad_close_tag
Truth table50%1/2
A
A= $self->_match_bad_close_tag
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 305 | ▶ | $self->_match_plain_text && ( $lm = 'plain_text' ) && next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->_match_plain_text and $lm = "plain_text"
MC/DC0%0/1
$self->_match_plain_text and $lm = "plain_text"
$self->_match_plain_text
Truth table50%1/2
A
A= $self->_match_plain_text
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | $self->_throw_syntax_error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | "could not parse next element at position " . pos( $self->{source} ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 21 | ▶ | method process_perl_code ($coderef) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
process_perl_code: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 222 | return $coderef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 21 | ▶ | method unnamed_block_types () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
unnamed_block_types: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 241 | return [qw(args class doc flags init perl shared text)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 21 | ▶ | method valid_flags () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
valid_flags: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 8 | return [qw(extends)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # PRIVATE METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 21 | ▶ | method _add_to_class_block ($text) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_add_to_class_block: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # Don't add a line number comment when following a perl-line. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # We know a perl-line is always _one_ line, so we know that the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # line numbers are going to match up as long as the first line in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # a series has a line number comment before it. Adding a comment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # can break certain constructs like qw() list that spans multiple | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # perl-lines. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 5 | ▶ | if ( $self->{last_match} ne 'perl_line' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | $text = $self->_output_line_number_comment . $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 5 | $self->{blocks}->{class} .= $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 21 | ▶ | method _add_to_current_method ($text) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 620 | ▶ | if ( $self->{last_match} ne 'perl_line' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 593 | $text = $self->_output_line_number_comment . $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 620 | $self->{current_method}->{body} .= $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 21 | ▶ | method _assert_not_nested ($block_type) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_assert_not_nested: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | $self->_throw_syntax_error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | "Cannot nest <%$block_type> block inside <%$self->{in_recursive_parse}> block") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 27 | ▶ | if $self->{in_recursive_parse}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 21 | ▶ | method _attribute_declaration ($name, $params, $line_number) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | $self->_throw_syntax_error("'$name' is reserved and cannot be used as an attribute name") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 10 | ▶ | if $self->bad_attribute_hash->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 10 | return $self->_processed_perl_code( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | "%shas '%s' => %s", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | $self->_output_line_number_comment($line_number), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | $name, $params | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 21 | ▶ | method _handle_after_block () { $self->_handle_method_modifier_block( 'after', @_ ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_handle_after_block: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 21 | ▶ | method _handle_around_block () { $self->_handle_method_modifier_block( 'around', @_ ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 21 | ▶ | method _handle_augment_block () { $self->_handle_method_modifier_block( 'augment', @_ ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 21 | ▶ | method _handle_before_block () { $self->_handle_method_modifier_block( 'before', @_ ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_handle_before_block: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 21 | ▶ | method _handle_override_block () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_handle_override_block: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | $self->_handle_method_modifier_block( 'override', @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 21 | ▶ | method _handle_method_modifier_block ($block_type, $contents, $name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 13 | my $modifier = $block_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 13 | ▶ | $self->_throw_syntax_error("Invalid method modifier name '$name'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | if $name !~ /^$identifier$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 12 | $self->_assert_not_nested($block_type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 11 | my $method_key = "$block_type $name"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | $self->_throw_syntax_error("Duplicate definition of method modifier '$method_key'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 11 | ▶ | if exists $self->{methods}->{"$method_key"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 10 | my $method = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | $self->_new_method_hash( name => $name, type => 'modifier', modifier => $modifier ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 10 | $self->{methods}->{"$method_key"} = $method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 10 | $self->_recursive_parse( $block_type, $contents, $method ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 21 | ▶ | method _handle_apply_filter ($filter_expr) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_handle_apply_filter: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 23 | my $rest = substr( $self->{source}, pos( $self->{source} ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 23 | my $method = $self->_new_method_hash( type => 'apply_filter' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 23 | local $self->{end_parse} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 23 | $self->_recursive_parse( 'filter', $rest, $method ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 23 | ▶ | if ( my $incr = $self->{end_parse} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 22 | pos( $self->{source} ) += $incr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | $self->_throw_syntax_error("'{{' without matching '}}'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 22 | my $code = sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | "\$self->m->_apply_filters_to_output(%s, %s);\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | $self->_processed_perl_code($filter_expr), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | $self->_output_method($method) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 22 | $self->_add_to_current_method($code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 21 | ▶ | method _handle_args_block ($contents) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_handle_args_block: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | $self->_handle_attributes_list( $contents, 'args' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 21 | ▶ | method _handle_attributes_list ($contents, $attr_type) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=9 SCAR=22.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | my @lines = split( "\n", $contents ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | my @attributes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 2 | my $line_number = $self->{line_number} - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 2 | foreach my $line (@lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 16 | $line_number++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 16 | trim($line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 16 | ▶ | next if $line =~ /^\#/ || $line !~ /\S/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$line =~ /^\#/ or not $line =~ /\S/
MC/DC100%2/2
$line =~ /^\#/ or not $line =~ /\S/
$line =~ /^\#/
not $line =~ /\S/
Truth table100%3/3
A or not(B)
A= $line =~ /^\#/B= not $line =~ /\S/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 10 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | my ( $name, $rest ) = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | $line =~ / | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | \s* # optional whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | (?: \$\.)? # optional $. prefix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | ([^\W\d]\w*) # valid Perl variable name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | (?:\s*=>\s*(.*))? # optional arrow then default or attribute params | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | /x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 10 | my ($params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 10 | ▶ | if ( defined($rest) && length($rest) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $rest and length $rest
MC/DC50%1/2
defined $rest and length $rest
defined $rest
length $rest
Truth table66%2/3
A and B
A= defined $restB= length $rest
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 7 | ▶ | if ( $rest =~ /^\s*\(/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 3 | $params = "$rest\n;"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 4 | $params = sprintf( "(default => %s\n);", $rest ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 3 | $params = '();'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 10 | ▶ | if ( $attr_type eq 'shared' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 3 | $params = '(' . 'init_arg => undef, ' . substr( $params, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 10 | push( @attributes, $self->_attribute_declaration( $name, $params, $line_number ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $self->{line_number} = $line_number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $self->_throw_syntax_error("Invalid attribute line '$line'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 2 | $self->{blocks}->{attributes} .= join( "\n", @attributes ) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 21 | ▶ | method _handle_class_block ($contents) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_handle_class_block: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | $self->{blocks}->{class} .= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 49 | $self->_output_line_number_comment . $self->_processed_perl_code($contents); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 21 | ▶ | method _handle_component_call ($contents) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 17 | my ( $prespace, $call, $postspace ) = ( $contents =~ /(\s*)(.*)(\s*)/s ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 17 | ▶ | if ( $call =~ m,^[\w/.], ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 15 | my $comma = index( $call, ',' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 15 | ▶ | $comma = length $call if $comma == -1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 15 | ( my $comp = substr( $call, 0, $comma ) ) =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 15 | $call = "'$comp'" . substr( $call, $comma ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 17 | $call = $self->_processed_perl_code($call); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 17 | my $code = "\$m->comp( $prespace $call $postspace \n); "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 17 | $self->_add_to_current_method($code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 21 | ▶ | method _handle_doc_block () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | # Don't do anything - just discard the comment. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 21 | ▶ | method _handle_filter_block ($contents, $name, $arglist) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 3 | my $new_contents = join( '', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | '<%perl>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 'return Mason::DynamicFilter->new(', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 'filter => sub {', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 'my $yield = shift;', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | '$m->capture(sub {', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | '</%perl>', $contents, '<%perl>}); });</%perl>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 3 | $self->_handle_method_block( $new_contents, $name, $arglist ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 21 | ▶ | method _handle_flags_block ($contents) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_handle_flags_block: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 9 | my $ending = qr, (?: \n | # newline or | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | (?= </%flags> ) ) # end of block (don't consume it) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | ,ix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 9 | ▶ | while ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | $contents =~ / | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | \G | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | [ \t]* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | ([\w_]+) # identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | [ \t]*=>[ \t]* # separator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | (\S[^\n]*?) # value ( must start with a non-space char) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | $ending | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | \G\n # a plain empty line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | \G | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | [ \t]* # an optional comment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | \# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | [^\n]* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | $ending | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | \G[ \t]+? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | $ending | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | /xgc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 16 | my ( $flag, $value ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 16 | ▶ | if ( defined $flag && defined $value && length $flag && length $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
defined $flag and defined $value and length $flag and length $value
defined $flag and defined $value and length $flag
defined $flag and defined $value
MC/DC25%1/4
defined $flag and defined $value and length $flag and length $value
defined $flag
defined $value
length $flag
length $value
Truth table40%2/5
A and B and C and D
A= defined $flagB= defined $valueC= length $flagD= length $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 8 | ▶ | if ( $self->valid_flags_hash->{$flag} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 7 | $self->{blocks}->{flags}->{$flag} = eval($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 7 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 1 | $self->_throw_syntax_error("Invalid flag '$flag'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 21 | ▶ | method _handle_init_block ($contents) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_handle_init_block: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | $self->{current_method}->{init} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 8 | $self->_output_line_number_comment . $self->_processed_perl_code($contents); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 21 | ▶ | method _handle_method_block ($contents, $name, $arglist) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 17 | ▶ | $self->_throw_syntax_error("Invalid method name '$name'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | if $name !~ /^$identifier$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | $self->_throw_syntax_error("'$name' is reserved and cannot be used as a method name") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 16 | ▶ | if $self->bad_method_hash->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | $self->_throw_syntax_error("Duplicate definition of method '$name'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 15 | ▶ | if exists $self->{methods}->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 14 | $self->_assert_not_nested('method'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 14 | my $method = $self->_new_method_hash( name => $name, arglist => $arglist ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 14 | $self->{methods}->{$name} = $method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 14 | $self->_recursive_parse( 'method', $contents, $method ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 21 | ▶ | method _handle_perl_block ($contents) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 40 | $self->_add_to_current_method( $self->_processed_perl_code($contents) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 21 | ▶ | method _handle_perl_line ($type, $contents) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 46 | my $code = $self->_processed_perl_code( $contents . "\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 46 | ▶ | if ( $type eq 'perl' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 41 | $self->_add_to_current_method($code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 5 | $self->_add_to_class_block($code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 21 | ▶ | method _handle_plain_text ($text) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | # Escape single quotes and backslashes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 304 | $text =~ s,([\'\\]),\\$1,g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 304 | my $code = "\$\$_m_buffer .= '$text';\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 304 | $self->_add_to_current_method($code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 21 | ▶ | method _handle_shared_block ($contents) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_handle_shared_block: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 1 | $self->_handle_attributes_list( $contents, 'shared' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 21 | ▶ | method _handle_substitution ($text, $filter_list) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | # This is a comment tag if all lines of text contain only whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | # or start with whitespace and a comment marker, e.g. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | # <% | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | # # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | # # foo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 180 | my @lines = split( /\n/, $text ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 180 | ▶ | unless ( grep { /^\s*[^\s\#]/ } @lines ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 179 | $text = $self->_processed_perl_code($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 179 | ▶ | if ($filter_list) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 12 | ▶ | if ( my @filters = grep { /\S/ } split( /\s*,\s*/, $filter_list ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 12 | my $filter_call_list = join( ", ", map { "\$self->$_()" } @filters ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 12 | $text = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | sprintf( '$self->m->_apply_filters(%s, sub { local $_ = %s; defined($_) ? $_ : "" })', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | $filter_call_list, $text ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 179 | my $code = "for (scalar($text)) { \$\$_m_buffer .= \$_ if defined }\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 179 | $self->_add_to_current_method($code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 21 | ▶ | method _handle_text_block ($contents) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_handle_text_block: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 2 | $contents =~ s/^\n//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 2 | $contents =~ s,([\'\\]),\\$1,g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 2 | $self->_add_to_current_method("\$\$_m_buffer .= '$contents';\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 21 | ▶ | method _match_apply_filter () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 596 | my $pos = pos( $self->{source} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | # Match % ... {{ at beginning of line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 596 | ▶ | if ( $self->{source} =~ / \G (?<=^) % ([^\n]*) \{\{ [^\S\n]* (?:\#.*)? \n /gcmx ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 20 | my ($filter_expr) = ($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 20 | $self->_handle_apply_filter($filter_expr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 19 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | # Old syntax, for backward compatibility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | # Match <% ... { %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 576 | ▶ | if ( $self->{source} =~ /\G(\n)? <% (.+?) (\s*\{\s*) %>(\n)?/xcgs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 5 | my ( $preceding_newline, $filter_expr, $opening_brace, $following_newline ) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | ( $1, $2, $3, $4 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | # and make sure we didn't go through a %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 5 | ▶ | if ( $filter_expr !~ /%>/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 3 | for ( $preceding_newline, $filter_expr, $following_newline ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 9 | ▶ | $self->{line_number} += tr/\n// if defined($_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 3 | $self->_handle_apply_filter($filter_expr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 2 | pos( $self->{source} ) = $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 573 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 21 | ▶ | method _match_apply_filter_end () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 768 | ▶ | if ( $self->{source} =~ / \G (?<=^) % [ \t]+ \}\} [^\S\n]* (?:\#.*)? (?:\n\n?|\z) /gmcx ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 20 | ▶ | if ( $self->{current_method}->{type} eq 'apply_filter' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 19 | $self->{end_parse} = pos( $self->{source} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 19 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 1 | $self->_throw_syntax_error("'}}' without matching '{{'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | # Old syntax - <% } %> and </%> - for backward compatibility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 748 | ▶ | if ( $self->{current_method}->{type} eq 'apply_filter' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"current_method"}{"type"} eq "apply_filter" and $self->{"source"} =~ m[\G (?: (?: <% [ \t]* \} [ \t]* %> ) | (?: </%> ) ) (\n?\n?)]cgx
MC/DC100%2/2
$self->{"current_method"}{"type"} eq "apply_filter" and $self->{"source"} =~ m[\G (?: (?: <% [ \t]* \} [ \t]* %> ) | (?: </%> ) ) (\n?\n?)]cgx
$self->{"current_method"}{"type"} eq "apply_filter"
$self->{"source"} =~ m[\G (?: (?: <% [ \t]* \} [ \t]* %> ) | (?: </%> ) ) (\n?\n?)]cgx
Truth table100%3/3
A and B
A= $self->{"current_method"}{"type"} eq "apply_filter"B= $self->{"source"} =~ m[\G (?: (?: <% [ \t]* \} [ \t]* %> ) | (?: </%> ) ) (\n?\n?)]cgx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | && $self->{source} =~ /\G (?: (?: <% [ \t]* \} [ \t]* %> ) | (?: <\/%> ) ) (\n?\n?)/gcx ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 3 | $self->{end_parse} = pos( $self->{source} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 745 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 21 | ▶ | method _match_block ($block_regex, $named) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_match_block: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 1376 | my $regex = qr/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | \G(\n?) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | <% ($block_regex) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | (?: \s+ ([^\s\(>]+) ([^>]*) )? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | /x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 1376 | ▶ | if ( $self->{source} =~ /$regex/gcs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 147 | my ( $preceding_newline, $block_type, $name, $arglist ) = ( $1, $2, $3, $4 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 147 | ▶ | $self->_throw_syntax_error("<%$block_type> block requires a name") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$named and not defined $name
MC/DC100%2/2
$named and not defined $name
$named
not defined $name
Truth table100%3/3
A and not(B)
A= $namedB= not defined $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | if ( $named && !defined($name) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 145 | ▶ | $self->_throw_syntax_error("<%$block_type> block does not take a name") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $named and defined $name
MC/DC100%2/2
not $named and defined $name
not $named
defined $name
Truth table100%3/3
not(A) and B
A= not $namedB= defined $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | if ( !$named && defined($name) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 144 | my $block_method = "_handle_${block_type}_block"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 144 | ▶ | $self->{line_number}++ if $preceding_newline; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 144 | my ( $block_contents, $nl ) = $self->_match_block_end($block_type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 143 | $self->$block_method( $block_contents, $name, $arglist ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 134 | $self->{line_number} += $block_contents =~ tr/\n//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 134 | ▶ | $self->{line_number} += length($nl) if $nl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 134 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 1229 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 21 | ▶ | method _match_block_end ($block_type) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_match_block_end: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 144 | my $re = qr,\G(.*?)</%\Q$block_type\E>(\n?\n?),is; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 144 | ▶ | if ( $self->{source} =~ /$re/gc ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 143 | return ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 1 | $self->_throw_syntax_error("<%$block_type> without matching </%$block_type>"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 21 | ▶ | method _match_component_call () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_match_component_call: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 387 | ▶ | if ( $self->{source} =~ /\G<&(?!\|)/gcs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 33 | ▶ | if ( $self->{source} =~ /\G(.*?)&>/gcs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 32 | my $body = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 32 | $self->_handle_component_call($body); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 32 | $self->{line_number} += $body =~ tr/\n//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 32 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 1 | $self->_throw_syntax_error("'<&' without matching '&>'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 21 | ▶ | method _match_end () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_match_end: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 1008 | ▶ | if ( $self->{source} =~ /(\G\z)/gcs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 240 | $self->{line_number} += $1 =~ tr/\n//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 240 | ▶ | return defined $1 && length $1 ? $1 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $1 and length $1
MC/DC0%0/2
defined $1 and length $1
defined $1
length $1
Truth table33%1/3
A and B
A= defined $1B= length $1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 768 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 21 | ▶ | method _match_named_block () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 631 | $self->_match_block( $self->named_block_regex, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 21 | ▶ | method _match_perl_line () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_match_perl_line: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 354 | ▶ | if ( $self->{source} =~ /\G(?<=^)(%%?)([^\n]*)(?:\n|\z)/gcm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 47 | my ( $percents, $line ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 47 | ▶ | if ( length($line) && $line !~ /^\s/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
length $line and not $line =~ /^\s/
MC/DC100%2/2
length $line and not $line =~ /^\s/
length $line
not $line =~ /^\s/
Truth table100%3/3
A and not(B)
A= length $lineB= not $line =~ /^\s/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 1 | $self->_throw_syntax_error("$percents must be followed by whitespace or EOL"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 46 | ▶ | if ( $percents eq '%%' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 5 | ▶ | if ( $line =~ /\{\s*$/ && $self->{source} =~ /\G(?!%%)/gcm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$line =~ /\{\s*$/ and $self->{"source"} =~ /\G(?!%%)/cgm
MC/DC0%0/2
$line =~ /\{\s*$/ and $self->{"source"} =~ /\G(?!%%)/cgm
$line =~ /\{\s*$/
$self->{"source"} =~ /\G(?!%%)/cgm
Truth table66%2/3
A and B
A= $line =~ /\{\s*$/B= $self->{"source"} =~ /\G(?!%%)/cgm
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | $self->_throw_syntax_error("%%-lines cannot be used to surround content"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 46 | ▶ | $self->_handle_perl_line( ( $percents eq '%' ? 'perl' : 'class' ), $line ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 46 | $self->{line_number}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 46 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 307 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 21 | ▶ | method _match_plain_text () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_match_plain_text: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | # Most of these terminator patterns actually belong to the next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | # lexeme in the source, so we use a lookahead if we don't want to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | # consume them. We use a lookbehind when we want to consume | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | # something in the matched text, like the newline before a '%'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 305 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | $self->{source} =~ m{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | \G | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | (.*?) # anything, followed by: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | (?<=\n)(?=%) # an eval line - consume the \n | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | (?=<%\s) # a substitution tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | (?=[%&]>) # an end substitution or component call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | (?=</?[%&]) # a block or call start or end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | # - don't consume | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | \\\n # an escaped newline - throw away | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | \z # end of string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | }xcgs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 305 | my ( $orig_text, $swallowed ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 305 | my $text = $orig_text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | # Chomp newline before block start | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 305 | ▶ | if ( substr( $self->{source}, pos( $self->{source} ), 3 ) =~ /<%[a-z]/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 15 | chomp($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 305 | ▶ | $self->_handle_plain_text($text) if length $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | # Not checking definedness seems to cause extra lines to be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | # counted with Perl 5.00503. I'm not sure why - dave | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 305 | $self->{line_number} += tr/\n// foreach grep defined, ( $orig_text, $swallowed ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 305 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 21 | ▶ | method _match_substitution () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_match_substitution: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 573 | ▶ | return 0 unless $self->{source} =~ /\G<%/gcs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 186 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | $self->{source} =~ m{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | \G | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | (\s*) # Initial whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | (.*?) # Substitution body ($1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | \s* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | (?<!\|) # Not preceded by a '|' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | \| # A '|' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | \s* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | ( # (Start $3) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | $identifier # A filter name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | (?:\s*,\s*$identifier)* # More filter names, with comma separators | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | )? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | (\s*) # Final whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | %> # Closing tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | }xcigs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 185 | my ( $start_ws, $body, $after_body, $filters, $end_ws ) = ( $1, $2, $3, $4, $5 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 185 | ▶ | $self->_throw_syntax_error("found empty '<% %>' tag") unless $body =~ /\S/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 182 | ▶ | $self->_throw_syntax_error("whitespace required after '<%'") unless length($start_ws); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | $self->{line_number} += tr/\n// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 181 | foreach grep defined, ( $start_ws, $body, $after_body, $end_ws ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 181 | ▶ | $self->_throw_syntax_error("whitespace required before '%>'") unless length($end_ws); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 180 | $self->_handle_substitution( $body, $filters ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 180 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 1 | $self->_throw_syntax_error("'<%' without matching '%>'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 21 | ▶ | method _match_unknown_block () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 598 | ▶ | if ( $self->{source} =~ /\G(?:\n?)<%([A-Za-z_]+)>/gc ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 2 | $self->_throw_syntax_error("unknown block '<%$1>'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 21 | ▶ | method _match_unnamed_block () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_match_unnamed_block: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 745 | $self->_match_block( $self->unnamed_block_regex, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 21 | ▶ | method _match_bad_close_tag () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_match_bad_close_tag: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 307 | ▶ | if ( my ($end_tag) = ( $self->{source} =~ /\G\s*(%>|&>)/gc ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 2 | ( my $begin_tag = reverse($end_tag) ) =~ s/>/</; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 2 | $self->_throw_syntax_error("'$end_tag' without matching '$begin_tag'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 21 | ▶ | method _new_method_hash () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 289 | return { body => '', init => '', type => 'method', @_ }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 21 | ▶ | method _output_attributes () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 215 | ▶ | return $self->{blocks}->{attributes} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'blocks'}{'attributes'} || ''
MC/DC100%1/1
$self->{'blocks'}{'attributes'} || ''
$self->{'blocks'}{'attributes'}
Truth table100%2/2
A
A= $self->{'blocks'}{'attributes'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 21 | ▶ | method _output_class_block () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 215 | ▶ | return $self->{blocks}->{class} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'blocks'}{'class'} || ''
MC/DC100%1/1
$self->{'blocks'}{'class'} || ''
$self->{'blocks'}{'class'}
Truth table100%2/2
A
A= $self->{'blocks'}{'class'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 21 | ▶ | method _output_class_initialization () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 215 | return join( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | "our (\$_class_cmeta, \$m, \$_m_buffer, \$_interp);", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | "BEGIN { ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | "local \$_interp = Mason::Interp->current_load_interp;", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | "\$_interp->component_moose_class->import;", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | "\$_interp->component_import_class->import;", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | "}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | "*m = \\\$Mason::Request::current_request;", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | "*_m_buffer = \\\$Mason::Request::current_buffer;", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | # Must be defined here since inner relies on caller() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | "sub _inner { inner() }" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 21 | ▶ | method _output_cmeta () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 215 | ▶ | my $q = sub { "'$_[0]'" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 215 | my %cmeta_info = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | dir_path => $q->( $self->dir_path ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | is_top_level => $q->( $self->interp->is_top_level_comp_path( $self->path ) ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | path => $q->( $self->path ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | source_file => $q->( $self->source_file ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | object_file => '__FILE__', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | class => 'CLASS', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | interp => '$interp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | return join( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | "method _set_class_cmeta (\$interp) {", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | "\$_class_cmeta = \$interp->component_class_meta_class->new(", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 215 | map { sprintf( "'%s' => %s,", $_, $cmeta_info{$_} ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | sort( keys(%cmeta_info) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | ');', '}', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 'sub _unset_class_cmeta { undef $_class_cmeta }', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 'sub _class_cmeta { $_class_cmeta }' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 21 | ▶ | method _output_compiled_component () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | return join( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 215 | ▶ | map { trim($_) } grep { defined($_) && length($_) } ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $_ && length $_
MC/DC100%2/2
defined $_ && length $_
defined $_
length $_
Truth table100%3/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | $self->_output_flag_comment, $self->_output_class_initialization, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | $self->output_class_header, $self->_output_global_declarations, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | $self->_output_cmeta, $self->_output_attributes, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | $self->_output_class_block, $self->_output_methods, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | $self->output_class_footer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | ) . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 21 | ▶ | method _output_flag_comment () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 215 | ▶ | if ( my $flags = $self->{blocks}->{flags} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 6 | ▶ | if (%$flags) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 6 | ( my $json = json_encode($flags) ) =~ s/\n//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 6 | return "# FLAGS: $json\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 21 | ▶ | method _output_global_declaration ($spec) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 4 | my ( $sigil, $name ) = $self->interp->_parse_global_spec($spec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 4 | return sprintf( 'our %s%s; *%s = \%s%s::%s;' . "\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | $sigil, $name, $name, $sigil, $self->interp->globals_package, $name ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 21 | ▶ | method _output_global_declarations () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 215 | join( "\n", map { $self->_output_global_declaration($_) } @{ $self->interp->allow_globals } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 21 | ▶ | method _output_line_number_comment ($line_number) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 662 | ▶ | if ( !$self->interp->no_source_line_numbers ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 657 | ▶ | $line_number ||= $self->{line_number}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$line_number ||= $self->{"line_number"}
MC/DC0%0/2
$line_number ||= $self->{"line_number"}
$line_number
$self->{"line_number"}
Truth table66%2/3
A ||= B
A= $line_numberB= $self->{"line_number"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 657 | ▶ | if ($line_number) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 657 | my $comment = sprintf( qq{#line %s "%s"\n}, $line_number, $self->source_file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 657 | return $comment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 5 | return ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 21 | ▶ | method _output_method ($method) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_output_method: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 244 | my $path = $self->path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 244 | my $name = $method->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 244 | my $type = $method->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 244 | ▶ | my $modifier = $method->{modifier} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$method->{'modifier'} || ''
MC/DC100%1/1
$method->{'modifier'} || ''
$method->{'modifier'}
Truth table100%2/2
A
A= $method->{'modifier'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 244 | ▶ | my $arglist = $method->{arglist} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$method->{'arglist'} || ''
MC/DC100%1/1
$method->{'arglist'} || ''
$method->{'arglist'}
Truth table100%2/2
A
A= $method->{'arglist'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 244 | my $contents = join( "\n", grep { /\S/ } ( $method->{init}, $method->{body} ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 244 | ▶ | my $start = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | $type eq 'apply_filter' ? "sub {" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | : $modifier eq 'around' ? "around '$name' => sub {\nmy \$orig = shift; my \$self = shift;" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | : $type eq 'modifier' ? "$modifier '$name' => sub {\nmy \$self = shift;" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | : "method $name $arglist {"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 244 | ▶ | my $end = $modifier ? "};" : "}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 244 | return join( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | $start, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | # do not add a block around this, it introduces | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | # a separate scope and might break cleanup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | # blocks (or all sort of other things!) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | $contents, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | # don't return values explicitly. semi before return will help catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | # syntax errors in component body. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | ";return;", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | $end, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 21 | ▶ | method _output_methods () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | # Sort methods so that modifiers come after | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | my @sorted_methods_keys = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 215 | ▶ | sort { ( index( $a, ' ' ) <=> index( $b, ' ' ) ) || $a cmp $b } keys( %{ $self->{methods} } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
index($a, ' ') <=> index($b, ' ') || $a cmp $b
MC/DC0%0/2
index($a, ' ') <=> index($b, ' ') || $a cmp $b
index($a, ' ') <=> index($b, ' ')
$a cmp $b
Truth table66%2/3
A || B
A= index($a, ' ') <=> index($b, ' ')B= $a cmp $b
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 215 | join( "\n", map { $self->_output_method( $self->{methods}->{$_} ) } @sorted_methods_keys ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 21 | ▶ | method _processed_perl_code ($code) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 386 | my $coderef = \$code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 386 | $self->process_perl_code($coderef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 386 | return $$coderef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 21 | ▶ | method _recursive_parse ($block_type, $contents, $method) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | # Save current regex position, then locally set source to the contents and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | # recursively parse. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 48 | local $self->{in_recursive_parse} = $block_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 48 | my $save_pos = pos( $self->{source} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 48 | ▶ | scope_guard { pos( $self->{source} ) = $save_pos }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 48 | local $self->{source} = $contents; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 48 | local $self->{current_method} = $method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 48 | local $self->{line_number} = $self->{line_number}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 48 | $self->parse(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 21 | ▶ | method _throw_syntax_error ($msg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_throw_syntax_error: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 25 | die sprintf( "%s at %s line %d\n", $msg, $self->source_file, $self->{line_number} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 21 | __PACKAGE__->meta->make_immutable(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 21 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||