| 1 | package Hardware::Vhdl::Automake::PreProcessor; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # file line-reader, which can delegate preprocessing to a preprocessor module specified in the first line of the file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # to do: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # check first line for PreProcessor selector, and attempt to auto-load it and use it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | #use AutoLoader; # don't import AUTOLOAD, define our own | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | our $file_slurp_limit = 16000; # the size of the chunks of file we read at a time | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | our $VERSION = "1.00"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | =for notes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | For a 'delegate' style preprocessor, the module must provide the following class methods: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | Class->pp_style() - must return the string 'delegate' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | Class->new(sourcefile => $filename, includepaths => [$path1, $path2...], defines => {name1 => 'value1'...} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | and the following object methods: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | get_next_line() - returns a line and its newline at the end, or the last line (perhaps without a newline) or undef if there are no more lines | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | linenum() - returns the line number of the last line fetched | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | sourcefile() - returns the source file of the last line fetched | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | files_used() - returns a list of all the source files used | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | For a 'wholefile_with_synclines' style preprocessor, the module must provide the following class methods: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | Class->pp_style() - must return the string 'wholefile_with_synclines' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | $tempfile = Class->preprocess(sourcefile => $filename, includepaths => [$path1, $path2...], defines => {name1 => 'value1'...} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | This should preprocess the file and return a filename for the output file, which will be deleted later | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=19 SCAR=59.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my $self = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ungot => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | line => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | linenum => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | source => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | endat => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | delegate => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | firstline => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | no_processing => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if ( exists $args{no_processing} && $args{no_processing} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $args{"no_processing"} and $args{"no_processing"}
MC/DC0%0/2
exists $args{"no_processing"} and $args{"no_processing"}
exists $args{"no_processing"}
$args{"no_processing"}
Truth table0%0/3
A and B
A= exists $args{"no_processing"}B= $args{"no_processing"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $self->{no_processing} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | for my $optname (qw/preprocessor/) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | croak "argument $optname to $class is not allowed if no_processing option is set" if exists $args{$optname}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | for my $optname (qw/sourcestring startat endat linenum/) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | croak "argument $optname to $class is not allowed unless no_processing option is set" if exists $args{$optname}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if ( defined $args{sourcestring} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $self->{sourcestring} = $args{sourcestring}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if (defined $self->{endat}) { $self->{sourcestring} = substr $self->{sourcestring}, 0, $self->{endat} } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if (defined $self->{startat}) { $self->{sourcestring} = substr $self->{sourcestring}, $self->{startat} } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | $self->{source} = '<passed string>'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } elsif ( defined $args{sourcefile} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $fhi; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | -f $args{sourcefile} || croak "File '$args{sourcefile}' does not exist\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | open $fhi, "<$args{sourcefile}" || croak "Could not read '$args{sourcefile}'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
"<$args{'sourcefile'}" || croak("Could not read '$args{'sourcefile'}'\n")
MC/DC0%0/2
"<$args{'sourcefile'}" || croak("Could not read '$args{'sourcefile'}'\n")
"<$args{'sourcefile'}"
croak("Could not read '$args{'sourcefile'}'\n")
Truth table0%0/3
A || B
A= "<$args{'sourcefile'}"B= croak("Could not read '$args{'sourcefile'}'\n")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $self->{fhi} = $fhi; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | binmode $self->{fhi}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $self->{filebuf} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $self->{source} = $args{sourcefile}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $self->{files_used}{ $args{sourcefile} } = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | croak "No source code specified" unless defined $self->{source}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if (defined $args{startat} && defined $self->{fhi}) { seek $self->{fhi}, $args{startat}, 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $args{"startat"} and defined $self->{"fhi"}
MC/DC0%0/2
defined $args{"startat"} and defined $self->{"fhi"}
defined $args{"startat"}
defined $self->{"fhi"}
Truth table0%0/3
A and B
A= defined $args{"startat"}B= defined $self->{"fhi"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if (defined $args{endat}) { $self->{endat} = $args{endat}; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if (defined $args{linenum}) { $self->{linenum} = $args{linenum}-1; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | $self->_select_preprocessor($args{preprocessor}) if ( defined $args{preprocessor} ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub linenum { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
linenum: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # returns the line number of the last line fetched | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | defined $_[0]->{delegate} ? $_[0]->{delegate}->linenum : $_[0]->{linenum}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub sourcefile { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sourcefile: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # returns the source file of the last line fetched | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | defined $_[0]->{delegate} ? $_[0]->{delegate}->sourcefile : $_[0]->{source}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub files_used { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
files_used: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # returns a list of all the source files used | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | defined $_[0]->{delegate} ? $_[0]->{delegate}->files_used : $_[0]->{source}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | sub unget { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unget: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $self->{ungot} = $_[0] . $self->{ungot}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub get_next_line { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_next_line: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # returns a line and its newline at the end, or the last line (perhaps without a newline) or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | return $self->{delegate}->get_next_line if defined $self->{delegate}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if ($self->{ungot} ne '') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if ( $self->{ungot} =~ m/^(.*?(\015\012?|\012\015?))(.*)$/s ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $self->{line} = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $self->{ungot} = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $self->{line} = $self->{ungot}."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $self->{ungot} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $self->_just_get_a_line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | if ( defined $self->{line} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $self->{linenum}++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # check for preprocessor selection in first line of file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | #~ if ($self->{firstline}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | #~ print "First line is $self->{line}\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | #~ print "Preprocessing is " . ($self->{no_processing} ? 'disabled' : 'enabled') . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | #~ } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if ($self->{firstline} && !$self->{no_processing} && $self->{line} =~ m/ --< \s* use \s+ preprocess[oe]r \s+ (\S+) \s* >-- /xms) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->{"firstline"} and not $self->{"no_processing"} and $self->{"line"} =~ / --< \s* use \s+ preprocess[oe]r \s+ (\S+) \s* >-- /msx
$self->{"firstline"} and not $self->{"no_processing"}
MC/DC0%0/3
$self->{"firstline"} and not $self->{"no_processing"} and $self->{"line"} =~ / --< \s* use \s+ preprocess[oe]r \s+ (\S+) \s* >-- /msx
$self->{"firstline"}
not $self->{"no_processing"}
$self->{"line"} =~ / --< \s* use \s+ preprocess[oe]r \s+ (\S+) \s* >-- /msx
Truth table0%0/4
A and not(B) and C
A= $self->{"firstline"}B= not $self->{"no_processing"}C= $self->{"line"} =~ / --< \s* use \s+ preprocess[oe]r \s+ (\S+) \s* >-- /msx
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $ppname = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | #~ print "Preprocessor '$ppname' requested\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $self->{firstline} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $self->_select_preprocessor($ppname); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | return $self->get_next_line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $self->{firstline} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | #print "# got line $self->{linenum}: '$self->{line}'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | wantarray ? ( $self->{line}, $self->{source}, $self->{linenum} ) : $self->{line}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub _select_preprocessor { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_select_preprocessor: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my ($self, $pp) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $ppclass = 'Hardware::Vhdl::Automake::PreProcessor::'.$pp; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | #print "# preprocessor $pp requested!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my $ppstyle; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | eval " | |||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | require $ppclass; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | #eval { import $ppclass; }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | \$ppstyle = $ppclass->pp_style(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | "; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | die "Could not load preprocessor plugin '$pp':$@\n" if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if ($ppstyle eq 'delegate') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $self->{delegate} = $ppclass->new(sourcefile => $self->{source}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | #print "# Delegating to preprocessor plugin '$pp'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } elsif ($ppstyle eq 'wholefile_with_synclines') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my $ppfile; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | eval "\$ppfile = $ppclass->preprocess(sourcefile => \$self->{source});"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | die "Preprocessor plugin '$pp' failed: $@\n" if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $self->{delegate} = Hardware::Vhdl::Automake::PreProcessor->new(no_processing => 1, sourcefile => $ppfile, delete_source => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | die ref($self)." does not recognise preprocessor plugin style '$ppstyle'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | sub _just_get_a_line { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_just_get_a_line: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $self->{line} = undef; # default return value | |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | my $bufname = exists $self->{sourcestring} ? 'sourcestring' : 'filebuf'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # Just what is used as a newline may vary from OS to OS. Unix traditionally uses \012, one type of DOSish I/O uses \015\012, and Mac OS uses \015. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | GET_LINE: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $rem; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if (defined $self->{endat}) { $rem = $self->{endat} - tell($self->{fhi}) } # REMainding bytes we are allowed to read from the file | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ( $self->{$bufname} =~ m/^(.*?(\015\012?|\012\015?))(.*)$/s ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $self->{line} = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $self->{$bufname} = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | ▶ | } elsif ( exists $self->{fhi} && !eof $self->{fhi} && (!defined $rem || ($rem > 0))) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
exists $self->{"fhi"} and not eof $self->{"fhi"} and !defined($rem) || $rem > 0
exists $self->{"fhi"} and not eof $self->{"fhi"}
not defined $rem or $rem > 0
MC/DC0%0/4
exists $self->{"fhi"} and not eof $self->{"fhi"} and !defined($rem) || $rem > 0
exists $self->{"fhi"}
not eof $self->{"fhi"}
not defined $rem
$rem > 0
Truth table0%0/5
A and not(B) and not(C) or D
A= exists $self->{"fhi"}B= not eof $self->{"fhi"}C= not defined $remD= $rem > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | local $/ = \$file_slurp_limit; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | if (defined $rem && $file_slurp_limit > $rem) { $/ = \$rem } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $rem and $Hardware::Vhdl::Automake::PreProcessor::file_slurp_limit > $rem
MC/DC0%0/2
defined $rem and $Hardware::Vhdl::Automake::PreProcessor::file_slurp_limit > $rem
defined $rem
$Hardware::Vhdl::Automake::PreProcessor::file_slurp_limit > $rem
Truth table0%0/3
A and B
A= defined $remB= $Hardware::Vhdl::Automake::PreProcessor::file_slurp_limit > $rem
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $self->{$bufname} .= readline $self->{fhi}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | redo GET_LINE; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $self->{line} = $self->{$bufname}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $self->{$bufname} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | $self->{line} = undef if $self->{line} eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||